jf-ruby-opencv 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.yardopts +3 -0
  4. data/DEVELOPERS_NOTE.md +137 -0
  5. data/Gemfile +9 -0
  6. data/History.txt +5 -0
  7. data/License.txt +30 -0
  8. data/Manifest.txt +239 -0
  9. data/README.md +94 -0
  10. data/Rakefile +99 -0
  11. data/config.yml +7 -0
  12. data/examples/alpha_blend.rb +21 -0
  13. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  14. data/examples/contours/bitmap-contours.png +0 -0
  15. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  16. data/examples/contours/contour_retrieval_modes.rb +139 -0
  17. data/examples/contours/rotated-boxes.jpg +0 -0
  18. data/examples/convexhull.rb +47 -0
  19. data/examples/face_detect.rb +20 -0
  20. data/examples/facerec/create_csv.rb +43 -0
  21. data/examples/facerec/facerec_eigenfaces.rb +132 -0
  22. data/examples/facerec/facerec_fisherfaces.rb +131 -0
  23. data/examples/facerec/facerec_lbph.rb +116 -0
  24. data/examples/facerec/readme.md +111 -0
  25. data/examples/find_obj.rb +169 -0
  26. data/examples/houghcircle.rb +22 -0
  27. data/examples/images/box.png +0 -0
  28. data/examples/images/box_in_scene.png +0 -0
  29. data/examples/images/inpaint.png +0 -0
  30. data/examples/images/lena-256x256.jpg +0 -0
  31. data/examples/images/lena-eyes.jpg +0 -0
  32. data/examples/images/lenna-rotated.jpg +0 -0
  33. data/examples/images/lenna.jpg +0 -0
  34. data/examples/images/stuff.jpg +0 -0
  35. data/examples/images/tiffany.jpg +0 -0
  36. data/examples/inpaint.rb +57 -0
  37. data/examples/match_kdtree.rb +88 -0
  38. data/examples/match_template.rb +26 -0
  39. data/examples/paint.rb +70 -0
  40. data/examples/snake.rb +43 -0
  41. data/ext/opencv/algorithm.cpp +291 -0
  42. data/ext/opencv/algorithm.h +38 -0
  43. data/ext/opencv/curve.cpp +127 -0
  44. data/ext/opencv/curve.h +34 -0
  45. data/ext/opencv/cvavgcomp.cpp +64 -0
  46. data/ext/opencv/cvavgcomp.h +39 -0
  47. data/ext/opencv/cvbox2d.cpp +195 -0
  48. data/ext/opencv/cvbox2d.h +61 -0
  49. data/ext/opencv/cvcapture.cpp +633 -0
  50. data/ext/opencv/cvcapture.h +82 -0
  51. data/ext/opencv/cvchain.cpp +233 -0
  52. data/ext/opencv/cvchain.h +46 -0
  53. data/ext/opencv/cvcircle32f.cpp +126 -0
  54. data/ext/opencv/cvcircle32f.h +52 -0
  55. data/ext/opencv/cvconnectedcomp.cpp +156 -0
  56. data/ext/opencv/cvconnectedcomp.h +49 -0
  57. data/ext/opencv/cvcontour.cpp +384 -0
  58. data/ext/opencv/cvcontour.h +51 -0
  59. data/ext/opencv/cvcontourtree.cpp +96 -0
  60. data/ext/opencv/cvcontourtree.h +41 -0
  61. data/ext/opencv/cvconvexitydefect.cpp +92 -0
  62. data/ext/opencv/cvconvexitydefect.h +42 -0
  63. data/ext/opencv/cverror.cpp +115 -0
  64. data/ext/opencv/cverror.h +28 -0
  65. data/ext/opencv/cvfeaturetree.cpp +123 -0
  66. data/ext/opencv/cvfeaturetree.h +55 -0
  67. data/ext/opencv/cvfont.cpp +228 -0
  68. data/ext/opencv/cvfont.h +64 -0
  69. data/ext/opencv/cvhaarclassifiercascade.cpp +148 -0
  70. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  71. data/ext/opencv/cvhistogram.cpp +717 -0
  72. data/ext/opencv/cvhistogram.h +73 -0
  73. data/ext/opencv/cvhumoments.cpp +178 -0
  74. data/ext/opencv/cvhumoments.h +51 -0
  75. data/ext/opencv/cvline.cpp +159 -0
  76. data/ext/opencv/cvline.h +54 -0
  77. data/ext/opencv/cvmat.cpp +6086 -0
  78. data/ext/opencv/cvmat.h +290 -0
  79. data/ext/opencv/cvmemstorage.cpp +73 -0
  80. data/ext/opencv/cvmemstorage.h +50 -0
  81. data/ext/opencv/cvmoments.cpp +293 -0
  82. data/ext/opencv/cvmoments.h +75 -0
  83. data/ext/opencv/cvpoint.cpp +234 -0
  84. data/ext/opencv/cvpoint.h +64 -0
  85. data/ext/opencv/cvpoint2d32f.cpp +216 -0
  86. data/ext/opencv/cvpoint2d32f.h +63 -0
  87. data/ext/opencv/cvpoint3d32f.cpp +252 -0
  88. data/ext/opencv/cvpoint3d32f.h +66 -0
  89. data/ext/opencv/cvrect.cpp +338 -0
  90. data/ext/opencv/cvrect.h +79 -0
  91. data/ext/opencv/cvscalar.cpp +241 -0
  92. data/ext/opencv/cvscalar.h +71 -0
  93. data/ext/opencv/cvseq.cpp +663 -0
  94. data/ext/opencv/cvseq.h +75 -0
  95. data/ext/opencv/cvsize.cpp +227 -0
  96. data/ext/opencv/cvsize.h +65 -0
  97. data/ext/opencv/cvsize2d32f.cpp +215 -0
  98. data/ext/opencv/cvsize2d32f.h +64 -0
  99. data/ext/opencv/cvslice.cpp +126 -0
  100. data/ext/opencv/cvslice.h +61 -0
  101. data/ext/opencv/cvsurfparams.cpp +208 -0
  102. data/ext/opencv/cvsurfparams.h +58 -0
  103. data/ext/opencv/cvsurfpoint.cpp +246 -0
  104. data/ext/opencv/cvsurfpoint.h +52 -0
  105. data/ext/opencv/cvtermcriteria.cpp +198 -0
  106. data/ext/opencv/cvtermcriteria.h +71 -0
  107. data/ext/opencv/cvtwopoints.cpp +122 -0
  108. data/ext/opencv/cvtwopoints.h +51 -0
  109. data/ext/opencv/cvutils.cpp +192 -0
  110. data/ext/opencv/cvutils.h +30 -0
  111. data/ext/opencv/cvvideowriter.cpp +142 -0
  112. data/ext/opencv/cvvideowriter.h +43 -0
  113. data/ext/opencv/eigenfaces.cpp +75 -0
  114. data/ext/opencv/eigenfaces.h +30 -0
  115. data/ext/opencv/extconf.rb +77 -0
  116. data/ext/opencv/facerecognizer.cpp +219 -0
  117. data/ext/opencv/facerecognizer.h +46 -0
  118. data/ext/opencv/fisherfaces.cpp +75 -0
  119. data/ext/opencv/fisherfaces.h +30 -0
  120. data/ext/opencv/gui.cpp +71 -0
  121. data/ext/opencv/gui.h +30 -0
  122. data/ext/opencv/iplconvkernel.cpp +198 -0
  123. data/ext/opencv/iplconvkernel.h +71 -0
  124. data/ext/opencv/iplimage.cpp +651 -0
  125. data/ext/opencv/iplimage.h +73 -0
  126. data/ext/opencv/lbph.cpp +78 -0
  127. data/ext/opencv/lbph.h +30 -0
  128. data/ext/opencv/mouseevent.cpp +186 -0
  129. data/ext/opencv/mouseevent.h +56 -0
  130. data/ext/opencv/opencv.cpp +819 -0
  131. data/ext/opencv/opencv.h +408 -0
  132. data/ext/opencv/pointset.cpp +280 -0
  133. data/ext/opencv/pointset.h +68 -0
  134. data/ext/opencv/trackbar.cpp +127 -0
  135. data/ext/opencv/trackbar.h +69 -0
  136. data/ext/opencv/window.cpp +377 -0
  137. data/ext/opencv/window.h +66 -0
  138. data/images/CvMat_sobel.png +0 -0
  139. data/images/CvMat_sub_rect.png +0 -0
  140. data/images/CvSeq_relationmap.png +0 -0
  141. data/lib/opencv.rb +12 -0
  142. data/lib/opencv/psyched_yaml.rb +22 -0
  143. data/lib/opencv/version.rb +3 -0
  144. data/ruby-opencv.gemspec +44 -0
  145. data/test/eigenfaces_save.xml +7524 -0
  146. data/test/fisherfaces_save.xml +7530 -0
  147. data/test/helper.rb +167 -0
  148. data/test/lbph_save.xml +4304 -0
  149. data/test/runner.rb +30 -0
  150. data/test/samples/airplane.jpg +0 -0
  151. data/test/samples/baboon.jpg +0 -0
  152. data/test/samples/baboon200.jpg +0 -0
  153. data/test/samples/baboon200_rotated.jpg +0 -0
  154. data/test/samples/blank0.jpg +0 -0
  155. data/test/samples/blank1.jpg +0 -0
  156. data/test/samples/blank2.jpg +0 -0
  157. data/test/samples/blank3.jpg +0 -0
  158. data/test/samples/blank4.jpg +0 -0
  159. data/test/samples/blank5.jpg +0 -0
  160. data/test/samples/blank6.jpg +0 -0
  161. data/test/samples/blank7.jpg +0 -0
  162. data/test/samples/blank8.jpg +0 -0
  163. data/test/samples/blank9.jpg +0 -0
  164. data/test/samples/cat.jpg +0 -0
  165. data/test/samples/chessboard.jpg +0 -0
  166. data/test/samples/contours.jpg +0 -0
  167. data/test/samples/fruits.jpg +0 -0
  168. data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
  169. data/test/samples/inpaint-mask.bmp +0 -0
  170. data/test/samples/lena-256x256.jpg +0 -0
  171. data/test/samples/lena-32x32.jpg +0 -0
  172. data/test/samples/lena-eyes.jpg +0 -0
  173. data/test/samples/lena-inpaint.jpg +0 -0
  174. data/test/samples/lena.jpg +0 -0
  175. data/test/samples/lines.jpg +0 -0
  176. data/test/samples/messy0.jpg +0 -0
  177. data/test/samples/messy1.jpg +0 -0
  178. data/test/samples/movie_sample.avi +0 -0
  179. data/test/samples/one_way_train_0000.jpg +0 -0
  180. data/test/samples/one_way_train_0001.jpg +0 -0
  181. data/test/samples/partially_blank0.jpg +0 -0
  182. data/test/samples/partially_blank1.jpg +0 -0
  183. data/test/samples/smooth0.jpg +0 -0
  184. data/test/samples/smooth1.jpg +0 -0
  185. data/test/samples/smooth2.jpg +0 -0
  186. data/test/samples/smooth3.jpg +0 -0
  187. data/test/samples/smooth4.jpg +0 -0
  188. data/test/samples/smooth5.jpg +0 -0
  189. data/test/samples/smooth6.jpg +0 -0
  190. data/test/samples/str-cv-rotated.jpg +0 -0
  191. data/test/samples/str-cv.jpg +0 -0
  192. data/test/samples/str-ov.jpg +0 -0
  193. data/test/samples/stuff.jpg +0 -0
  194. data/test/test_curve.rb +43 -0
  195. data/test/test_cvavgcomp.rb +24 -0
  196. data/test/test_cvbox2d.rb +76 -0
  197. data/test/test_cvcapture.rb +191 -0
  198. data/test/test_cvchain.rb +108 -0
  199. data/test/test_cvcircle32f.rb +41 -0
  200. data/test/test_cvconnectedcomp.rb +61 -0
  201. data/test/test_cvcontour.rb +171 -0
  202. data/test/test_cvcontourtree.rb +43 -0
  203. data/test/test_cverror.rb +50 -0
  204. data/test/test_cvfeaturetree.rb +65 -0
  205. data/test/test_cvfont.rb +58 -0
  206. data/test/test_cvhaarclassifiercascade.rb +63 -0
  207. data/test/test_cvhistogram.rb +271 -0
  208. data/test/test_cvhumoments.rb +83 -0
  209. data/test/test_cvline.rb +50 -0
  210. data/test/test_cvmat.rb +3036 -0
  211. data/test/test_cvmat_drawing.rb +349 -0
  212. data/test/test_cvmat_dxt.rb +150 -0
  213. data/test/test_cvmat_imageprocessing.rb +2085 -0
  214. data/test/test_cvmoments.rb +180 -0
  215. data/test/test_cvpoint.rb +75 -0
  216. data/test/test_cvpoint2d32f.rb +75 -0
  217. data/test/test_cvpoint3d32f.rb +93 -0
  218. data/test/test_cvrect.rb +144 -0
  219. data/test/test_cvscalar.rb +113 -0
  220. data/test/test_cvseq.rb +311 -0
  221. data/test/test_cvsize.rb +75 -0
  222. data/test/test_cvsize2d32f.rb +75 -0
  223. data/test/test_cvslice.rb +31 -0
  224. data/test/test_cvsurfparams.rb +57 -0
  225. data/test/test_cvsurfpoint.rb +66 -0
  226. data/test/test_cvtermcriteria.rb +56 -0
  227. data/test/test_cvtwopoints.rb +40 -0
  228. data/test/test_cvvideowriter.rb +58 -0
  229. data/test/test_eigenfaces.rb +93 -0
  230. data/test/test_fisherfaces.rb +93 -0
  231. data/test/test_iplconvkernel.rb +54 -0
  232. data/test/test_iplimage.rb +232 -0
  233. data/test/test_lbph.rb +166 -0
  234. data/test/test_mouseevent.rb +17 -0
  235. data/test/test_opencv.rb +360 -0
  236. data/test/test_pointset.rb +128 -0
  237. data/test/test_preliminary.rb +130 -0
  238. data/test/test_trackbar.rb +47 -0
  239. data/test/test_window.rb +115 -0
  240. data/yard_extension.rb +5 -0
  241. metadata +352 -0
