Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable win32 #7

Open
wants to merge 18 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ tags
gh-pages
site
*.tests
<<<<<<< HEAD
lib/.CC
lib/.DEF
lib/.LN
=======
lib/*.conf
>>>>>>> added a simple config script
test/*_test
test/*.jpg
test/*.png
Expand All @@ -30,3 +34,4 @@ data/*
tool/*
config.mk
build
Thumbs.db
34 changes: 34 additions & 0 deletions bin/Makefile.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CC = gcc
CXXFLAGS = -mno-cygwin -O3 -msse2 -Wall -std=c99 -fms-extensions -pedantic -I"../lib"
LDFLAGS = -L"../lib" -L"/strawberry/c/lib" -lccv -ljpeg -lpng -lz -lm -lws2_32

o = .o
a = .a

RM_F = del

.SUFFIXES : .c .i $(o) .dll $(a) .exe .rc .res

.PHONY : all .exe

TARGETS = bbffmt siftmatch bbfcreate bbfdetect swtdetect swtcreate dpmdetect

# Currently broken
# convert

all: ../lib/libccv.a $(TARGETS)

clean:
$(RM_F) *$o ../lib/*$o ../lib/3rdparty/*$o ../lib/libccv$a $(TARGETS)

$(TARGETS) : $(TARGETS:+".exe")
+@echo.

%.exe : %.o '../lib/libccv.a'
$(CC) $< -o $@ $(LDFLAGS)

../lib/libccv.a: ../lib/ccv.h
+cd ..\lib && $(MAKE) libccv.a

%.o: %.c '../lib/ccv.h'
$(CC) $(CXXFLAGS) -c $< -o $@
46 changes: 46 additions & 0 deletions bin/dpmcreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
void exit_with_help()
{
printf(
<<<<<<< HEAD
"\n \033[1mUSAGE\033[0m\n\n dpmcreate [OPTION...]\n\n"
" \033[1mREQUIRED OPTIONS\033[0m\n\n"
" --positive-list : text file contains a list of positive files in format:\n"
Expand All @@ -30,6 +31,31 @@ void exit_with_help()
" --grayscale : 0 or 1, whether to exploit color in a given image [DEFAULT TO 0]\n"
" --discard-estimating-constant : 0 or 1, when estimating bounding boxes, discarding constant (which may be accumulated error) [DEFAULT TO 1]\n"
" --percentile-breakdown : 0.00 - 1.00, the percentile use for breakdown threshold [DEFAULT TO 0.05]\n\n"
=======
"\033[1mUSAGE\033[0m\n\tdpmcreate [OPTION...]\n\n"
"\033[1mREQUIRED OPTIONS\033[0m\n"
"\t--positive-list : text file contains a list of positive files in format:\n"
"\t <file name> x y width height \\newline\n"
"\t--background-list : text file contains a list of image files that don't contain any target objects\n"
"\t--negative-count : the number of negative examples we should collect from background files to initialize SVM\n"
"\t--model-component : the number of root filters in our mixture model\n"
"\t--model-part : the number of part filters for each root filter\n"
"\t--working-dir : the directory to save progress and produce result model\n"
"\t--symmetric : 0 or 1, whether to exploit symmetric property of the object\n\n"
"\033[1mOTHER OPTIONS\033[0m\n"
"\t--base-dir : change the base directory so that the program can read images from there\n"
"\t--iterations : how many iterations needed for stochastic gradient descent [DEFAULT TO 20]\n"
"\t--relabels : how many relabel procedure needed [DEFAULT TO 5]\n"
"\t--alpha : the step size for stochastic gradient descent [DEFAULT TO 0.1]\n"
"\t--alpha-ratio : decrease the step size for each iteration [DEFAULT TO 0.9]\n"
"\t--margin-c : the famous C in SVM [DEFAULT TO 0.002]\n"
"\t--balance : to balance the weight of positive examples and negative examples [DEFAULT TO 1.75]\n"
"\t--negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 500]\n"
"\t--include-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object [DEFAULT TO 0.7]\n"
"\t--exclude-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Below this threshold, it is ensured to not be the same object [DEFAULT TO 0.5]\n"
"\t--grayscale : 0 or 1, whether to exploit color in a given image [DEFAULT TO 1]\n"
"\t--percentile-breakdown : 0.00 - 1.00, the percentile use for breakdown threshold [DEFAULT TO 0.05]\n"
>>>>>>> added a simple config script
);
exit(-1);
}
Expand Down Expand Up @@ -70,6 +96,7 @@ int main(int argc, char** argv)
char* base_dir = 0;
int negative_count = 0;
ccv_dpm_param_t detector = { .interval = 8, .min_neighbors = 0, .flags = 0, .threshold = 0.0 };
<<<<<<< HEAD
ccv_dpm_new_param_t params = {
.components = 0,
.detector = detector,
Expand All @@ -91,6 +118,25 @@ int main(int argc, char** argv)
.grayscale = 0,
.discard_estimating_constant = 1,
};
=======
ccv_dpm_new_param_t params = { .components = 0,
.detector = detector,
.parts = 0,
.min_area = 3000,
.max_area = 5000,
.symmetric = 1,
.alpha = 0.1,
.balance = 1.75,
.alpha_ratio = 0.9,
.iterations = 20,
.relabels = 5,
.negative_cache_size = 500,
.C = 0.002,
.percentile_breakdown = 0.05,
.include_overlap = 0.7,
.exclude_overlap = 0.1,
.grayscale = 0 };
>>>>>>> added a simple config script
int i, k;
while (getopt_long_only(argc, argv, "", dpm_options, &k) != -1)
{
Expand Down
16 changes: 16 additions & 0 deletions bin/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cd ..\lib
call make

cd /d %~dp0

set CC=gcc
set CXXFLAGS=-mno-cygwin -O3 -msse2 -Wall -std=c99 -fms-extensions -pedantic -I"../lib"
set LDFLAGS= -L"../lib" -lccv -ljpeg -lpng -lz -lm -I"../lib" -msse2

del *.exe
del *.o

%CC% siftmatch.c -o siftmatch.o -c %CXXFLAGS%
%CC% -o siftmatch.exe siftmatch.o %LDFLAGS%

siftmatch.exe ..\samples\scene.png ..\samples\book.png
6 changes: 6 additions & 0 deletions bin/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<<<<<<< HEAD
include ../lib/config.mk
=======
CC = `cat ../lib/.cc.conf`
LDFLAGS = -L"../lib" -lccv `cat ../lib/.l.conf` -lm
CFLAGS = -O3 -Wall -I"../lib" `cat ../lib/.def.conf`
>>>>>>> added a simple config script

#CC += -faddress-sanitizer -fno-omit-frame-pointer
LDFLAGS := -L"../lib" -lccv $(LDFLAGS)
Expand Down
5 changes: 5 additions & 0 deletions lib/3rdparty/sha1/sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

/* this is only to get definitions for memcpy(), ntohl() and htonl() */
#include <string.h>
#include <stdint.h>
#ifdef WIN32
#include <winsock.h>
#else
#include <arpa/inet.h>
#endif

