camellia 2.7.0-x86-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. data/CamelliaLib-2.7.0.tar.gz +0 -0
  2. data/README +59 -0
  3. data/doc/README +58 -0
  4. data/doc/camellia.dox +205 -0
  5. data/doc/html/annotated.html +52 -0
  6. data/doc/html/camellia_8h-source.html +1618 -0
  7. data/doc/html/camellia_8h.html +4583 -0
  8. data/doc/html/doxygen.css +358 -0
  9. data/doc/html/doxygen.png +0 -0
  10. data/doc/html/files.html +29 -0
  11. data/doc/html/ftv2blank.png +0 -0
  12. data/doc/html/ftv2doc.png +0 -0
  13. data/doc/html/ftv2folderclosed.png +0 -0
  14. data/doc/html/ftv2folderopen.png +0 -0
  15. data/doc/html/ftv2lastnode.png +0 -0
  16. data/doc/html/ftv2link.png +0 -0
  17. data/doc/html/ftv2mlastnode.png +0 -0
  18. data/doc/html/ftv2mnode.png +0 -0
  19. data/doc/html/ftv2node.png +0 -0
  20. data/doc/html/ftv2plastnode.png +0 -0
  21. data/doc/html/ftv2pnode.png +0 -0
  22. data/doc/html/ftv2vertline.png +0 -0
  23. data/doc/html/functions.html +108 -0
  24. data/doc/html/functions_0x62.html +78 -0
  25. data/doc/html/functions_0x63.html +112 -0
  26. data/doc/html/functions_0x64.html +113 -0
  27. data/doc/html/functions_0x65.html +102 -0
  28. data/doc/html/functions_0x66.html +82 -0
  29. data/doc/html/functions_0x67.html +76 -0
  30. data/doc/html/functions_0x68.html +88 -0
  31. data/doc/html/functions_0x69.html +90 -0
  32. data/doc/html/functions_0x6b.html +70 -0
  33. data/doc/html/functions_0x6c.html +88 -0
  34. data/doc/html/functions_0x6d.html +93 -0
  35. data/doc/html/functions_0x6e.html +79 -0
  36. data/doc/html/functions_0x6f.html +74 -0
  37. data/doc/html/functions_0x70.html +72 -0
  38. data/doc/html/functions_0x72.html +73 -0
  39. data/doc/html/functions_0x73.html +130 -0
  40. data/doc/html/functions_0x74.html +82 -0
  41. data/doc/html/functions_0x76.html +74 -0
  42. data/doc/html/functions_0x77.html +75 -0
  43. data/doc/html/functions_0x78.html +72 -0
  44. data/doc/html/functions_0x79.html +77 -0
  45. data/doc/html/functions_0x7e.html +76 -0
  46. data/doc/html/functions_func.html +93 -0
  47. data/doc/html/functions_func_0x62.html +64 -0
  48. data/doc/html/functions_func_0x63.html +83 -0
  49. data/doc/html/functions_func_0x64.html +99 -0
  50. data/doc/html/functions_func_0x65.html +95 -0
  51. data/doc/html/functions_func_0x66.html +74 -0
  52. data/doc/html/functions_func_0x67.html +72 -0
  53. data/doc/html/functions_func_0x68.html +76 -0
  54. data/doc/html/functions_func_0x69.html +70 -0
  55. data/doc/html/functions_func_0x6c.html +76 -0
  56. data/doc/html/functions_func_0x6d.html +78 -0
  57. data/doc/html/functions_func_0x6f.html +65 -0
  58. data/doc/html/functions_func_0x70.html +64 -0
  59. data/doc/html/functions_func_0x72.html +65 -0
  60. data/doc/html/functions_func_0x73.html +113 -0
  61. data/doc/html/functions_func_0x74.html +74 -0
  62. data/doc/html/functions_func_0x76.html +64 -0
  63. data/doc/html/functions_func_0x77.html +64 -0
  64. data/doc/html/functions_func_0x7e.html +72 -0
  65. data/doc/html/functions_vars.html +290 -0
  66. data/doc/html/globals.html +368 -0
  67. data/doc/html/globals_defs.html +41 -0
  68. data/doc/html/globals_func.html +364 -0
  69. data/doc/html/index.html +11 -0
  70. data/doc/html/main.html +22 -0
  71. data/doc/html/pages.html +24 -0
  72. data/doc/html/structCamAffineTransform.html +37 -0
  73. data/doc/html/structCamArithmParams.html +60 -0
  74. data/doc/html/structCamBasin.html +62 -0
  75. data/doc/html/structCamBitmapFont.html +37 -0
  76. data/doc/html/structCamBlobInfo.html +90 -0
  77. data/doc/html/structCamBlobs.html +51 -0
  78. data/doc/html/structCamImage.html +853 -0
  79. data/doc/html/structCamKeypoint.html +79 -0
  80. data/doc/html/structCamKeypoints.html +99 -0
  81. data/doc/html/structCamKeypointsKdTree.html +42 -0
  82. data/doc/html/structCamKeypointsMatches.html +54 -0
  83. data/doc/html/structCamLabelingResults.html +46 -0
  84. data/doc/html/structCamLinearFilterKernel.html +63 -0
  85. data/doc/html/structCamMeasuresResults.html +54 -0
  86. data/doc/html/structCamMorphoMathsKernel.html +81 -0
  87. data/doc/html/structCamPoint.html +46 -0
  88. data/doc/html/structCamRLEImage.html +183 -0
  89. data/doc/html/structCamROI.html +80 -0
  90. data/doc/html/structCamRun.html +56 -0
  91. data/doc/html/structCamSepFilterKernel.html +67 -0
  92. data/doc/html/structCamTable.html +46 -0
  93. data/doc/html/structCamTableOfBasins.html +37 -0
  94. data/doc/html/structCamVolbergFwdParams.html +46 -0
  95. data/doc/html/structCamWarpingParams.html +70 -0
  96. data/doc/html/tab_b.gif +0 -0
  97. data/doc/html/tab_l.gif +0 -0
  98. data/doc/html/tab_r.gif +0 -0
  99. data/doc/html/tabs.css +102 -0
  100. data/doc/html/todo.html +29 -0
  101. data/doc/html/tree.html +106 -0
  102. data/doc/rtf/refman.rtf +7866 -0
  103. data/ext/Makefile +149 -0
  104. data/ext/README +12 -0
  105. data/ext/camellia_ruby.i +493 -0
  106. data/ext/camellia_ruby_wrap.cxx +21103 -0
  107. data/ext/extconf.rb +12 -0
  108. data/ext/install.rb +11 -0
  109. data/ext/swig_ruby.dsp +159 -0
  110. data/ext/swig_ruby.vcproj +290 -0
  111. data/ext/test.rb +31 -0
  112. data/inc/SHLWAPI.H +661 -0
  113. data/inc/cam_capture.h +202 -0
  114. data/inc/camellia.h +2651 -0
  115. data/inc/camellia_internals.h +205 -0
  116. data/inc/config.h +62 -0
  117. data/inc/config.h.in +61 -0
  118. data/inc/stamp-h1 +1 -0
  119. data/lib/camellia-fox.rb +39 -0
  120. data/test/test_arithm.rb +13 -0
  121. data/test/test_capture.rb +15 -0
  122. data/test/test_color_labeling.rb +45 -0
  123. data/test/test_copy.rb +13 -0
  124. data/test/test_draw.rb +15 -0
  125. data/test/test_fixed_filters.rb +23 -0
  126. data/test/test_fox.rb +106 -0
  127. data/test/test_fox2.rb +108 -0
  128. data/test/test_histogram.rb +18 -0
  129. data/test/test_hough.rb +29 -0
  130. data/test/test_keypoints.rb +106 -0
  131. data/test/test_labeling.rb +30 -0
  132. data/test/test_mask.rb +34 -0
  133. data/test/test_warping.rb +46 -0
  134. data/test/test_watershed.rb +35 -0
  135. data/test/ts_camellia.rb +12 -0
  136. metadata +204 -0
