ruby-opencv 0.0.8.pre-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/.gitignore +25 -0
  2. data/Gemfile +8 -0
  3. data/History.txt +5 -0
  4. data/License.txt +30 -0
  5. data/Manifest.txt +225 -0
  6. data/README.rdoc +149 -0
  7. data/Rakefile +32 -0
  8. data/examples/alpha_blend.rb +21 -0
  9. data/examples/box.png +0 -0
  10. data/examples/box_in_scene.png +0 -0
  11. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  12. data/examples/contours/bitmap-contours.png +0 -0
  13. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  14. data/examples/contours/contour_retrieval_modes.rb +139 -0
  15. data/examples/contours/rotated-boxes.jpg +0 -0
  16. data/examples/convexhull.rb +47 -0
  17. data/examples/face_detect.rb +20 -0
  18. data/examples/find_obj.rb +169 -0
  19. data/examples/houghcircle.rb +22 -0
  20. data/examples/inpaint.png +0 -0
  21. data/examples/inpaint.rb +57 -0
  22. data/examples/lenna-rotated.jpg +0 -0
  23. data/examples/lenna.jpg +0 -0
  24. data/examples/match_kdtree.rb +88 -0
  25. data/examples/matching_to_many_images.rb +16 -0
  26. data/examples/matching_to_many_images/query.png +0 -0
  27. data/examples/matching_to_many_images/train/1.png +0 -0
  28. data/examples/matching_to_many_images/train/2.png +0 -0
  29. data/examples/matching_to_many_images/train/3.png +0 -0
  30. data/examples/matching_to_many_images/train/trainImages.txt +3 -0
  31. data/examples/paint.rb +70 -0
  32. data/examples/snake.rb +43 -0
  33. data/examples/stuff.jpg +0 -0
  34. data/examples/tiffany.jpg +0 -0
  35. data/ext/opencv/curve.cpp +112 -0
  36. data/ext/opencv/curve.h +34 -0
  37. data/ext/opencv/cvavgcomp.cpp +67 -0
  38. data/ext/opencv/cvavgcomp.h +39 -0
  39. data/ext/opencv/cvbox2d.cpp +197 -0
  40. data/ext/opencv/cvbox2d.h +61 -0
  41. data/ext/opencv/cvcapture.cpp +499 -0
  42. data/ext/opencv/cvcapture.h +72 -0
  43. data/ext/opencv/cvchain.cpp +233 -0
  44. data/ext/opencv/cvchain.h +46 -0
  45. data/ext/opencv/cvcircle32f.cpp +116 -0
  46. data/ext/opencv/cvcircle32f.h +52 -0
  47. data/ext/opencv/cvcondensation.cpp +282 -0
  48. data/ext/opencv/cvcondensation.h +49 -0
  49. data/ext/opencv/cvconnectedcomp.cpp +143 -0
  50. data/ext/opencv/cvconnectedcomp.h +49 -0
  51. data/ext/opencv/cvcontour.cpp +296 -0
  52. data/ext/opencv/cvcontour.h +48 -0
  53. data/ext/opencv/cvcontourtree.cpp +91 -0
  54. data/ext/opencv/cvcontourtree.h +41 -0
  55. data/ext/opencv/cvconvexitydefect.cpp +103 -0
  56. data/ext/opencv/cvconvexitydefect.h +42 -0
  57. data/ext/opencv/cverror.cpp +159 -0
  58. data/ext/opencv/cverror.h +28 -0
  59. data/ext/opencv/cvfeaturetree.cpp +125 -0
  60. data/ext/opencv/cvfeaturetree.h +55 -0
  61. data/ext/opencv/cvfont.cpp +208 -0
  62. data/ext/opencv/cvfont.h +64 -0
  63. data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
  64. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  65. data/ext/opencv/cvhistogram.cpp +546 -0
  66. data/ext/opencv/cvhistogram.h +73 -0
  67. data/ext/opencv/cvhumoments.cpp +139 -0
  68. data/ext/opencv/cvhumoments.h +51 -0
  69. data/ext/opencv/cvline.cpp +154 -0
  70. data/ext/opencv/cvline.h +54 -0
  71. data/ext/opencv/cvmat.cpp +5848 -0
  72. data/ext/opencv/cvmat.h +284 -0
  73. data/ext/opencv/cvmatnd.cpp +44 -0
  74. data/ext/opencv/cvmatnd.h +28 -0
  75. data/ext/opencv/cvmemstorage.cpp +68 -0
  76. data/ext/opencv/cvmemstorage.h +53 -0
  77. data/ext/opencv/cvmoments.cpp +287 -0
  78. data/ext/opencv/cvmoments.h +75 -0
  79. data/ext/opencv/cvpoint.cpp +228 -0
  80. data/ext/opencv/cvpoint.h +64 -0
  81. data/ext/opencv/cvpoint2d32f.cpp +211 -0
  82. data/ext/opencv/cvpoint2d32f.h +63 -0
  83. data/ext/opencv/cvpoint3d32f.cpp +245 -0
  84. data/ext/opencv/cvpoint3d32f.h +66 -0
  85. data/ext/opencv/cvrect.cpp +333 -0
  86. data/ext/opencv/cvrect.h +79 -0
  87. data/ext/opencv/cvscalar.cpp +236 -0
  88. data/ext/opencv/cvscalar.h +71 -0
  89. data/ext/opencv/cvseq.cpp +599 -0
  90. data/ext/opencv/cvseq.h +74 -0
  91. data/ext/opencv/cvsize.cpp +221 -0
  92. data/ext/opencv/cvsize.h +65 -0
  93. data/ext/opencv/cvsize2d32f.cpp +209 -0
  94. data/ext/opencv/cvsize2d32f.h +64 -0
  95. data/ext/opencv/cvslice.cpp +120 -0
  96. data/ext/opencv/cvslice.h +61 -0
  97. data/ext/opencv/cvsparsemat.cpp +44 -0
  98. data/ext/opencv/cvsparsemat.h +28 -0
  99. data/ext/opencv/cvsurfparams.cpp +199 -0
  100. data/ext/opencv/cvsurfparams.h +58 -0
  101. data/ext/opencv/cvsurfpoint.cpp +223 -0
  102. data/ext/opencv/cvsurfpoint.h +52 -0
  103. data/ext/opencv/cvtermcriteria.cpp +192 -0
  104. data/ext/opencv/cvtermcriteria.h +71 -0
  105. data/ext/opencv/cvtwopoints.cpp +116 -0
  106. data/ext/opencv/cvtwopoints.h +51 -0
  107. data/ext/opencv/cvutils.cpp +194 -0
  108. data/ext/opencv/cvutils.h +29 -0
  109. data/ext/opencv/cvvideowriter.cpp +137 -0
  110. data/ext/opencv/cvvideowriter.h +43 -0
  111. data/ext/opencv/gui.cpp +68 -0
  112. data/ext/opencv/gui.h +30 -0
  113. data/ext/opencv/iplconvkernel.cpp +192 -0
  114. data/ext/opencv/iplconvkernel.h +71 -0
  115. data/ext/opencv/iplimage.cpp +644 -0
  116. data/ext/opencv/iplimage.h +73 -0
  117. data/ext/opencv/lib/opencv.rb +3 -0
  118. data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
  119. data/ext/opencv/lib/opencv/version.rb +3 -0
  120. data/ext/opencv/mouseevent.cpp +181 -0
  121. data/ext/opencv/mouseevent.h +56 -0
  122. data/ext/opencv/opencv.cpp +722 -0
  123. data/ext/opencv/opencv.h +400 -0
  124. data/ext/opencv/pointset.cpp +274 -0
  125. data/ext/opencv/pointset.h +68 -0
  126. data/ext/opencv/trackbar.cpp +121 -0
  127. data/ext/opencv/trackbar.h +69 -0
  128. data/ext/opencv/window.cpp +357 -0
  129. data/ext/opencv/window.h +66 -0
  130. data/extconf.rb +75 -0
  131. data/images/CvMat_sobel.png +0 -0
  132. data/images/CvMat_sub_rect.png +0 -0
  133. data/images/CvSeq_relationmap.png +0 -0
  134. data/images/face_detect_from_lena.jpg +0 -0
  135. data/lib/opencv.rb +3 -0
  136. data/lib/opencv/psyched_yaml.rb +22 -0
  137. data/lib/opencv/version.rb +3 -0
  138. data/ruby-opencv.gemspec +43 -0
  139. data/test/helper.rb +166 -0
  140. data/test/runner.rb +30 -0
  141. data/test/samples/airplane.jpg +0 -0
  142. data/test/samples/baboon.jpg +0 -0
  143. data/test/samples/baboon200.jpg +0 -0
  144. data/test/samples/baboon200_rotated.jpg +0 -0
  145. data/test/samples/blank0.jpg +0 -0
  146. data/test/samples/blank1.jpg +0 -0
  147. data/test/samples/blank2.jpg +0 -0
  148. data/test/samples/blank3.jpg +0 -0
  149. data/test/samples/blank4.jpg +0 -0
  150. data/test/samples/blank5.jpg +0 -0
  151. data/test/samples/blank6.jpg +0 -0
  152. data/test/samples/blank7.jpg +0 -0
  153. data/test/samples/blank8.jpg +0 -0
  154. data/test/samples/blank9.jpg +0 -0
  155. data/test/samples/cat.jpg +0 -0
  156. data/test/samples/chessboard.jpg +0 -0
  157. data/test/samples/contours.jpg +0 -0
  158. data/test/samples/fruits.jpg +0 -0
  159. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  160. data/test/samples/inpaint-mask.bmp +0 -0
  161. data/test/samples/lena-256x256.jpg +0 -0
  162. data/test/samples/lena-32x32.jpg +0 -0
  163. data/test/samples/lena-eyes.jpg +0 -0
  164. data/test/samples/lena-inpaint.jpg +0 -0
  165. data/test/samples/lena.jpg +0 -0
  166. data/test/samples/lines.jpg +0 -0
  167. data/test/samples/messy0.jpg +0 -0
  168. data/test/samples/messy1.jpg +0 -0
  169. data/test/samples/movie_sample.avi +0 -0
  170. data/test/samples/one_way_train_0000.jpg +0 -0
  171. data/test/samples/one_way_train_0001.jpg +0 -0
  172. data/test/samples/partially_blank0.jpg +0 -0
  173. data/test/samples/partially_blank1.jpg +0 -0
  174. data/test/samples/smooth0.jpg +0 -0
  175. data/test/samples/smooth1.jpg +0 -0
  176. data/test/samples/smooth2.jpg +0 -0
  177. data/test/samples/smooth3.jpg +0 -0
  178. data/test/samples/smooth4.jpg +0 -0
  179. data/test/samples/smooth5.jpg +0 -0
  180. data/test/samples/smooth6.jpg +0 -0
  181. data/test/samples/str-cv-rotated.jpg +0 -0
  182. data/test/samples/str-cv.jpg +0 -0
  183. data/test/samples/str-ov.jpg +0 -0
  184. data/test/samples/stuff.jpg +0 -0
  185. data/test/test_curve.rb +43 -0
  186. data/test/test_cvavgcomp.rb +24 -0
  187. data/test/test_cvbox2d.rb +76 -0
  188. data/test/test_cvcapture.rb +183 -0
  189. data/test/test_cvchain.rb +108 -0
  190. data/test/test_cvcircle32f.rb +41 -0
  191. data/test/test_cvconnectedcomp.rb +61 -0
  192. data/test/test_cvcontour.rb +150 -0
  193. data/test/test_cvcontourtree.rb +43 -0
  194. data/test/test_cverror.rb +50 -0
  195. data/test/test_cvfeaturetree.rb +65 -0
  196. data/test/test_cvfont.rb +58 -0
  197. data/test/test_cvhaarclassifiercascade.rb +63 -0
  198. data/test/test_cvhistogram.rb +271 -0
  199. data/test/test_cvhumoments.rb +83 -0
  200. data/test/test_cvline.rb +50 -0
  201. data/test/test_cvmat.rb +2947 -0
  202. data/test/test_cvmat_drawing.rb +349 -0
  203. data/test/test_cvmat_dxt.rb +150 -0
  204. data/test/test_cvmat_imageprocessing.rb +2025 -0
  205. data/test/test_cvmat_matching.rb +57 -0
  206. data/test/test_cvmoments.rb +180 -0
  207. data/test/test_cvpoint.rb +75 -0
  208. data/test/test_cvpoint2d32f.rb +75 -0
  209. data/test/test_cvpoint3d32f.rb +93 -0
  210. data/test/test_cvrect.rb +144 -0
  211. data/test/test_cvscalar.rb +113 -0
  212. data/test/test_cvseq.rb +295 -0
  213. data/test/test_cvsize.rb +75 -0
  214. data/test/test_cvsize2d32f.rb +75 -0
  215. data/test/test_cvslice.rb +31 -0
  216. data/test/test_cvsurfparams.rb +57 -0
  217. data/test/test_cvsurfpoint.rb +66 -0
  218. data/test/test_cvtermcriteria.rb +56 -0
  219. data/test/test_cvtwopoints.rb +40 -0
  220. data/test/test_cvvideowriter.rb +58 -0
  221. data/test/test_iplconvkernel.rb +54 -0
  222. data/test/test_iplimage.rb +236 -0
  223. data/test/test_mouseevent.rb +17 -0
  224. data/test/test_opencv.rb +324 -0
  225. data/test/test_pointset.rb +126 -0
  226. data/test/test_preliminary.rb +130 -0
  227. data/test/test_trackbar.rb +47 -0
  228. data/test/test_window.rb +115 -0
  229. metadata +414 -0