#include "sha1.h"

Expand Down
4 changes: 4 additions & 0 deletions lib/3rdparty/sha1/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* This was initially based on the Mozilla SHA1 implementation, although
* none of the original Mozilla code remains.
*/
#ifndef GUARD_sha1_h
#define GUARD_sha1_h

typedef struct {
unsigned long long size;
Expand All @@ -20,3 +22,5 @@ void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
#define git_SHA1_Init blk_SHA1_Init
#define git_SHA1_Update blk_SHA1_Update
#define git_SHA1_Final blk_SHA1_Final

#endif
76 changes: 76 additions & 0 deletions lib/Makefile.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
CC = gcc
# CFLAGS = -Wall -D HAVE_LIBJPEG -D HAVE_CBLAS -D HAVE_GSL -D HAVE_LIBPNG -D HAVE_FFTW3
DEFINES = -DWIN32 -D HAVE_LIBJPEG -D HAVE_LIBPNG
LIBFILES = -lws2_32 -ljpeg -lpng
INCLUDES =
OPTIMIZE = -O3 -msse2 -Wall -fms-extensions -mms-bitfields

CFLAGS = $(INCLUDES) $(DEFINES) $(OPTIMIZE)
LINK32 = g++
LIB32 = ar rc
#AR = ar
LD = g++.exe
#RM_F = rm -f
RM_F = del

SO = dll
_EXE = .exe
o = .o
a = .a

LDFLAGS=$(LIBFILES) -Wl,--output-def,ccv.def,--out-lib,libccv.a

# Handy lists of source code files:
C_FILES = ccv_algebra.c \
ccv_basic.c \
ccv_bbf.c \
ccv_cache.c \
ccv_daisy.c \
ccv_dpm.c \
ccv_io.c \
io/_ccv_io_binary.c \
io/_ccv_io_bmp.c \
io/_ccv_io_libpng.c \
io/_ccv_io_libjpeg.c \
ccv_memory.c \
ccv_numeric.c \
ccv_sift.c \
ccv_sparse_coding.c \
ccv_swt.c \
ccv_util.c \
3rdparty/sha1.c

O_FILES = ccv_algebra.o \
ccv_basic.o \
ccv_bbf.o \
ccv_cache.o \
ccv_daisy.o \
ccv_dpm.o \
ccv_io.o \
ccv_memory.o \
ccv_numeric.o \
ccv_sift.o \
ccv_sparse_coding.o \
ccv_swt.o \
ccv_util.o \
3rdparty/sha1.o

H_FILES = ccv.h 3rdparty/sha1.h

all: libccv.a

clean:
$(RM_F) *.o 3rdparty/*.o libccv.a

libccv.a: $(O_FILES)
$(AR) rcs $@ $<

ccv.$(SO): libccv.a
gcc -shared -o ccv.$(SO) $(O_FILES) $(LDFLAGS)

.c$(o):
$(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS) -o$@ $<

$(o).dll:
$(LINK32) -o $@ $(BLINK_FLAGS) $< $(LIBFILES)
$(IMPLIB) --input-def $(*B).def --output-lib $(*B).a $@
92 changes: 92 additions & 0 deletions lib/ccv.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
EXPORTS
_ccv_filter_direct_8u @1
_ccv_flip_x_self @2
_ccv_flip_y_self @3
_ccv_get_sparse_prime @4 DATA
_ccv_indice_double_sort @5
_ccv_indice_float_sort @6
_ccv_indice_int_sort @7
_ccv_indice_uchar_sort @8
_ccv_sort_32f @9
_ccv_sort_letters @10
_ccv_swt_connected_component @11
blk_SHA1_Final @12
blk_SHA1_Init @13
blk_SHA1_Update @14
ccv_array_clear @15
ccv_array_free @16
ccv_array_group @17
ccv_array_new @18
ccv_array_push @19
ccv_array_zero @20
ccv_bbf_classifier_cascade_free @21
ccv_bbf_classifier_cascade_new @22
ccv_bbf_classifier_cascade_read_binary @23
ccv_bbf_classifier_cascade_write_binary @24
ccv_bbf_detect_objects @25
ccv_blur @26
ccv_cache_cleanup @27
ccv_cache_close @28
ccv_cache_delete @29
ccv_cache_get @30
ccv_cache_init @31
ccv_cache_out @32
ccv_cache_put @33
ccv_canny @34
ccv_compress_sparse_matrix @35
ccv_contour_free @36
ccv_contour_new @37
ccv_contour_push @38
ccv_daisy @39
ccv_decompress_sparse_matrix @40
ccv_dense_matrix @41
ccv_dense_matrix_new @42
ccv_dense_matrix_renew @43
ccv_disable_cache @44
ccv_dpm_classifier_lsvm_new @45
ccv_dpm_detect_objects @46
ccv_drain_cache @47
ccv_eigen @48
ccv_enable_cache @49
ccv_enable_default_cache @50
ccv_filter @51
ccv_filter_kernel @52
ccv_flip @53
ccv_gemm @54
ccv_get_dense_matrix @55
ccv_get_sparse_matrix @56
ccv_get_sparse_matrix_cell @57
ccv_get_sparse_matrix_vector @58
ccv_gradient @59
ccv_hog @60
ccv_invert @61
ccv_load_bbf_classifier_cascade @62
ccv_load_dpm_root_classifier @63
ccv_matrix_eq @64
ccv_matrix_free @65
ccv_matrix_free_immediately @66
ccv_matrix_generate_signature @67
ccv_minimize @68
ccv_move @69
ccv_norm @70
ccv_normalize @71
ccv_otsu @72
ccv_resample @73
ccv_sample_down @74
ccv_sample_up @75
ccv_serialize @76
ccv_set_sparse_matrix_cell @77
ccv_shift @78
ccv_sift @79
ccv_slice @80
ccv_sobel @81
ccv_solve @82
ccv_sparse_coding @83
ccv_sparse_matrix_new @84
ccv_substract @85
ccv_sum @86
ccv_swt @87
ccv_swt_detect_words @88
ccv_trace @89
ccv_unserialize @90
ccv_zero @91
Binary file added lib/ccv.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions lib/ccv.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#ifndef GUARD_ccv_h
#define GUARD_ccv_h

#ifndef _MSC_VER
#include <unistd.h>
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
Expand All @@ -18,7 +20,11 @@
#include <xmmintrin.h>
#endif
#include <assert.h>
#ifdef _WIN32
#include <malloc.h>
#else
#include <alloca.h>
#endif

#define CCV_PI (3.141592653589793)
#define ccmalloc malloc
Expand Down
1 change: 1 addition & 0 deletions lib/ccv_bbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#endif
#include <sys/time.h>
#ifdef USE_OPENMP
#include <omp.h>
#endif
Expand Down
Loading