camellia 2.7.0-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/README +59 -0
- data/doc/README +58 -0
- data/doc/camellia.dox +205 -0
- data/ext/Debug/BuildLog.htm +0 -0
- data/ext/Debug/camellia.dll.embed.manifest +1 -0
- data/ext/Debug/vc80.idb +0 -0
- data/ext/Debug/vc80.pdb +0 -0
- data/ext/README +12 -0
- data/ext/Release/BuildLog.htm +0 -0
- data/ext/Release/camellia.exp +0 -0
- data/ext/Release/swig_ruby.pch +0 -0
- data/ext/Release/vc60.idb +0 -0
- data/ext/Release/vc80.idb +0 -0
- data/ext/camellia_ruby.i +493 -0
- data/ext/camellia_ruby_wrap.cpp +21103 -0
- data/ext/camellia_ruby_wrap.cxx +21103 -0
- data/ext/extconf.rb +12 -0
- data/ext/install.rb +11 -0
- data/ext/swig_ruby.dsp +159 -0
- data/ext/swig_ruby.plg +53 -0
- data/ext/swig_ruby.vcproj +290 -0
- data/ext/swig_ruby.vcproj.HAMBURG.Bruno STEUX.user +65 -0
- data/ext/test.rb +31 -0
- data/inc/SHLWAPI.H +661 -0
- data/inc/cam_capture.h +202 -0
- data/inc/camellia.h +2651 -0
- data/inc/camellia_internals.h +205 -0
- data/inc/config.h +59 -0
- data/inc/config.h.in +58 -0
- data/inc/stamp-h1 +1 -0
- data/lib/camellia-fox.rb +39 -0
- data/lib/camellia.dll +0 -0
- data/test/test_arithm.rb +13 -0
- data/test/test_capture.rb +15 -0
- data/test/test_color_labeling.rb +45 -0
- data/test/test_copy.rb +13 -0
- data/test/test_draw.rb +15 -0
- data/test/test_fixed_filters.rb +23 -0
- data/test/test_fox.rb +106 -0
- data/test/test_fox2.rb +108 -0
- data/test/test_histogram.rb +18 -0
- data/test/test_hough.rb +29 -0
- data/test/test_keypoints.rb +106 -0
- data/test/test_labeling.rb +30 -0
- data/test/test_mask.rb +34 -0
- data/test/test_warping.rb +46 -0
- data/test/test_watershed.rb +35 -0
- data/test/ts_camellia.rb +12 -0
- metadata +110 -0
data/ext/camellia_ruby.i
ADDED
@@ -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
|
+
|