@@ -0,0 +1,149 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = .
7
+ topdir = /usr/local/lib/ruby/1.8/i686-linux
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ prefix = $(DESTDIR)/usr/local
11
+ exec_prefix = $(prefix)
12
+ sitedir = $(prefix)/lib/ruby/site_ruby
13
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
14
+ docdir = $(datarootdir)/doc/$(PACKAGE)
15
+ dvidir = $(docdir)
16
+ datarootdir = $(prefix)/share
17
+ archdir = $(rubylibdir)/$(arch)
18
+ sbindir = $(exec_prefix)/sbin
19
+ psdir = $(docdir)
20
+ localedir = $(datarootdir)/locale
21
+ htmldir = $(docdir)
22
+ datadir = $(datarootdir)
23
+ includedir = $(prefix)/include
24
+ infodir = $(datarootdir)/info
25
+ sysconfdir = $(prefix)/etc
26
+ mandir = $(datarootdir)/man
27
+ libdir = $(exec_prefix)/lib
28
+ sharedstatedir = $(prefix)/com
29
+ oldincludedir = $(DESTDIR)/usr/include
30
+ pdfdir = $(docdir)
31
+ sitearchdir = $(sitelibdir)/$(sitearch)
32
+ bindir = $(exec_prefix)/bin
33
+ localstatedir = $(prefix)/var
34
+ sitelibdir = $(sitedir)/$(ruby_version)
35
+ libexecdir = $(exec_prefix)/libexec
36
+
37
+ CC = gcc
38
+ LIBRUBY = $(LIBRUBY_A)
39
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
+ LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -L.
41
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
42
+
43
+ RUBY_EXTCONF_H =
44
+ CFLAGS = -fPIC -g -O2
45
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
46
+ CPPFLAGS =
47
+ CXXFLAGS = $(CFLAGS)
48
+ DLDFLAGS = -rdynamic -Wl,-export-dynamic
49
+ LDSHARED = g++ -shared -lCamellia
50
+ AR = ar
51
+ EXEEXT =
52
+
53
+ RUBY_INSTALL_NAME = ruby
54
+ RUBY_SO_NAME = ruby
55
+ arch = i686-linux
56
+ sitearch = i686-linux
57
+ ruby_version = 1.8
58
+ ruby = /usr/local/bin/ruby
59
+ RUBY = $(ruby)
60
+ RM = rm -f
61
+ MAKEDIRS = mkdir -p
62
+ INSTALL = /usr/bin/install -c
63
+ INSTALL_PROG = $(INSTALL) -m 0755
64
+ INSTALL_DATA = $(INSTALL) -m 644
65
+ COPY = cp
66
+
67
+ #### End of system configuration section. ####
68
+
69
+ preload =
70
+
71
+ libpath = $(libdir)
72
+ LIBPATH = -L'$(libdir)' -Wl,-R'$(libdir)'
73
+ DEFFILE =
74
+
75
+ CLEANFILES =
76
+ DISTCLEANFILES =
77
+
78
+ extout =
79
+ extout_prefix =
80
+ target_prefix =
81
+ LOCAL_LIBS =
82
+ LIBS = -ldl -lcrypt -lm -lc
83
+ SRCS = camellia_ruby_wrap.cxx
84
+ OBJS = camellia_ruby_wrap.o
85
+ TARGET = camellia
86
+ DLLIB = $(TARGET).so
87
+ EXTSTATIC =
88
+ STATIC_LIB =
89
+
90
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
91
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
92
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
93
+
94
+ TARGET_SO = $(DLLIB)
95
+ CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
96
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
97
+
98
+ all: $(DLLIB)
99
+ static: $(STATIC_LIB)
100
+
101
+ clean:
102
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
103
+
104
+ distclean: clean
105
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
106
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
107
+
108
+ realclean: distclean
109
+ install: install-so install-rb
110
+
111
+ install-so: $(RUBYARCHDIR)
112
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
113
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
114
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
115
+ install-rb: pre-install-rb install-rb-default
116
+ install-rb-default: pre-install-rb-default
117
+ pre-install-rb: Makefile
118
+ pre-install-rb-default: Makefile
119
+ $(RUBYARCHDIR):
120
+ $(MAKEDIRS) $@
121
+
122
+ site-install: site-install-so site-install-rb
123
+ site-install-so: install-so
124
+ site-install-rb: install-rb
125
+
126
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
127
+
128
+ .cc.o:
129
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
130
+
131
+ .cxx.o:
132
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
133
+
134
+ .cpp.o:
135
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
136
+
137
+ .C.o:
138
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
139
+
140
+ .c.o:
141
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
142
+
143
+ $(DLLIB): $(OBJS)
144
+ @-$(RM) $@
145
+ $(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
146
+
147
+
148
+
149
+ $(OBJS): ruby.h defines.h
@@ -0,0 +1,12 @@
1
+ # How to build the Ruby wrapper for Camellia
2
+
3
+ cd ..
4
+ make dist
5
+ cd ext
6
+ swig -ruby -c++ camellia_ruby.i
7
+ ruby extconf.rb
8
+ make clean
9
+ make
10
+ cp camellia.so ../lib
11
+ sudo make install
12
+ sudo ruby install.rb
@@ -0,0 +1,493 @@
1
+ /* File : camellia_ruby.i */
2
+ %module camellia
3
+
4
+ %{
5
+ #include "../inc/camellia.h"
6
+ extern "C" void Init_camcapture();
7
+ %}
8
+
9
+ %include "cstring.i"
10
+
11
+ // Ruby object tracking
12
+ %trackobjects;
13
+ %feature("trackobjects","0") CamBasin;
14
+
15
+ // Bash
16
+ %rename("dealloc!") CamImage::dealloc();
17
+
18
+ %rename("erode_square3!") CamImage::erode_square3();
19
+ %rename("erode_circle5!") CamImage::erode_circle5();
20
+ %rename("erode_circle7!") CamImage::erode_circle7();
21
+ %rename("dilate_square3!") CamImage::dilate_square3();
22
+ %rename("dilate_circle5!") CamImage::dilate_circle5();
23
+ %rename("dilate_circle7!") CamImage::dilate_circle7();
24
+ %rename("morpho_gradient_square3!") CamImage::morpho_gradient_square3();
25
+ %rename("morpho_gradient_circle5!") CamImage::morpho_gradient_circle5();
26
+ %rename("morpho_gradient_circle7!") CamImage::morpho_gradient_circle7();
27
+ %rename("morpho_maths!") CamImage::morpho_maths(const CamMorphoMathsKernel &ker);
28
+ %rename("erode_3x3!") CamImage::erode_3x3(const CamMorphoMathsKernel &ker);
29
+ %rename("dilate_3x3!") CamImage::dilate_3x3(const CamMorphoMathsKernel &ker);
30
+ %rename("erode_5x5!") CamImage::erode_5x5(const CamMorphoMathsKernel &ker);
31
+ %rename("dilate_5x5!") CamImage::dilate_5x5(const CamMorphoMathsKernel &ker);
32
+ %rename("erode_7x7!") CamImage::erode_7x7(const CamMorphoMathsKernel &ker);
33
+ %rename("dilate_7x7!") CamImage::dilate_7x7(const CamMorphoMathsKernel &ker);
34
+ %rename("threshold!") CamImage::threshold(int threshold);
35
+ %rename("threshold_inv!") CamImage::threshold_inv(int threshold);
36
+ %rename("abs!") CamImage::abs();
37
+ %rename("set!") CamImage::set(int color);
38
+
39
+ %rename("linear_filter_3x3!") CamImage::linear_filter_3x3(const CamLinearFilterKernel &ker);
40
+ %rename("linear_filter_5x5!") CamImage::linear_filter_5x5(const CamLinearFilterKernel &ker);
41
+ %rename("linear_filter_abs_3x3!") CamImage::linear_filter_abs_3x3(const CamLinearFilterKernel &ker);
42
+ %rename("linear_filter_abs_5x5!") CamImage::linear_filter_abs_5x5(const CamLinearFilterKernel &ker);
43
+ %rename("sep_filter_3x3!") CamImage::sep_filter_3x3(const CamSepFilterKernel &ker);
44
+ %rename("sep_filter_5x5!") CamImage::sep_filter_5x5(const CamSepFilterKernel &ker);
45
+ %rename("sep_filter_7x7!") CamImage::sep_filter_7x7(const CamSepFilterKernel &ker);
46
+ %rename("sep_filter_abs_3x3!") CamImage::sep_filter_abs_3x3(const CamSepFilterKernel &ker);
47
+ %rename("sep_filter_abs_5x5!") CamImage::sep_filter_abs_5x5(const CamSepFilterKernel &ker);
48
+ %rename("sep_filter_abs_7x7!") CamImage::sep_filter_abs_7x7(const CamSepFilterKernel &ker);
49
+ %rename("sobel_v!") CamImage::sobel_v();
50
+ %rename("sobel_h!") CamImage::sobel_h();
51
+ %rename("sobel_v_abs!") CamImage::sobel_v_abs();
52
+ %rename("sobel_h_abs!") CamImage::sobel_h_abs();
53
+ %rename("fixed_filter!") CamImage::fixed_filter(int filter);
54
+ %rename("hierarchical_watershed_regions!") CamImage::hierarchical_watershed_regions(const CamTableOfBasins &tob);
55
+
56
+ %rename("arithm!") CamImage::arithm(int operation, int c1=0, int c2=0, int c3=0);
57
+ %rename("draw_keypoints!") CamImage::draw_keypoints(const CamKeypoints &points, int color = 255);
58
+ %rename("draw_keypoint!") CamImage::draw_keypoint(const CamKeypoints &points, int color = 255);
59
+
60
+ %rename("apply_lut!") CamImage::apply_lut(const CamTable &LUT);
61
+ %rename("apply_lut!") CamRLEImage::apply_lut(const CamTable &LUT);
62
+
63
+ %rename("inverse!") CamRLEImage::inverse();
64
+ %rename("labeling!") CamRLEImage::labeling();
65
+ %rename("labeling!") CamRLEImage::labeling(CamBlobs &results);
66
+
67
+ // Predicates
68
+ %rename("allocated?") CamImage::allocated() const;
69
+
70
+ // Other renaming
71
+ %rename("cam_rgb") camRGB(int r, int g, int b);
72
+ %rename("cam_rgba") camRGBA(int r, int g, int b);
73
+ %rename("cam_set_viewer") camSetImageViewer;
74
+ %rename("nb_runs") CamRLEImage::nbRuns;
75
+ %rename("nb_blobs") CamBlobs::nbBlobs;
76
+ %rename("nb_matches") CamKeypointsMatches::nbMatches;
77
+ %rename("nb_outliers") CamKeypointsMatches::nbOutliers;
78
+ %rename("nb_points") CamKeypoints::nbPoints;
79
+
80
+ // Aliases
81
+ %alias CamRLEImage::labeling "labelling!";
82
+ %alias CamImage::set_mask "mask=";
83
+ %alias CamImage::copy "copy_to";
84
+ %alias CamImage::set "fill_with";
85
+ %alias CamImage::to_y "to_grey";
86
+ %alias CamKeypoint::set_descriptor "descriptor=";
87
+
88
+ // Ruby idioms
89
+ %alias CamImage::get_pixels "to_s";
90
+ %alias CamImage::clone "dup";
91
+
92
+ %newobject CamImage::clone;
93
+ %newobject CamImage::encode;
94
+ %newobject CamImage::encode_threshold;
95
+ %newobject CamImage::encode_threshold_inv;
96
+ %newobject CamImage::encode_threshold_lut;
97
+ %newobject CamImage::labeling;
98
+ %newobject CamImage::to_yuv;
99
+ %newobject CamImage::to_y;
100
+ %newobject CamImage::to_rgb;
101
+ %newobject CamImage::to_hls;
102
+ %newobject CamImage::integral_image;
103
+ %newobject CamRLEImage::erode_cross;
104
+ %newobject CamRLEImage::erode_3x3;
105
+ %newobject CamRLEImage::erode_3x2;
106
+
107
+ // Garbage collection
108
+ %markfunc CamImage "mark_CamImage";
109
+ %markfunc CamKeypointsMatch "mark_CamKeypointsMatch";
110
+ %markfunc CamKeypointsMatches "mark_CamKeypointsMatches";
111
+ %markfunc CamKeypoints "mark_CamKeypoints";
112
+ %markfunc CamKeypoint "mark_CamKeypoint";
113
+
114
+ // Typemaps
115
+
116
+ // Correct string allocation for to_s
117
+ %cstring_output_allocate_size(char **result, int *len, delete[](*$1));
118
+
119
+ %include "typemaps.i"
120
+ %apply int *OUTPUT { int &xc };
121
+ %apply int *OUTPUT { int &yc };
122
+ %apply int *OUTPUT { int &rc };
123
+ %apply int *OUTPUT { int *dist1 };
124
+ %apply int *OUTPUT { int *dist2 };
125
+ %apply int *OUTPUT { int *error };
126
+
127
+ %typemap(in) (const char *pixels, int sz)
128
+ {
129
+ $1=STR2CSTR($input);
130
+ $2=(int)RSTRING($input)->len;
131
+ }
132
+
133
+ %typemap(in) (const int* const array, int sz)
134
+ {
135
+ Check_Type($input, T_ARRAY);
136
+ $2=RARRAY($input)->len;
137
+ if ($2) {
138
+ $1=new int[$2];
139
+ for (int i=0;i!=$2;i++) {
140
+ VALUE inst = rb_ary_entry($input, i);
141
+ $1[i]=NUM2INT(inst);
142
+ }
143
+ } else {
144
+ $1=NULL;
145
+ }
146
+ }
147
+
148
+ %typemap(freearg) (const int* const array, int sz)
149
+ {
150
+ if ($1) delete[] $1;
151
+ }
152
+
153
+ %typemap(in) (const CamKeypoints **models, int nbModels)
154
+ {
155
+ Check_Type($input, T_ARRAY);
156
+ $2=RARRAY($input)->len;
157
+ if ($2) {
158
+ $1=new CamKeypoints*[$2];
159
+ for (int i=0;i!=$2;i++) {
160
+ VALUE inst = rb_ary_entry($input, i);
161
+ void *argp;
162
+ int res = SWIG_ConvertPtr(inst, &argp, SWIGTYPE_p_CamKeypoints, 0 );
163
+ if (!SWIG_IsOK(res)) {
164
+ SWIG_exception_fail(SWIG_ArgError(res), "Array of CamKeypoints expected");
165
+ }
166
+ $1[i]=reinterpret_cast< CamKeypoints * >(argp);
167
+ }
168
+ } else {
169
+ $1=NULL;
170
+ }
171
+ }
172
+
173
+ %typemap(freearg) (const CamKeypoints **models, int nbModels)
174
+ {
175
+ if ($1) delete[] $1;
176
+ }
177
+
178
+ %typemap(out) double [ANY]
179
+ {
180
+ VALUE arr = rb_ary_new2($1_dim0);
181
+ for (int i = 0; i < $1_dim0; i++) {
182
+ rb_ary_push(arr, rb_float_new($1[i]));
183
+ }
184
+ $result = arr;
185
+ }
186
+
187
+ %typemap(out) int [ANY]
188
+ {
189
+ VALUE arr = rb_ary_new2($1_dim0);
190
+ for (int i = 0; i < $1_dim0; i++) {
191
+ rb_ary_push(arr, INT2FIX($1[i]));
192
+ }
193
+ $result = arr;
194
+ }
195
+
196
+ // Include header
197
+
198
+ %rename(CamCapture2) CamCapture;
199
+ %include "../inc/camellia.h"
200
+
201
+ // Additional definitions
202
+
203
+ #define CAM_COLORMODEL_GREY 0
204
+ #define CAM_COLORMODEL_RGB 1
205
+ #define CAM_COLORMODEL_RGBA 2
206
+ #define CAM_COLORMODEL_YUV 3
207
+ #define CAM_CHANNELSEQ_GREY 0
208
+ #define CAM_CHANNELSEQ_RGB 1
209
+ #define CAM_CHANNELSEQ_RGBA 2
210
+ #define CAM_CHANNELSEQ_YUV 3
211
+ #define CAM_CHANNELSEQ_BGR 4
212
+ #define CAM_CHANNELSEQ_BGRA 5
213
+
214
+ %mixin CamTable "Enumerable";
215
+
216
+ struct CamTable {
217
+ int size; ///< Number of valid entries
218
+ CamTable(int s=0);
219
+ bool set(const int* const array, int sz);
220
+ };
221
+
222
+ %extend CamTable {
223
+ int __getitem__(int n) {
224
+ if ((n>=0)&&(n<self->size)&&(n<CAM_TABLE_SIZE)) return self->t[n];
225
+ else camError("CamTable","Index out of range");
226
+ return self->t[0];
227
+ };
228
+ void __setitem__(int n, int val) {
229
+ if ((n>=0)&&(n<self->size)&&(n<CAM_TABLE_SIZE)) self->t[n]=val;
230
+ else camError("CamTable","Index out of range");
231
+ };
232
+ void each() {
233
+ for (int i=0;i<self->size;i++) {
234
+ VALUE obj = INT2FIX(self->t[i]);
235
+ if (obj != Qnil) {
236
+ rb_yield(obj);
237
+ }
238
+ }
239
+ };
240
+ };
241
+
242
+ %mutable;
243
+ struct CamRLEImage {
244
+ int id; ///< Frame id (user dependent)
245
+ %immutable;
246
+ int height; ///< Image height
247
+ int width; ///< Image width
248
+ int nbRuns; ///< The number of runs
249
+ int allocated; ///< Number of runs allocated
250
+ %mutable;
251
+
252
+ CamRLEImage(); ///< Default constructor
253
+ CamRLEImage(int nbruns); ///< Constructor with max number of runs parameter
254
+ CamRLEImage(const CamRLEImage &image); ///< Copy constructor
255
+ ~CamRLEImage(); ///< Default destructor
256
+
257
+ CamRLEImage* clone() const; ///< Clone RLE image (using CamRLEClone() function)
258
+ bool alloc(int nbruns); ///< Allocator (C++ wrapping of CamRLEAllocate() function)
259
+ bool realloc(int nbruns); ///< Reallocator (C++ wrapping of CamRLEReallocate() function)
260
+
261
+ bool encode(const CamImage &image); ///< C++ wrapping for CamRLEEncode() function
262
+ bool encode_lut(const CamImage &image, const CamTable &LUT); ///< C++ wrapping for CamRLEEncodeLUT() function
263
+ bool encode_threshold(const CamImage &image, int threshold); ///< C++ wrapping for CamRLEEncodeThreshold() function
264
+ bool encode_threshold_inv(const CamImage &image, int threshold);///< C++ wrapping for CamRLEEncodeThresholdInv() function
265
+ bool encode_color(const CamImage &image, const CamTable &clusters); ///< C++ wrapping for camCamRLEEncodeColor() function
266
+ CamBlobs* labeling(); ///< C++ wrapping for CamRLELabeling() function
267
+ bool labeling(CamBlobs &results); ///< C++ wrapping for CamRLELabeling() function
268
+ bool blob_analysis(CamBlobs &results) const; ///< C++ wrapping for CamRLEBlobAnalysis() function
269
+ bool apply_lut(const CamTable &LUT); ///< C++ wrapping for CamRLEApplyLUT() function
270
+ bool apply_lut(CamRLEImage &dest, const CamTable &LUT) const; ///< C++ wrapping for CamRLEApplyLUT() function
271
+ bool decode(CamImage &dest) const; ///< C++ wrapping for CamRLEDecode() function
272
+ bool decode(CamImage &dest, const CamTable &LUT) const; ///< C++ wrapping for CamRLEDecode() function
273
+ bool decode_blobs(CamImage &dest) const; ///< C++ wrapping for CamRLEDecodeBlobs() function
274
+ bool decode_blobs(CamImage &dest, const CamTable &LUT) const; ///< C++ wrapping for CamRLEDecodeBlos() function
275
+ bool inverse(); ///< C++ wrapping for CamRLEInverse() function
276
+ bool erode_cross(CamRLEImage &dest) const; ///< C++ wrapping for CamRLEErodeCross() function
277
+ CamRLEImage *erode_cross() const; ///< C++ wrapping for CamRLEErodeCross() function
278
+ bool erode_3x3(CamRLEImage &dest) const; ///< C++ wrapping for CamRLEErode3x3() function
279
+ CamRLEImage *erode_3x3() const; ///< C++ wrapping for CamRLEErode3x3() function
280
+ bool erode_3x2(CamRLEImage &dest) const; ///< C++ wrapping for CamRLEErode3x2() function
281
+ CamRLEImage *erode_3x2() const; ///< C++ wrapping for CamRLEErode3x2() function
282
+ };
283
+
284
+ %immutable;
285
+ typedef struct {
286
+ int id;
287
+ int left; ///< Leftmost coordinate of the blob
288
+ int top; ///< Topmost coordinate of the blob
289
+ int width; ///< Width of the blob
290
+ int height; ///< Height of the blob
291
+ int surface; ///< Number of pixels covered by this blob
292
+ int cx; ///< Center of gravity (x)
293
+ int cy; ///< Center of gravity (y)
294
+ int value; ///< Blob value, or average pixel value in the original image
295
+ int min; ///< Minimum pixel value in the original image
296
+ int max; ///< Maximum pixel value in the original image
297
+ void *misc; ///< Additional user-dependant blob information
298
+ } CamBlobInfo;
299
+
300
+ %mixin CamBlobs "Enumerable";
301
+
302
+ struct CamBlobs {
303
+ int nbBlobs; ///< Number of valid blobs
304
+ CamBlobs() {nbBlobs=0;} ///< Default constructor
305
+ };
306
+
307
+ %extend CamBlobs {
308
+ CamBlobInfo __getitem__(int n) {
309
+ if ((n>=0)&&(n<self->nbBlobs)) return self->blobInfo[n];
310
+ else camError("CamBlobs","Index out of range");
311
+ return self->blobInfo[0];
312
+ };
313
+ void each() {
314
+ for (int i=0;i<self->nbBlobs;i++) {
315
+ VALUE obj = SWIG_NewPointerObj((new CamBlobInfo(self->blobInfo[i])), SWIGTYPE_p_CamBlobInfo, SWIG_POINTER_OWN);
316
+ if (obj != Qnil) {
317
+ rb_yield(obj);
318
+ }
319
+ }
320
+ };
321
+ };
322
+
323
+ %mixin CamTableOfBasins "Enumerable";
324
+
325
+ struct CamTableOfBasins
326
+ {
327
+ int nbBasins;
328
+ void get_rid_of(CamBasin &basin) {basin.surface=-1;}
329
+ };
330
+
331
+ %extend CamTableOfBasins {
332
+ CamBasin* __getitem__(int n) {
333
+ if ((n >= 0) && (n < self->nbBasins)) return &self->tab[n];
334
+ else camError("CamTableOfBasins","Index out of range");
335
+ return &self->tab[0];
336
+ };
337
+ void each() {
338
+ for (int i = 0;i < self->nbBasins; i++) {
339
+ VALUE obj = SWIG_NewPointerObj(&self->tab[i], SWIGTYPE_p_CamBasin, 0 );
340
+ if (obj != Qnil) {
341
+ rb_yield(obj);
342
+ }
343
+ }
344
+ };
345
+ };
346
+
347
+ %mixin CamKeypoints "Enumerable";
348
+
349
+ %extend CamKeypoints {
350
+ CamKeypoint* __getitem__(int n) {
351
+ if (n >= 0 && n < self->nbPoints) return self->keypoint[n];
352
+ else camError("CamKeypoints","Index out of range");
353
+ return NULL;
354
+ };
355
+ void each() {
356
+ for (int i=0; i < self->nbPoints; i++) {
357
+ VALUE obj = SWIG_NewPointerObj(self->keypoint[i], SWIGTYPE_p_CamKeypoint, 0 );
358
+ if (obj != Qnil) {
359
+ rb_yield(obj);
360
+ }
361
+ }
362
+ };
363
+ };
364
+
365
+ %mixin CamKeypointsMatches "Enumerable";
366
+
367
+ %extend CamKeypointsMatches {
368
+ CamKeypointsMatch* __getitem__(int n) {
369
+ if (n >= 0 && n < self->nbMatches) return &(self->pairs[n]);
370
+ else camError("CamKeypointsMatches","Index out of range");
371
+ return NULL;
372
+ };
373
+ void each() {
374
+ for (int i=0; i < self->nbMatches; i++) {
375
+ VALUE obj = SWIG_NewPointerObj(&(self->pairs[i]), SWIGTYPE_p_CamKeypointsMatch, 0 );
376
+ if (obj != Qnil) {
377
+ rb_yield(obj);
378
+ }
379
+ }
380
+ };
381
+ };
382
+
383
+ %mutable;
384
+
385
+ // Garbage collection implementation (mark & sweep)
386
+ %header %{
387
+ static void mark_CamImage(void *ptr) {
388
+ CamImage *image=(CamImage*)ptr;
389
+ //printf("Marking CamImage %x\n", ptr);
390
+ if (image->roi) {
391
+ VALUE object = SWIG_RubyInstanceFor(image->roi);
392
+ if (object != Qnil) {
393
+ rb_gc_mark(object);
394
+ }
395
+ }
396
+ if (image->mask) {
397
+ VALUE object = SWIG_RubyInstanceFor(image->mask);
398
+ if (object != Qnil) {
399
+ rb_gc_mark(object);
400
+ }
401
+ }
402
+ if (image->imageData !=NULL && image->imageDataOrigin == NULL) {
403
+ // Image references a Ruby string
404
+ rb_gc_mark((VALUE)image->imageId);
405
+ }
406
+ }
407
+
408
+ static void mark_CamKeypoints(void *ptr) {
409
+ int i;
410
+ //printf("Marking keypoints %x\n", ptr);
411
+ CamKeypoints *points = (CamKeypoints*)ptr;
412
+ for (i = 0; i < points->nbPoints; i++) {
413
+ VALUE object = SWIG_RubyInstanceFor(points->keypoint[i]);
414
+ if (object != Qnil) {
415
+ rb_gc_mark(object);
416
+ }
417
+ }
418
+ }
419
+
420
+ static void mark_CamKeypoint(void *ptr) {
421
+ //printf("Marking keypoint %x\n", ptr);
422
+ CamKeypoint *point = (CamKeypoint*)ptr;
423
+ if (point->set) {
424
+ VALUE object = SWIG_RubyInstanceFor(point->set);
425
+ if (object != Qnil) {
426
+ rb_gc_mark(object);
427
+ }
428
+ }
429
+ }
430
+
431
+ static void mark_CamKeypointsMatch(void *ptr) {
432
+ CamKeypointsMatch *match = (CamKeypointsMatch*)ptr;
433
+ //printf("Marking match %x\n", ptr);
434
+ VALUE object = SWIG_RubyInstanceFor(match->p1);
435
+ if (object != Qnil) {
436
+ rb_gc_mark(object);
437
+ }
438
+ object = SWIG_RubyInstanceFor(match->p2);
439
+ if (object != Qnil) {
440
+ rb_gc_mark(object);
441
+ }
442
+ }
443
+
444
+ static void mark_CamKeypointsMatches(void *ptr) {
445
+ int i;
446
+ CamKeypointsMatches *matches = (CamKeypointsMatches*)ptr;
447
+ //printf("Marking matches %x\n", ptr);
448
+ for (i = 0; i < matches->nbMatches; i++) {
449
+ VALUE object = SWIG_RubyInstanceFor(matches->pairs[i].p1);
450
+ if (object != Qnil) {
451
+ rb_gc_mark(object);
452
+ }
453
+ object = SWIG_RubyInstanceFor(matches->pairs[i].p2);
454
+ if (object != Qnil) {
455
+ rb_gc_mark(object);
456
+ }
457
+ }
458
+ }
459
+
460
+ %}
461
+
462
+ // Exception handling
463
+ %header %{
464
+ void camErrorRuby(char *module, char *error)
465
+ {
466
+ rb_raise(rb_eRuntimeError,"Error in %s : %s",module,error);
467
+ }
468
+
469
+ static VALUE camellia_set_image_data(VALUE self, VALUE str)
470
+ {
471
+ VALUE strx;
472
+ CamImage *image;
473
+ void *argp1 = 0 ;
474
+
475
+ SWIG_ConvertPtr(self, &argp1, SWIGTYPE_p_CamImage, 0 | 0 );
476
+ image = reinterpret_cast< CamImage * >(argp1);
477
+ strx = StringValue(str);
478
+ if (image->imageData) {
479
+ camDeallocateImage(image);
480
+ }
481
+ image->imageId = (void*)strx; // Reference to the Ruby string kept for Mark & Sweep
482
+ image->imageData = (unsigned char*)RSTRING(strx)->ptr;
483
+ return self;
484
+ }
485
+ %}
486
+
487
+ // Set ruby error function
488
+ %init %{
489
+ camSetErrorFunct(camErrorRuby);
490
+ rb_define_method(cCamImage.klass, "set_image_data", VALUEFUNC(camellia_set_image_data), 1);
491
+ %}
492
+
493
+