@@ -0,0 +1,51 @@
1
+ /************************************************************
2
+
3
+ cvcontour.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_CVCONTOUR_H
11
+ #define RUBY_OPENCV_CVCONTOUR_H
12
+ #include "opencv.h"
13
+
14
+ #define __NAMESPACE_BEGIN_CVCONTOUR namespace cCvContour {
15
+ #define __NAMESPACE_END_CVCONTOUR }
16
+
17
+ __NAMESPACE_BEGIN_OPENCV
18
+ __NAMESPACE_BEGIN_CVCONTOUR
19
+
20
+ VALUE rb_class();
21
+
22
+ void init_ruby_class();
23
+
24
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
25
+ VALUE rb_rect(VALUE self);
26
+ VALUE rb_color(VALUE self);
27
+ VALUE rb_set_color(VALUE self, VALUE color);
28
+ VALUE rb_reserved(VALUE self);
29
+ VALUE rb_approx_poly(int argc, VALUE *argv, VALUE self);
30
+ VALUE rb_bounding_rect(VALUE self);
31
+ VALUE rb_create_tree(int argc, VALUE *argv, VALUE self);
32
+ VALUE rb_in_q(VALUE self, VALUE point);
33
+ VALUE rb_measure_distance(VALUE self, VALUE point);
34
+ VALUE rb_point_polygon_test(VALUE self, VALUE point, VALUE measure_dist);
35
+
36
+ /* Matching*/
37
+ VALUE rb_match_shapes(int argc, VALUE *argv, VALUE self);
38
+
39
+ VALUE new_object();
40
+ __NAMESPACE_END_CVCONTOUR
41
+
42
+ inline CvContour*
43
+ CVCONTOUR(VALUE object){
44
+ CvContour *ptr;
45
+ Data_Get_Struct(object, CvContour, ptr);
46
+ return ptr;
47
+ }
48
+
49
+ __NAMESPACE_END_OPENCV
50
+
51
+ #endif // RUBY_OPENCV_CVCONTOUR_H
@@ -0,0 +1,96 @@
1
+ /************************************************************
2
+
3
+ cvcontourtree.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2007 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include "cvcontour.h"
11
+ /*
12
+ * Document-class: OpenCV::CvContourTree
13
+ *
14
+ * Contour tree
15
+ *
16
+ * @see CvContour#create_tree
17
+ */
18
+ __NAMESPACE_BEGIN_OPENCV
19
+ __NAMESPACE_BEGIN_CVCONTOURTREE
20
+
21
+ VALUE rb_klass;
22
+
23
+ VALUE
24
+ rb_class()
25
+ {
26
+ return rb_klass;
27
+ }
28
+
29
+ /*
30
+ * Returns the first point of the binary tree root segment
31
+ * @overload p1
32
+ * @return [CvPoint] First point of the binary tree root segment
33
+ */
34
+ VALUE
35
+ rb_p1(VALUE self)
36
+ {
37
+ return REFER_OBJECT(cCvPoint::rb_class(), &CVCONTOURTREE(self)->p1, self);
38
+ }
39
+
40
+ /*
41
+ * Returns the last point of the binary tree root segment
42
+ * @overload p2
43
+ * @return [CvPoint] Last point of the binary tree root segment
44
+ */
45
+ VALUE
46
+ rb_p2(VALUE self)
47
+ {
48
+ return REFER_OBJECT(cCvPoint::rb_class(), &CVCONTOURTREE(self)->p2, self);
49
+ }
50
+
51
+ /*
52
+ * Restores the contour from its binary tree representation.
53
+ *
54
+ * The parameter +criteria+ determines the accuracy and/or the number of tree levels
55
+ * used for reconstruction, so it is possible to build approximated contour.
56
+ * @overload contour(criteria = 0)
57
+ * @param criteria [Integer] Criteria, where to stop reconstruction
58
+ * @return [CvContour] Contour tree
59
+ * @opencv_func cvContourFromContourTree
60
+ */
61
+ VALUE
62
+ rb_contour(VALUE self, VALUE criteria)
63
+ {
64
+ VALUE storage = cCvMemStorage::new_object();
65
+ CvSeq *contour = NULL;
66
+ try {
67
+ contour = cvContourFromContourTree(CVCONTOURTREE(self), CVMEMSTORAGE(storage),
68
+ VALUE_TO_CVTERMCRITERIA(criteria));
69
+ }
70
+ catch (cv::Exception& e) {
71
+ raise_cverror(e);
72
+ }
73
+ return cCvSeq::new_sequence(cCvContour::rb_class(), contour, cCvPoint::rb_class(), storage);
74
+ }
75
+
76
+ void
77
+ init_ruby_class()
78
+ {
79
+ #if 0
80
+ // For documentation using YARD
81
+ VALUE opencv = rb_define_module("OpenCV");
82
+ VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
83
+ #endif
84
+ if (rb_klass)
85
+ return;
86
+ VALUE opencv = rb_module_opencv();
87
+ VALUE cvseq = cCvSeq::rb_class();
88
+
89
+ rb_klass = rb_define_class_under(opencv, "CvContourTree", cvseq);
90
+ rb_define_method(rb_klass, "p1", RUBY_METHOD_FUNC(rb_p1), 0);
91
+ rb_define_method(rb_klass, "p2", RUBY_METHOD_FUNC(rb_p2), 0);
92
+ rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 1);
93
+ }
94
+
95
+ __NAMESPACE_END_CVCONTOURTREE
96
+ __NAMESPACE_END_OPENCV
@@ -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 init_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,92 @@
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 defect
15
+ */
16
+ __NAMESPACE_BEGIN_OPENCV
17
+ __NAMESPACE_BEGIN_CVCONVEXITYDEFECT
18
+
19
+ VALUE rb_klass;
20
+
21
+ VALUE
22
+ rb_class()
23
+ {
24
+ return rb_klass;
25
+ }
26
+
27
+ /*
28
+ * Returns the point of the contour where the defect begins
29
+ * @overload start
30
+ * @return [CvPoint] Start point of the contour
31
+ */
32
+ VALUE
33
+ rb_start(VALUE self)
34
+ {
35
+ return cCvPoint::new_object(*CVCONVEXITYDEFECT(self)->start);
36
+ }
37
+
38
+ /*
39
+ * Returns the point of the contour where the defect ends
40
+ * @overload end
41
+ * @return [CvPoint] End point of the contour
42
+ */
43
+ VALUE
44
+ rb_end(VALUE self)
45
+ {
46
+ return cCvPoint::new_object(*CVCONVEXITYDEFECT(self)->end);
47
+ }
48
+
49
+ /*
50
+ * Returns the farthest from the convex hull point within the defect
51
+ * @overload depth_point
52
+ * @return [CvPoint] The farthest from the convex hull point within the defect
53
+ */
54
+ VALUE
55
+ rb_depth_point(VALUE self)
56
+ {
57
+ return cCvPoint::new_object(*CVCONVEXITYDEFECT(self)->depth_point);
58
+ }
59
+
60
+ /*
61
+ * Returns distance between the farthest point and the convex hull
62
+ * @overload depth
63
+ * @return [Number] Distance between the farthest point and the convex hull
64
+ */
65
+ VALUE
66
+ rb_depth(VALUE self)
67
+ {
68
+ return rb_float_new(CVCONVEXITYDEFECT(self)->depth);
69
+ }
70
+
71
+ void
72
+ init_ruby_class()
73
+ {
74
+ #if 0
75
+ // For documentation using YARD
76
+ VALUE opencv = rb_define_module("OpenCV");
77
+ #endif
78
+
79
+ if (rb_klass)
80
+ return;
81
+
82
+ VALUE opencv = rb_module_opencv();
83
+
84
+ rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
85
+ rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
86
+ rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
87
+ rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
88
+ rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
89
+ }
90
+
91
+ __NAMESPACE_END_CVCONVEXITYDEFECT
92
+ __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 init_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,115 @@
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
+ * OpenCV errors
15
+ */
16
+
17
+ __NAMESPACE_BEGIN_OPENCV
18
+ __NAMESPACE_BEGIN_CVERROR
19
+
20
+ st_table *cv_error = st_init_numtable();
21
+
22
+ VALUE rb_klass;
23
+
24
+ void
25
+ REGISTER_CVERROR(const char* object_name, int error_code)
26
+ {
27
+ st_insert(cv_error, (st_data_t)error_code,
28
+ (st_data_t)rb_define_class_under(rb_module_opencv(), object_name, rb_klass));
29
+ }
30
+
31
+ VALUE
32
+ rb_class()
33
+ {
34
+ return rb_klass;
35
+ }
36
+
37
+ VALUE
38
+ by_code(int error_code)
39
+ {
40
+ VALUE klass = 0;
41
+ st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
42
+ return klass ? klass : rb_eStandardError;
43
+ }
44
+
45
+ void
46
+ raise(cv::Exception e)
47
+ {
48
+ rb_raise(by_code(e.code), "%s", e.what());
49
+ }
50
+
51
+ void
52
+ init_ruby_class()
53
+ {
54
+ #if 0
55
+ // For documentation using YARD
56
+ VALUE opencv = rb_define_module("OpenCV");
57
+ #endif
58
+
59
+ if (rb_klass)
60
+ return;
61
+
62
+ VALUE opencv = rb_module_opencv();
63
+ rb_klass = rb_define_class_under(opencv, "CvError", rb_eStandardError);
64
+ REGISTER_CVERROR("CvStsBackTrace", CV_StsBackTrace);
65
+ REGISTER_CVERROR("CvStsError", CV_StsError);
66
+ REGISTER_CVERROR("CvStsInternal", CV_StsInternal);
67
+ REGISTER_CVERROR("CvStsNoMem", CV_StsNoMem);
68
+ REGISTER_CVERROR("CvStsBadArg", CV_StsBadArg);
69
+ REGISTER_CVERROR("CvStsBadFunc", CV_StsBadFunc);
70
+ REGISTER_CVERROR("CvStsNoConv", CV_StsNoConv);
71
+ REGISTER_CVERROR("CvStsAutoTrace", CV_StsAutoTrace);
72
+ REGISTER_CVERROR("CvHeaderIsNull", CV_HeaderIsNull);
73
+ REGISTER_CVERROR("CvBadImageSize", CV_BadImageSize);
74
+ REGISTER_CVERROR("CvBadOffset", CV_BadOffset);
75
+ REGISTER_CVERROR("CvBadDataPtr", CV_BadDataPtr);
76
+ REGISTER_CVERROR("CvBadStep", CV_BadStep);
77
+ REGISTER_CVERROR("CvBadModelOrChSeq", CV_BadModelOrChSeq);
78
+ REGISTER_CVERROR("CvBadNumChannels", CV_BadNumChannels);
79
+ REGISTER_CVERROR("CvBadNumChannel1U", CV_BadNumChannel1U);
80
+ REGISTER_CVERROR("CvBadDepth", CV_BadDepth);
81
+ REGISTER_CVERROR("CvBadAlphaChannel", CV_BadAlphaChannel);
82
+ REGISTER_CVERROR("CvBadOrder", CV_BadOrder);
83
+ REGISTER_CVERROR("CvBadOrigin", CV_BadOrigin);
84
+ REGISTER_CVERROR("CvBadAlign", CV_BadAlign);
85
+ REGISTER_CVERROR("CvBadCallBack", CV_BadCallBack);
86
+ REGISTER_CVERROR("CvBadTileSize", CV_BadTileSize);
87
+ REGISTER_CVERROR("CvBadCOI", CV_BadCOI);
88
+ REGISTER_CVERROR("CvBadROISize", CV_BadROISize);
89
+ REGISTER_CVERROR("CvMaskIsTiled", CV_MaskIsTiled);
90
+ REGISTER_CVERROR("CvStsNullPtr", CV_StsNullPtr);
91
+ REGISTER_CVERROR("CvStsVecLengthErr", CV_StsVecLengthErr);
92
+ REGISTER_CVERROR("CvStsFilterStructContentErr", CV_StsFilterStructContentErr);
93
+ REGISTER_CVERROR("CvStsKernelStructContentErr", CV_StsKernelStructContentErr);
94
+ REGISTER_CVERROR("CvStsFilterOffsetErr", CV_StsFilterOffsetErr);
95
+ REGISTER_CVERROR("CvStsBadSize", CV_StsBadSize);
96
+ REGISTER_CVERROR("CvStsDivByZero", CV_StsDivByZero);
97
+ REGISTER_CVERROR("CvStsInplaceNotSupported", CV_StsInplaceNotSupported);
98
+ REGISTER_CVERROR("CvStsObjectNotFound", CV_StsObjectNotFound);
99
+ REGISTER_CVERROR("CvStsUnmatchedFormats", CV_StsUnmatchedFormats);
100
+ REGISTER_CVERROR("CvStsBadFlag", CV_StsBadFlag);
101
+ REGISTER_CVERROR("CvStsBadPoint", CV_StsBadPoint);
102
+ REGISTER_CVERROR("CvStsBadMask", CV_StsBadMask);
103
+ REGISTER_CVERROR("CvStsUnmatchedSizes", CV_StsUnmatchedSizes);
104
+ REGISTER_CVERROR("CvStsUnsupportedFormat", CV_StsUnsupportedFormat);
105
+ REGISTER_CVERROR("CvStsOutOfRange", CV_StsOutOfRange);
106
+ REGISTER_CVERROR("CvStsParseError", CV_StsParseError);
107
+ REGISTER_CVERROR("CvStsNotImplemented", CV_StsNotImplemented);
108
+ REGISTER_CVERROR("CvStsBadMemBlock", CV_StsBadMemBlock);
109
+ REGISTER_CVERROR("CvStsAssert", CV_StsAssert);
110
+ REGISTER_CVERROR("CvGpuNotSupported", CV_GpuNotSupported);
111
+ REGISTER_CVERROR("CvGpuApiCallError", CV_GpuApiCallError);
112
+ }
113
+
114
+ __NAMESPACE_END_CVERROR
115
+ __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 init_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