@@ -0,0 +1,41 @@
1
+ /************************************************************
2
+
3
+ cvcontourtree.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVCONTOURTREE_H
11
+ #define RUBY_OPENCV_CVCONTOURTREE_H
12
+ #include "opencv.h"
13
+
14
+ #define __NAMESPACE_BEGIN_CVCONTOURTREE namespace cCvContourTree {
15
+ #define __NAMESPACE_END_CVCONTOURTREE }
16
+
17
+ __NAMESPACE_BEGIN_OPENCV
18
+ __NAMESPACE_BEGIN_CVCONTOURTREE
19
+
20
+ VALUE rb_class();
21
+
22
+ void define_ruby_class();
23
+
24
+ VALUE rb_p1(VALUE self);
25
+ VALUE rb_p2(VALUE self);
26
+ VALUE rb_contour(VALUE self, VALUE criteria);
27
+
28
+ VALUE new_object();
29
+
30
+ __NAMESPACE_END_CVCONTOURTREE
31
+
32
+ inline CvContourTree*
33
+ CVCONTOURTREE(VALUE object){
34
+ CvContourTree *ptr;
35
+ Data_Get_Struct(object, CvContourTree, ptr);
36
+ return ptr;
37
+ }
38
+
39
+ __NAMESPACE_END_OPENCV
40
+
41
+ #endif // RUBY_OPENCV_CVCONTOUR_H
@@ -0,0 +1,103 @@
1
+ /************************************************************
2
+
3
+ cvconvexitydefect.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvconvexitydefect.h"
11
+ /*
12
+ * Document-class: OpenCV::CvConvexityDefect
13
+ *
14
+ * Convexity.
15
+ * C structure is here.
16
+ * typedef struct CvConvexityDefect {
17
+ * CvPoint* start;
18
+ * CvPoint* end;
19
+ * CvPoint* depth_point;
20
+ * float depth;
21
+ * } CvConvexityDefect;
22
+ *
23
+ */
24
+ __NAMESPACE_BEGIN_OPENCV
25
+ __NAMESPACE_BEGIN_CVCONVEXITYDEFECT
26
+
27
+ VALUE rb_klass;
28
+
29
+ VALUE
30
+ rb_class()
31
+ {
32
+ return rb_klass;
33
+ }
34
+
35
+ void
36
+ define_ruby_class()
37
+ {
38
+ if (rb_klass)
39
+ return;
40
+ /*
41
+ * opencv = rb_define_module("OpenCV");
42
+ *
43
+ * note: this comment is used by rdoc.
44
+ */
45
+ VALUE opencv = rb_module_opencv();
46
+
47
+ rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
48
+ rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
49
+ rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
50
+ rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
51
+ rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
52
+ }
53
+
54
+ /*
55
+ * call-seq:
56
+ * start -> cvpoint
57
+ *
58
+ * Return start point as CvPoint.
59
+ */
60
+ VALUE
61
+ rb_start(VALUE self)
62
+ {
63
+ return cCvPoint::new_object(*CVCONVEXITYDEFECT(self)->start);
64
+ }
65
+
66
+ /*
67
+ * call-seq:
68
+ * end -> cvpoint
69
+ *
70
+ * Return end point as CvPoint.
71
+ */
72
+ VALUE
73
+ rb_end(VALUE self)
74
+ {
75
+ return cCvPoint::new_object(*CVCONVEXITYDEFECT(self)->end);
76
+ }
77
+
78
+ /*
79
+ * call-seq:
80
+ * depth_point -> cvpoint
81
+ *
82
+ * Return depth point as CvPoint.
83
+ */
84
+ VALUE
85
+ rb_depth_point(VALUE self)
86
+ {
87
+ return cCvPoint::new_object(*CVCONVEXITYDEFECT(self)->depth_point);
88
+ }
89
+
90
+ /*
91
+ * call-seq:
92
+ * depth -> float
93
+ *
94
+ * Return depth.
95
+ */
96
+ VALUE
97
+ rb_depth(VALUE self)
98
+ {
99
+ return rb_float_new(CVCONVEXITYDEFECT(self)->depth);
100
+ }
101
+
102
+ __NAMESPACE_END_CVCONVEXITYDEFECT
103
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,42 @@
1
+ /************************************************************
2
+
3
+ cvconvexitydefect.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVCONVEXITYDEFECT_H
11
+ #define RUBY_OPENCV_CVCONVEXITYDEFECT_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVCONVEXITYDEFECT namespace cCvConvexityDefect {
16
+ #define __NAMESPACE_END_CVCONVEXITYDEFECT }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVCONVEXITYDEFECT
20
+
21
+ VALUE rb_class();
22
+
23
+ void define_ruby_class();
24
+
25
+ VALUE rb_start(VALUE self);
26
+ VALUE rb_end(VALUE self);
27
+ VALUE rb_depth_point(VALUE self);
28
+ VALUE rb_depth(VALUE self);
29
+
30
+ __NAMESPACE_END_CVCONVEXITYDEFECT
31
+
32
+ inline CvConvexityDefect*
33
+ CVCONVEXITYDEFECT(VALUE object)
34
+ {
35
+ CvConvexityDefect *ptr;
36
+ Data_Get_Struct(object, CvConvexityDefect, ptr);
37
+ return ptr;
38
+ }
39
+
40
+ __NAMESPACE_END_OPENCV
41
+
42
+ #endif // RUBY_OPENCV_CVCONVEXITYDEFECT_H
@@ -0,0 +1,159 @@
1
+ /************************************************************
2
+
3
+ cverror.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cverror.h"
11
+ /*
12
+ * Document-class: OpenCV::CvError
13
+ *
14
+ * =Internal OpenCV errors
15
+ *
16
+ * This module collect OpenCV internal error wrapper classes.
17
+ * * CvStatusBackTrace
18
+ * * CvStatusError
19
+ * * CvStatusInternal
20
+ * * CvStatusNoMemory
21
+ * * CvStatusBadArgument
22
+ * * CvStatusNoConverge
23
+ * * CvStatusAutoTrace
24
+ *
25
+ * * CvHeaderIsNull
26
+ * * CvBadImageSize
27
+ * * CvBadOffset
28
+ * * CvBadDataPointer
29
+ * * CvBadStep
30
+ * * CvBadModelOrChannelSequence
31
+ * * CvBadNumChannels
32
+ * * CvBadAlphaChannel
33
+ * * CvBadOrder
34
+ * * CvBadOrigin
35
+ * * CvBadAlign
36
+ * * CvBadCallback
37
+ * * CvBadTileSize
38
+ * * CvBadCOI
39
+ * * CvBadROISize
40
+ *
41
+ * * CvMaskIsTiled
42
+ *
43
+ * * CvStatusNullPointer
44
+ * * CvStatusVectorLengthError
45
+ * * CvStatusFilterStructContentError
46
+ * * CvStatusKernelStructContentError
47
+ * * CvStatusFilterOffsetError
48
+ *
49
+ * * CvStatusBadSize
50
+ * * CvStatusDivByZero
51
+ * * CvStatusInplaceNotSupported
52
+ * * CvStatusObjectNotFound
53
+ * * CvStatusUnmatchedFormant
54
+ * * CvStatusUnsupportedFormats
55
+ * * CvStatusOutOfRange
56
+ * * CvStatusParseError
57
+ * * CvStatusNotImplemented
58
+ * * CvStsBadMemoryBlock
59
+ */
60
+
61
+ __NAMESPACE_BEGIN_OPENCV
62
+ __NAMESPACE_BEGIN_CVERROR
63
+
64
+ st_table *cv_error = st_init_numtable();
65
+
66
+ VALUE rb_klass;
67
+
68
+ void
69
+ REGISTER_CVERROR(const char* object_name, int error_code)
70
+ {
71
+ st_insert(cv_error, (st_data_t)error_code,
72
+ (st_data_t)rb_define_class_under(rb_module_opencv(), object_name, rb_klass));
73
+ }
74
+
75
+ VALUE
76
+ rb_class()
77
+ {
78
+ return rb_klass;
79
+ }
80
+
81
+ void define_ruby_class()
82
+ {
83
+ if (rb_klass)
84
+ return;
85
+
86
+ /*
87
+ * opencv = rb_define_module("OpenCV");
88
+ *
89
+ * note: this comment is used by rdoc.
90
+ */
91
+ VALUE opencv = rb_module_opencv();
92
+
93
+ rb_klass = rb_define_class_under(opencv, "CvError", rb_eStandardError);
94
+ REGISTER_CVERROR("CvStsBackTrace", CV_StsBackTrace);
95
+ REGISTER_CVERROR("CvStsError", CV_StsError);
96
+ REGISTER_CVERROR("CvStsInternal", CV_StsInternal);
97
+ REGISTER_CVERROR("CvStsNoMem", CV_StsNoMem);
98
+ REGISTER_CVERROR("CvStsBadArg", CV_StsBadArg);
99
+ REGISTER_CVERROR("CvStsBadFunc", CV_StsBadFunc);
100
+ REGISTER_CVERROR("CvStsNoConv", CV_StsNoConv);
101
+ REGISTER_CVERROR("CvStsAutoTrace", CV_StsAutoTrace);
102
+ REGISTER_CVERROR("CvHeaderIsNull", CV_HeaderIsNull);
103
+ REGISTER_CVERROR("CvBadImageSize", CV_BadImageSize);
104
+ REGISTER_CVERROR("CvBadOffset", CV_BadOffset);
105
+ REGISTER_CVERROR("CvBadDataPtr", CV_BadDataPtr);
106
+ REGISTER_CVERROR("CvBadStep", CV_BadStep);
107
+ REGISTER_CVERROR("CvBadModelOrChSeq", CV_BadModelOrChSeq);
108
+ REGISTER_CVERROR("CvBadNumChannels", CV_BadNumChannels);
109
+ REGISTER_CVERROR("CvBadNumChannel1U", CV_BadNumChannel1U);
110
+ REGISTER_CVERROR("CvBadDepth", CV_BadDepth);
111
+ REGISTER_CVERROR("CvBadAlphaChannel", CV_BadAlphaChannel);
112
+ REGISTER_CVERROR("CvBadOrder", CV_BadOrder);
113
+ REGISTER_CVERROR("CvBadOrigin", CV_BadOrigin);
114
+ REGISTER_CVERROR("CvBadAlign", CV_BadAlign);
115
+ REGISTER_CVERROR("CvBadCallBack", CV_BadCallBack);
116
+ REGISTER_CVERROR("CvBadTileSize", CV_BadTileSize);
117
+ REGISTER_CVERROR("CvBadCOI", CV_BadCOI);
118
+ REGISTER_CVERROR("CvBadROISize", CV_BadROISize);
119
+ REGISTER_CVERROR("CvMaskIsTiled", CV_MaskIsTiled);
120
+ REGISTER_CVERROR("CvStsNullPtr", CV_StsNullPtr);
121
+ REGISTER_CVERROR("CvStsVecLengthErr", CV_StsVecLengthErr);
122
+ REGISTER_CVERROR("CvStsFilterStructContentErr", CV_StsFilterStructContentErr);
123
+ REGISTER_CVERROR("CvStsKernelStructContentErr", CV_StsKernelStructContentErr);
124
+ REGISTER_CVERROR("CvStsFilterOffsetErr", CV_StsFilterOffsetErr);
125
+ REGISTER_CVERROR("CvStsBadSize", CV_StsBadSize);
126
+ REGISTER_CVERROR("CvStsDivByZero", CV_StsDivByZero);
127
+ REGISTER_CVERROR("CvStsInplaceNotSupported", CV_StsInplaceNotSupported);
128
+ REGISTER_CVERROR("CvStsObjectNotFound", CV_StsObjectNotFound);
129
+ REGISTER_CVERROR("CvStsUnmatchedFormats", CV_StsUnmatchedFormats);
130
+ REGISTER_CVERROR("CvStsBadFlag", CV_StsBadFlag);
131
+ REGISTER_CVERROR("CvStsBadPoint", CV_StsBadPoint);
132
+ REGISTER_CVERROR("CvStsBadMask", CV_StsBadMask);
133
+ REGISTER_CVERROR("CvStsUnmatchedSizes", CV_StsUnmatchedSizes);
134
+ REGISTER_CVERROR("CvStsUnsupportedFormat", CV_StsUnsupportedFormat);
135
+ REGISTER_CVERROR("CvStsOutOfRange", CV_StsOutOfRange);
136
+ REGISTER_CVERROR("CvStsParseError", CV_StsParseError);
137
+ REGISTER_CVERROR("CvStsNotImplemented", CV_StsNotImplemented);
138
+ REGISTER_CVERROR("CvStsBadMemBlock", CV_StsBadMemBlock);
139
+ REGISTER_CVERROR("CvStsAssert", CV_StsAssert);
140
+ REGISTER_CVERROR("CvGpuNotSupported", CV_GpuNotSupported);
141
+ REGISTER_CVERROR("CvGpuApiCallError", CV_GpuApiCallError);
142
+ }
143
+
144
+ VALUE
145
+ by_code(int error_code)
146
+ {
147
+ VALUE klass = 0;
148
+ st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
149
+ return klass ? klass : rb_eStandardError;
150
+ }
151
+
152
+ void
153
+ raise(cv::Exception e)
154
+ {
155
+ rb_raise(by_code(e.code), "%s", e.what());
156
+ }
157
+
158
+ __NAMESPACE_END_CVERROR
159
+ __NAMESPACE_END_OPENCV
@@ -0,0 +1,28 @@
1
+ /************************************************************
2
+
3
+ cverror.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVERROR_H
11
+ #define RUBY_OPENCV_CVERROR_H
12
+
13
+ #include "opencv.h"
14
+
15
+ #define __NAMESPACE_BEGIN_CVERROR namespace cCvError {
16
+ #define __NAMESPACE_END_CVERROR }
17
+
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVERROR
20
+
21
+ void define_ruby_class();
22
+ VALUE by_code(int error_code);
23
+ void raise(cv::Exception e);
24
+
25
+ __NAMESPACE_END_CVERROR
26
+ __NAMESPACE_END_OPENCV
27
+
28
+ #endif // RUBY_OPENCV_CVERROR_H
@@ -0,0 +1,125 @@
1
+ /************************************************************
2
+
3
+ cvfeaturetree.cpp -
4
+
5
+ $Author: ser1zw $
6
+
7
+ Copyright (C) 2011 ser1zw
8
+
9
+ ************************************************************/
10
+ #include "cvfeaturetree.h"
11
+ /*
12
+ * Document-class: OpenCV::CvFeatureTree
13
+ */
14
+ __NAMESPACE_BEGIN_OPENCV
15
+ __NAMESPACE_BEGIN_CVFEATURETREE
16
+
17
+ VALUE rb_klass;
18
+
19
+ VALUE
20
+ rb_class()
21
+ {
22
+ return rb_klass;
23
+ }
24
+
25
+ void
26
+ mark_feature_tree(void *ptr)
27
+ {
28
+ if (ptr) {
29
+ VALUE desc = ((CvFeatureTreeWrap*)ptr)->desc;
30
+ rb_gc_mark(desc);
31
+ }
32
+ }
33
+
34
+ void
35
+ rb_release_feature_tree(void *ptr)
36
+ {
37
+ if (ptr) {
38
+ CvFeatureTree* ft = ((CvFeatureTreeWrap*)ptr)->feature_tree;
39
+ cvReleaseFeatureTree(ft);
40
+ }
41
+ }
42
+
43
+ VALUE
44
+ rb_allocate(VALUE klass)
45
+ {
46
+ CvFeatureTreeWrap* ptr;
47
+ return Data_Make_Struct(klass, CvFeatureTreeWrap, mark_feature_tree,
48
+ rb_release_feature_tree, ptr);
49
+ }
50
+
51
+ void
52
+ define_ruby_class()
53
+ {
54
+ if (rb_klass)
55
+ return;
56
+ /*
57
+ * opencv = rb_define_module("OpenCV");
58
+ *
59
+ * note: this comment is used by rdoc.
60
+ */
61
+ VALUE opencv = rb_module_opencv();
62
+
63
+ rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
64
+ rb_define_alloc_func(rb_klass, rb_allocate);
65
+ rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
66
+
67
+ rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
68
+ }
69
+
70
+ /*
71
+ * call-seq:
72
+ * new(desc)
73
+ *
74
+ * Create a new kd-tree
75
+ */
76
+ VALUE
77
+ rb_initialize(VALUE self, VALUE desc)
78
+ {
79
+ CvMat* desc_mat = CVMAT_WITH_CHECK(desc);
80
+ CvFeatureTreeWrap* self_ptr = (CvFeatureTreeWrap*)DATA_PTR(self);
81
+ free(self_ptr);
82
+ self_ptr = ALLOC(CvFeatureTreeWrap);
83
+ try {
84
+ self_ptr->feature_tree = cvCreateKDTree(desc_mat);
85
+ }
86
+ catch (cv::Exception& e) {
87
+ raise_cverror(e);
88
+ }
89
+ self_ptr->desc = desc;
90
+ return self;
91
+ }
92
+
93
+ /*
94
+ * call-seq:
95
+ * find_features(desc, rows, cols, k, emax) -> array(results, dist)
96
+ *
97
+ * Find features from kd-tree
98
+ *
99
+ * desc: m x d matrix of (row-)vectors to find the nearest neighbors of.
100
+ * k: The number of neighbors to find.
101
+ * emax: The maximum number of leaves to visit.
102
+ *
103
+ * return
104
+ * results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
105
+ * dist: m x k matrix of distances to k nearest neighbors.
106
+ */
107
+ VALUE
108
+ rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
109
+ {
110
+ CvMat* desc_mat = CVMAT_WITH_CHECK(desc);
111
+ int _k = NUM2INT(k);
112
+ VALUE results = cCvMat::new_object(desc_mat->rows, _k, CV_32SC1);
113
+ VALUE dist = cCvMat::new_object(desc_mat->rows, _k, CV_64FC1);
114
+ try {
115
+ cvFindFeatures(CVFEATURETREE(self), desc_mat, CVMAT(results), CVMAT(dist), _k, NUM2INT(emax));
116
+ }
117
+ catch (cv::Exception& e) {
118
+ raise_cverror(e);
119
+ }
120
+ return rb_assoc_new(results, dist);
121
+ }
122
+
123
+ __NAMESPACE_END_OPENCV
124
+ __NAMESPACE_END_CVFEATURETREE
125
+