ruby-opencv 0.0.8.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/Gemfile +8 -0
  2. data/History.txt +5 -0
  3. data/License.txt +30 -0
  4. data/Manifest.txt +229 -0
  5. data/README.rdoc +149 -0
  6. data/Rakefile +32 -0
  7. data/examples/alpha_blend.rb +21 -0
  8. data/examples/box.png +0 -0
  9. data/examples/box_in_scene.png +0 -0
  10. data/examples/contours/bitmap-contours-with-labels.png +0 -0
  11. data/examples/contours/bitmap-contours.png +0 -0
  12. data/examples/contours/bounding-box-detect-canny.rb +62 -0
  13. data/examples/contours/contour_retrieval_modes.rb +139 -0
  14. data/examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg +0 -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/GPATH +0 -0
  36. data/ext/opencv/GSYMS +0 -0
  37. data/ext/opencv/curve.cpp +112 -0
  38. data/ext/opencv/curve.h +34 -0
  39. data/ext/opencv/cvavgcomp.cpp +67 -0
  40. data/ext/opencv/cvavgcomp.h +39 -0
  41. data/ext/opencv/cvbox2d.cpp +197 -0
  42. data/ext/opencv/cvbox2d.h +61 -0
  43. data/ext/opencv/cvcapture.cpp +499 -0
  44. data/ext/opencv/cvcapture.h +72 -0
  45. data/ext/opencv/cvchain.cpp +233 -0
  46. data/ext/opencv/cvchain.h +46 -0
  47. data/ext/opencv/cvcircle32f.cpp +116 -0
  48. data/ext/opencv/cvcircle32f.h +52 -0
  49. data/ext/opencv/cvcondensation.cpp +282 -0
  50. data/ext/opencv/cvcondensation.h +49 -0
  51. data/ext/opencv/cvconnectedcomp.cpp +143 -0
  52. data/ext/opencv/cvconnectedcomp.h +49 -0
  53. data/ext/opencv/cvcontour.cpp +296 -0
  54. data/ext/opencv/cvcontour.h +48 -0
  55. data/ext/opencv/cvcontourtree.cpp +91 -0
  56. data/ext/opencv/cvcontourtree.h +41 -0
  57. data/ext/opencv/cvconvexitydefect.cpp +103 -0
  58. data/ext/opencv/cvconvexitydefect.h +42 -0
  59. data/ext/opencv/cverror.cpp +159 -0
  60. data/ext/opencv/cverror.h +28 -0
  61. data/ext/opencv/cvfeaturetree.cpp +125 -0
  62. data/ext/opencv/cvfeaturetree.h +55 -0
  63. data/ext/opencv/cvfont.cpp +208 -0
  64. data/ext/opencv/cvfont.h +64 -0
  65. data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
  66. data/ext/opencv/cvhaarclassifiercascade.h +39 -0
  67. data/ext/opencv/cvhistogram.cpp +546 -0
  68. data/ext/opencv/cvhistogram.h +73 -0
  69. data/ext/opencv/cvhumoments.cpp +139 -0
  70. data/ext/opencv/cvhumoments.h +51 -0
  71. data/ext/opencv/cvline.cpp +154 -0
  72. data/ext/opencv/cvline.h +54 -0
  73. data/ext/opencv/cvmat.cpp +5848 -0
  74. data/ext/opencv/cvmat.h +284 -0
  75. data/ext/opencv/cvmatnd.cpp +44 -0
  76. data/ext/opencv/cvmatnd.h +28 -0
  77. data/ext/opencv/cvmemstorage.cpp +68 -0
  78. data/ext/opencv/cvmemstorage.h +53 -0
  79. data/ext/opencv/cvmoments.cpp +287 -0
  80. data/ext/opencv/cvmoments.h +75 -0
  81. data/ext/opencv/cvpoint.cpp +228 -0
  82. data/ext/opencv/cvpoint.h +64 -0
  83. data/ext/opencv/cvpoint2d32f.cpp +211 -0
  84. data/ext/opencv/cvpoint2d32f.h +63 -0
  85. data/ext/opencv/cvpoint3d32f.cpp +245 -0
  86. data/ext/opencv/cvpoint3d32f.h +66 -0
  87. data/ext/opencv/cvrect.cpp +333 -0
  88. data/ext/opencv/cvrect.h +79 -0
  89. data/ext/opencv/cvscalar.cpp +236 -0
  90. data/ext/opencv/cvscalar.h +71 -0
  91. data/ext/opencv/cvseq.cpp +599 -0
  92. data/ext/opencv/cvseq.h +74 -0
  93. data/ext/opencv/cvsize.cpp +221 -0
  94. data/ext/opencv/cvsize.h +65 -0
  95. data/ext/opencv/cvsize2d32f.cpp +209 -0
  96. data/ext/opencv/cvsize2d32f.h +64 -0
  97. data/ext/opencv/cvslice.cpp +120 -0
  98. data/ext/opencv/cvslice.h +61 -0
  99. data/ext/opencv/cvsparsemat.cpp +44 -0
  100. data/ext/opencv/cvsparsemat.h +28 -0
  101. data/ext/opencv/cvsurfparams.cpp +199 -0
  102. data/ext/opencv/cvsurfparams.h +58 -0
  103. data/ext/opencv/cvsurfpoint.cpp +223 -0
  104. data/ext/opencv/cvsurfpoint.h +52 -0
  105. data/ext/opencv/cvtermcriteria.cpp +192 -0
  106. data/ext/opencv/cvtermcriteria.h +71 -0
  107. data/ext/opencv/cvtwopoints.cpp +116 -0
  108. data/ext/opencv/cvtwopoints.h +51 -0
  109. data/ext/opencv/cvutils.cpp +194 -0
  110. data/ext/opencv/cvutils.h +29 -0
  111. data/ext/opencv/cvvideowriter.cpp +137 -0
  112. data/ext/opencv/cvvideowriter.h +43 -0
  113. data/ext/opencv/gui.cpp +68 -0
  114. data/ext/opencv/gui.h +30 -0
  115. data/ext/opencv/iplconvkernel.cpp +192 -0
  116. data/ext/opencv/iplconvkernel.h +71 -0
  117. data/ext/opencv/iplimage.cpp +644 -0
  118. data/ext/opencv/iplimage.h +73 -0
  119. data/ext/opencv/lib/opencv.rb +3 -0
  120. data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
  121. data/ext/opencv/lib/opencv/version.rb +3 -0
  122. data/ext/opencv/mouseevent.cpp +181 -0
  123. data/ext/opencv/mouseevent.h +56 -0
  124. data/ext/opencv/opencv.cpp +722 -0
  125. data/ext/opencv/opencv.h +400 -0
  126. data/ext/opencv/pointset.cpp +274 -0
  127. data/ext/opencv/pointset.h +68 -0
  128. data/ext/opencv/trackbar.cpp +121 -0
  129. data/ext/opencv/trackbar.h +69 -0
  130. data/ext/opencv/window.cpp +357 -0
  131. data/ext/opencv/window.h +66 -0
  132. data/extconf.rb +75 -0
  133. data/images/CvMat_sobel.png +0 -0
  134. data/images/CvMat_sub_rect.png +0 -0
  135. data/images/CvSeq_relationmap.png +0 -0
  136. data/images/face_detect_from_lena.jpg +0 -0
  137. data/ruby-opencv.gemspec +43 -0
  138. data/test/helper.rb +166 -0
  139. data/test/log.txt +55 -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. data/test/videowriter_result.avi +0 -0
  230. metadata +394 -0
@@ -0,0 +1,66 @@
1
+ /************************************************************
2
+
3
+ window.h -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005-2006 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #ifndef RUBY_OPENCV_GUI_H
11
+ #include "gui.h"
12
+ #endif
13
+
14
+ #ifndef RUBY_OPENCV_GUI_WINDOW_H
15
+ #define RUBY_OPENCV_GUI_WINDOW_H
16
+
17
+ #include "opencv.h"
18
+ #define __NAMESPACE_BEGIN_WINDOW namespace cWindow {
19
+ #define __NAMESPACE_END_WINDOW }
20
+
21
+ __NAMESPACE_BEGIN_OPENCV
22
+ __NAMESPACE_BEGIN_GUI
23
+
24
+ typedef struct Window {
25
+ VALUE name;
26
+ VALUE image;
27
+ VALUE trackbars;
28
+ VALUE blocks;
29
+ } Window;
30
+
31
+ __NAMESPACE_BEGIN_WINDOW
32
+
33
+ void define_ruby_class();
34
+
35
+ VALUE rb_allocate(VALUE klass);
36
+
37
+ void window_mark(void *ptr);
38
+ void window_free(void *ptr);
39
+ VALUE rb_alive_q(VALUE self);
40
+ VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
41
+ VALUE rb_destroy(VALUE self);
42
+ VALUE rb_destroy_all(VALUE klass);
43
+ VALUE rb_resize(int argc, VALUE *argv, VALUE self);
44
+ VALUE rb_move(int argc, VALUE *argv, VALUE self);
45
+ VALUE rb_show_image(VALUE self, VALUE img);
46
+ VALUE rb_set_trackbar(int argc, VALUE *argv, VALUE self);
47
+ VALUE rb_set_mouse_callback(int argc, VALUE* argv, VALUE self);
48
+
49
+ inline Window*
50
+ WINDOW(VALUE object) {
51
+ Window *ptr;
52
+ Data_Get_Struct(object, Window, ptr);
53
+ return ptr;
54
+ }
55
+
56
+ inline const char*
57
+ GET_WINDOW_NAME(VALUE object) {
58
+ return StringValueCStr(WINDOW(object)->name);
59
+ }
60
+
61
+ __NAMESPACE_END_WINDOW
62
+ __NAMESPACE_END_GUI
63
+ __NAMESPACE_END_OPENCV
64
+
65
+ #endif // RUBY_OPENCV_GUI_WINDOW_H
66
+
data/extconf.rb ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ require "mkmf"
3
+
4
+ def cv_version_suffix(incdir)
5
+ major, minor, subminor = nil, nil, nil
6
+ open("#{incdir}/opencv2/core/version.hpp", 'r') { |f|
7
+ f.read.lines.each { |line|
8
+ major = $1.to_s if line =~ /\A#define\s+CV_MAJOR_VERSION\s+(\d+)\s*\Z/
9
+ minor = $1.to_s if line =~ /\A#define\s+CV_MINOR_VERSION\s+(\d+)\s*\Z/
10
+ subminor = $1.to_s if line =~ /\A#define\s+CV_SUBMINOR_VERSION\s+(\d+)\s*\Z/
11
+ }
12
+ }
13
+ major + minor + subminor
14
+ end
15
+
16
+ incdir, libdir = dir_config("opencv", "/usr/local/include", "/usr/local/lib")
17
+ dir_config("libxml2", "/usr/include", "/usr/lib")
18
+
19
+ opencv_headers = ["opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h",
20
+ "opencv2/imgproc/imgproc.hpp", "opencv2/video/tracking.hpp", "opencv2/features2d/features2d.hpp",
21
+ "opencv2/flann/flann.hpp", "opencv2/calib3d/calib3d.hpp", "opencv2/objdetect/objdetect.hpp",
22
+ "opencv2/legacy/compat.hpp", "opencv2/legacy/legacy.hpp", "opencv2/highgui/highgui_c.h",
23
+ "opencv2/highgui/highgui.hpp", "opencv2/photo/photo.hpp", "opencv2/nonfree/nonfree.hpp"]
24
+
25
+ opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_features2d",
26
+ "opencv_flann", "opencv_gpu", "opencv_highgui", "opencv_imgproc",
27
+ "opencv_legacy", "opencv_ml", "opencv_objdetect", "opencv_video",
28
+ "opencv_photo", "opencv_nonfree"]
29
+
30
+
31
+ puts ">> Check the required libraries..."
32
+ case CONFIG["arch"]
33
+ when /mswin32/
34
+ suffix = cv_version_suffix(incdir)
35
+ opencv_libraries.map! {|lib| lib + suffix }
36
+ have_library("msvcrt")
37
+ opencv_libraries.each {|lib|
38
+ raise "#{lib}.lib not found." unless have_library(lib)
39
+ }
40
+ $CFLAGS << ' /EHsc'
41
+ when /mingw32/
42
+ suffix = cv_version_suffix(incdir)
43
+ opencv_libraries.map! {|lib| lib + suffix }
44
+ have_library("msvcrt")
45
+ opencv_libraries.each {|lib|
46
+ raise "lib#{lib} not found." unless have_library(lib)
47
+ }
48
+ else
49
+ opencv_libraries.each {|lib|
50
+ raise "lib#{lib} not found." unless have_library(lib)
51
+ }
52
+ have_library("stdc++")
53
+ end
54
+
55
+ # Check the required headers
56
+ puts ">> Check the required headers..."
57
+ opencv_headers.each {|header|
58
+ unless have_header(header)
59
+ if CONFIG["arch"] =~ /mswin32/ and File.exists? "#{incdir}/#{header}"
60
+ # In mswin32, have_header('opencv2/nonfree/nonfree.hpp') fails because of a syntax problem.
61
+ warn "warning: #{header} found but `have_header` failed."
62
+ $defs << "-DHAVE_#{header.tr_cpp}"
63
+ else
64
+ raise "#{header} not found."
65
+ end
66
+ end
67
+ }
68
+ have_header("stdarg.h")
69
+
70
+ # Quick fix for 1.8.7
71
+ $CFLAGS << " -I#{File.dirname(__FILE__)}/ext/opencv"
72
+
73
+ # Create Makefile
74
+ create_makefile("opencv", "./ext/opencv")
75
+
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "ruby-opencv"
5
+ s.version = "0.0.8.pre"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["lsxi", "ser1zw", "pcting"]
9
+ s.date = "2013-01-26"
10
+ s.description = "OpenCV wrapper for Ruby"
11
+ s.email = ["masakazu.yonekura@gmail.com", "azariahsawtikes@gmail.com", "pcting@gmail.com"]
12
+ s.extensions = ["extconf.rb"]
13
+ s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "examples/matching_to_many_images/train/trainImages.txt"]
14
+ s.files = ["Gemfile", "History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "examples/alpha_blend.rb", "examples/box.png", "examples/box_in_scene.png", "examples/contours/bitmap-contours-with-labels.png", "examples/contours/bitmap-contours.png", "examples/contours/bounding-box-detect-canny.rb", "examples/contours/contour_retrieval_modes.rb", "examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg", "examples/contours/rotated-boxes.jpg", "examples/convexhull.rb", "examples/face_detect.rb", "examples/find_obj.rb", "examples/houghcircle.rb", "examples/inpaint.png", "examples/inpaint.rb", "examples/lenna-rotated.jpg", "examples/lenna.jpg", "examples/match_kdtree.rb", "examples/matching_to_many_images.rb", "examples/matching_to_many_images/query.png", "examples/matching_to_many_images/train/1.png", "examples/matching_to_many_images/train/2.png", "examples/matching_to_many_images/train/3.png", "examples/matching_to_many_images/train/trainImages.txt", "examples/paint.rb", "examples/snake.rb", "examples/stuff.jpg", "examples/tiffany.jpg", "ext/opencv/GPATH", "ext/opencv/GSYMS", "ext/opencv/curve.cpp", "ext/opencv/curve.h", "ext/opencv/cvavgcomp.cpp", "ext/opencv/cvavgcomp.h", "ext/opencv/cvbox2d.cpp", "ext/opencv/cvbox2d.h", "ext/opencv/cvcapture.cpp", "ext/opencv/cvcapture.h", "ext/opencv/cvchain.cpp", "ext/opencv/cvchain.h", "ext/opencv/cvcircle32f.cpp", "ext/opencv/cvcircle32f.h", "ext/opencv/cvcondensation.cpp", "ext/opencv/cvcondensation.h", "ext/opencv/cvconnectedcomp.cpp", "ext/opencv/cvconnectedcomp.h", "ext/opencv/cvcontour.cpp", "ext/opencv/cvcontour.h", "ext/opencv/cvcontourtree.cpp", "ext/opencv/cvcontourtree.h", "ext/opencv/cvconvexitydefect.cpp", "ext/opencv/cvconvexitydefect.h", "ext/opencv/cverror.cpp", "ext/opencv/cverror.h", "ext/opencv/cvfeaturetree.cpp", "ext/opencv/cvfeaturetree.h", "ext/opencv/cvfont.cpp", "ext/opencv/cvfont.h", "ext/opencv/cvhaarclassifiercascade.cpp", "ext/opencv/cvhaarclassifiercascade.h", "ext/opencv/cvhistogram.cpp", "ext/opencv/cvhistogram.h", "ext/opencv/cvhumoments.cpp", "ext/opencv/cvhumoments.h", "ext/opencv/cvline.cpp", "ext/opencv/cvline.h", "ext/opencv/cvmat.cpp", "ext/opencv/cvmat.h", "ext/opencv/cvmatnd.cpp", "ext/opencv/cvmatnd.h", "ext/opencv/cvmemstorage.cpp", "ext/opencv/cvmemstorage.h", "ext/opencv/cvmoments.cpp", "ext/opencv/cvmoments.h", "ext/opencv/cvpoint.cpp", "ext/opencv/cvpoint.h", "ext/opencv/cvpoint2d32f.cpp", "ext/opencv/cvpoint2d32f.h", "ext/opencv/cvpoint3d32f.cpp", "ext/opencv/cvpoint3d32f.h", "ext/opencv/cvrect.cpp", "ext/opencv/cvrect.h", "ext/opencv/cvscalar.cpp", "ext/opencv/cvscalar.h", "ext/opencv/cvseq.cpp", "ext/opencv/cvseq.h", "ext/opencv/cvsize.cpp", "ext/opencv/cvsize.h", "ext/opencv/cvsize2d32f.cpp", "ext/opencv/cvsize2d32f.h", "ext/opencv/cvslice.cpp", "ext/opencv/cvslice.h", "ext/opencv/cvsparsemat.cpp", "ext/opencv/cvsparsemat.h", "ext/opencv/cvsurfparams.cpp", "ext/opencv/cvsurfparams.h", "ext/opencv/cvsurfpoint.cpp", "ext/opencv/cvsurfpoint.h", "ext/opencv/cvtermcriteria.cpp", "ext/opencv/cvtermcriteria.h", "ext/opencv/cvtwopoints.cpp", "ext/opencv/cvtwopoints.h", "ext/opencv/cvutils.cpp", "ext/opencv/cvutils.h", "ext/opencv/cvvideowriter.cpp", "ext/opencv/cvvideowriter.h", "ext/opencv/gui.cpp", "ext/opencv/gui.h", "ext/opencv/iplconvkernel.cpp", "ext/opencv/iplconvkernel.h", "ext/opencv/iplimage.cpp", "ext/opencv/iplimage.h", "ext/opencv/lib/opencv.rb", "ext/opencv/lib/opencv/psyched_yaml.rb", "ext/opencv/lib/opencv/version.rb", "ext/opencv/mouseevent.cpp", "ext/opencv/mouseevent.h", "ext/opencv/opencv.cpp", "ext/opencv/opencv.h", "ext/opencv/pointset.cpp", "ext/opencv/pointset.h", "ext/opencv/trackbar.cpp", "ext/opencv/trackbar.h", "ext/opencv/window.cpp", "ext/opencv/window.h", "extconf.rb", "images/CvMat_sobel.png", "images/CvMat_sub_rect.png", "images/CvSeq_relationmap.png", "images/face_detect_from_lena.jpg", "ruby-opencv.gemspec", "test/helper.rb", "test/log.txt", "test/runner.rb", "test/samples/airplane.jpg", "test/samples/baboon.jpg", "test/samples/baboon200.jpg", "test/samples/baboon200_rotated.jpg", "test/samples/blank0.jpg", "test/samples/blank1.jpg", "test/samples/blank2.jpg", "test/samples/blank3.jpg", "test/samples/blank4.jpg", "test/samples/blank5.jpg", "test/samples/blank6.jpg", "test/samples/blank7.jpg", "test/samples/blank8.jpg", "test/samples/blank9.jpg", "test/samples/cat.jpg", "test/samples/chessboard.jpg", "test/samples/contours.jpg", "test/samples/fruits.jpg", "test/samples/haarcascade_frontalface_alt.xml.gz", "test/samples/inpaint-mask.bmp", "test/samples/lena-256x256.jpg", "test/samples/lena-32x32.jpg", "test/samples/lena-eyes.jpg", "test/samples/lena-inpaint.jpg", "test/samples/lena.jpg", "test/samples/lines.jpg", "test/samples/messy0.jpg", "test/samples/messy1.jpg", "test/samples/movie_sample.avi", "test/samples/one_way_train_0000.jpg", "test/samples/one_way_train_0001.jpg", "test/samples/partially_blank0.jpg", "test/samples/partially_blank1.jpg", "test/samples/smooth0.jpg", "test/samples/smooth1.jpg", "test/samples/smooth2.jpg", "test/samples/smooth3.jpg", "test/samples/smooth4.jpg", "test/samples/smooth5.jpg", "test/samples/smooth6.jpg", "test/samples/str-cv-rotated.jpg", "test/samples/str-cv.jpg", "test/samples/str-ov.jpg", "test/samples/stuff.jpg", "test/test_curve.rb", "test/test_cvavgcomp.rb", "test/test_cvbox2d.rb", "test/test_cvcapture.rb", "test/test_cvchain.rb", "test/test_cvcircle32f.rb", "test/test_cvconnectedcomp.rb", "test/test_cvcontour.rb", "test/test_cvcontourtree.rb", "test/test_cverror.rb", "test/test_cvfeaturetree.rb", "test/test_cvfont.rb", "test/test_cvhaarclassifiercascade.rb", "test/test_cvhistogram.rb", "test/test_cvhumoments.rb", "test/test_cvline.rb", "test/test_cvmat.rb", "test/test_cvmat_drawing.rb", "test/test_cvmat_dxt.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvmat_matching.rb", "test/test_cvmoments.rb", "test/test_cvpoint.rb", "test/test_cvpoint2d32f.rb", "test/test_cvpoint3d32f.rb", "test/test_cvrect.rb", "test/test_cvscalar.rb", "test/test_cvseq.rb", "test/test_cvsize.rb", "test/test_cvsize2d32f.rb", "test/test_cvslice.rb", "test/test_cvsurfparams.rb", "test/test_cvsurfpoint.rb", "test/test_cvtermcriteria.rb", "test/test_cvtwopoints.rb", "test/test_cvvideowriter.rb", "test/test_iplconvkernel.rb", "test/test_iplimage.rb", "test/test_mouseevent.rb", "test/test_opencv.rb", "test/test_pointset.rb", "test/test_preliminary.rb", "test/test_trackbar.rb", "test/test_window.rb", "test/videowriter_result.avi"]
15
+ s.homepage = "https://github.com/ruby-opencv/ruby-opencv/"
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = "ruby-opencv"
19
+ s.rubygems_version = "1.8.24"
20
+ s.summary = "OpenCV wrapper for Ruby"
21
+ s.test_files = ["test/test_cvcontourtree.rb", "test/test_iplconvkernel.rb", "test/test_cvsize2d32f.rb", "test/test_cvconnectedcomp.rb", "test/test_cvcontour.rb", "test/test_cvslice.rb", "test/test_cvmat_matching.rb", "test/test_trackbar.rb", "test/test_cvpoint3d32f.rb", "test/test_cvpoint2d32f.rb", "test/test_cvcapture.rb", "test/test_cvfont.rb", "test/test_cvhumoments.rb", "test/test_cvmat_dxt.rb", "test/test_cvbox2d.rb", "test/test_iplimage.rb", "test/test_preliminary.rb", "test/test_cvmat_drawing.rb", "test/test_cvsurfparams.rb", "test/test_cvcircle32f.rb", "test/test_pointset.rb", "test/test_cvmat.rb", "test/test_cvhistogram.rb", "test/test_cverror.rb", "test/test_cvtermcriteria.rb", "test/test_cvmoments.rb", "test/test_cvchain.rb", "test/test_cvpoint.rb", "test/test_cvavgcomp.rb", "test/test_cvrect.rb", "test/test_cvvideowriter.rb", "test/test_curve.rb", "test/test_window.rb", "test/test_cvline.rb", "test/test_opencv.rb", "test/test_cvfeaturetree.rb", "test/test_cvseq.rb", "test/test_cvsize.rb", "test/test_mouseevent.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvtwopoints.rb", "test/test_cvscalar.rb", "test/test_cvsurfpoint.rb", "test/test_cvhaarclassifiercascade.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
28
+ s.add_development_dependency(%q<rake-compiler>, [">= 0"])
29
+ s.add_development_dependency(%q<hoe-gemspec>, [">= 0"])
30
+ s.add_development_dependency(%q<hoe>, ["~> 3.5"])
31
+ else
32
+ s.add_dependency(%q<rdoc>, ["~> 3.10"])
33
+ s.add_dependency(%q<rake-compiler>, [">= 0"])
34
+ s.add_dependency(%q<hoe-gemspec>, [">= 0"])
35
+ s.add_dependency(%q<hoe>, ["~> 3.5"])
36
+ end
37
+ else
38
+ s.add_dependency(%q<rdoc>, ["~> 3.10"])
39
+ s.add_dependency(%q<rake-compiler>, [">= 0"])
40
+ s.add_dependency(%q<hoe-gemspec>, [">= 0"])
41
+ s.add_dependency(%q<hoe>, ["~> 3.5"])
42
+ end
43
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+ require 'digest/md5'
5
+ require 'opencv'
6
+ include OpenCV
7
+
8
+ class OpenCVTestCase < Test::Unit::TestCase
9
+ SAMPLE_DIR = File.expand_path(File.dirname(__FILE__)) + '/samples/'
10
+ FILENAME_CAT = SAMPLE_DIR + 'cat.jpg'
11
+ FILENAME_LENA256x256 = SAMPLE_DIR + 'lena-256x256.jpg'
12
+ FILENAME_LENA32x32 = SAMPLE_DIR + 'lena-32x32.jpg'
13
+ FILENAME_LENA_EYES = File.expand_path(File.dirname(__FILE__)) + '/samples/lena-eyes.jpg'
14
+ FILENAME_FRUITS = SAMPLE_DIR + 'fruits.jpg'
15
+ FILENAME_CONTOURS = File.expand_path(File.dirname(__FILE__)) + '/samples/contours.jpg'
16
+ FILENAME_CHESSBOARD = SAMPLE_DIR + 'chessboard.jpg'
17
+ HAARCASCADE_FRONTALFACE_ALT = SAMPLE_DIR + 'haarcascade_frontalface_alt.xml.gz'
18
+ AVI_SAMPLE = SAMPLE_DIR + 'movie_sample.avi'
19
+
20
+ DUMMY_OBJ = Digest::MD5.new # dummy object for argument type check test
21
+
22
+ def snap(*images)
23
+ n = -1
24
+ images.map! { |val|
25
+ n += 1
26
+ if val.is_a? Hash
27
+ val
28
+ elsif val.is_a? Array
29
+ {:title => val[0], :image => val[1] }
30
+ else
31
+ {:title => "snap-#{n}", :image => val }
32
+ end
33
+ }
34
+
35
+ pos = CvPoint.new(0, 0)
36
+ images.each { |img|
37
+ w = GUI::Window.new(img[:title])
38
+ w.show(img[:image])
39
+ w.move(pos)
40
+ pos.x += img[:image].width
41
+ if pos.x > 800
42
+ pos.y += img[:image].height
43
+ pos.x = 0
44
+ end
45
+ }
46
+
47
+ GUI::wait_key
48
+ GUI::Window::destroy_all
49
+ end
50
+
51
+ def hash_img(img)
52
+ # Compute a hash for an image, useful for image comparisons
53
+ Digest::MD5.hexdigest(img.data)
54
+ end
55
+
56
+ unless Test::Unit::TestCase.instance_methods.map {|m| m.to_sym }.include? :assert_false
57
+ def assert_false(actual, message = nil)
58
+ assert_equal(false, actual, message)
59
+ end
60
+ end
61
+
62
+ alias original_assert_in_delta assert_in_delta
63
+
64
+ def assert_cvscalar_equal(expected, actual, message = nil)
65
+ assert_equal(CvScalar, actual.class, message)
66
+ assert_array_equal(expected.to_ary, actual.to_ary, message)
67
+ end
68
+
69
+ def assert_array_equal(expected, actual, message = nil)
70
+ assert_equal(expected.size, actual.size, message)
71
+ expected.zip(actual) { |e, a|
72
+ assert_equal(e, a, message)
73
+ }
74
+ end
75
+
76
+ def assert_in_delta(expected, actual, delta)
77
+ if expected.is_a? CvScalar or actual.is_a? CvScalar
78
+ expected = expected.to_ary if expected.is_a? CvScalar
79
+ actual = actual.to_ary if actual.is_a? CvScalar
80
+ assert_in_delta(expected, actual ,delta)
81
+ elsif expected.is_a? Array and actual.is_a? Array
82
+ assert_equal(expected.size, actual.size)
83
+ expected.zip(actual) { |e, a|
84
+ original_assert_in_delta(e, a, delta)
85
+ }
86
+ else
87
+ original_assert_in_delta(expected, actual, delta)
88
+ end
89
+ end
90
+
91
+ def create_cvmat(height, width, depth = :cv8u, channel = 4, &block)
92
+ m = CvMat.new(height, width, depth, channel)
93
+ block = lambda { |j, i, c| CvScalar.new(*([c + 1] * channel)) } unless block_given?
94
+ count = 0
95
+ height.times { |j|
96
+ width.times { |i|
97
+ m[j, i] = block.call(j, i, count)
98
+ count += 1
99
+ }
100
+ }
101
+ m
102
+ end
103
+
104
+ def create_iplimage(width, height, depth = :cv8u, channel = 4, &block)
105
+ m = IplImage.new(width, height, depth, channel)
106
+ block = lambda { |j, i, c| CvScalar.new(*([c + 1] * channel)) } unless block_given?
107
+ count = 0
108
+ height.times { |j|
109
+ width.times { |i|
110
+ m[j, i] = block.call(j, i, count)
111
+ count += 1
112
+ }
113
+ }
114
+ m
115
+ end
116
+
117
+ def assert_each_cvscalar(actual, delta = 0, &block)
118
+ raise unless block_given?
119
+ count = 0
120
+ actual.height.times { |j|
121
+ actual.width.times { |i|
122
+ expected = block.call(j, i, count)
123
+ if delta == 0
124
+ expected = expected.to_ary if expected.is_a? CvScalar
125
+ assert_array_equal(expected, actual[j, i].to_ary)
126
+ else
127
+ assert_in_delta(expected, actual[j, i], delta)
128
+ end
129
+ count += 1
130
+ }
131
+ }
132
+ end
133
+
134
+ def print_cvmat(mat)
135
+ s = []
136
+ mat.height.times { |j|
137
+ a = []
138
+ mat.width.times { |i|
139
+ tmp = mat[j, i].to_ary.map {|m| m.to_f.round(2) }.join(',')
140
+ a << "[#{tmp}]"
141
+ }
142
+ s << a.join(' ')
143
+ }
144
+ puts s.join("\n")
145
+ end
146
+
147
+ def count_threshold(mat, threshold, &block)
148
+ n = 0
149
+ block = lambda { |a, b| a > b } unless block_given?
150
+ (mat.rows * mat.cols).times { |i|
151
+ n += 1 if block.call(mat[i][0], threshold)
152
+ }
153
+ n
154
+ end
155
+
156
+ def color_hists(mat)
157
+ hists = [0] * mat.channel
158
+ (mat.rows * mat.cols).times { |i|
159
+ hists.size.times { |c|
160
+ hists[c] += mat[i][c]
161
+ }
162
+ }
163
+ hists
164
+ end
165
+ end
166
+
data/test/log.txt ADDED
@@ -0,0 +1,55 @@
1
+ Run options:
2
+
3
+ # Running tests:
4
+
5
+ .............................................................................................................................................................F...........................................F..F.F..................F..............F..F................................................................................................................F........F.....FF....................
6
+
7
+ Finished tests in 36.260783s, 10.8382 tests/s, 761.0150 assertions/s.
8
+
9
+ 1) Failure:
10
+ test_normalize(TestCvMat) [/home/seri/Projects/ruby-opencv/test/test_cvmat.rb:2062]:
11
+ Expected 0.0 - 72130682956280530000000.0 (72130682956280530000000.0) to be < 0.001.
12
+
13
+ 2) Failure:
14
+ test_cam_shift(TestCvMat_imageprocessing) [/home/seri/Projects/ruby-opencv/test/test_cvmat_imageprocessing.rb:1725]:
15
+ FIXME: CvMat#cam_shift is not tested yet.
16
+
17
+ 3) Failure:
18
+ test_corner_eigenvv(TestCvMat_imageprocessing) [/home/seri/Projects/ruby-opencv/test/test_cvmat_imageprocessing.rb:143]:
19
+ FIXME: CvMat#corner_eigenvv is not tested yet.
20
+
21
+ 4) Failure:
22
+ test_corner_min_eigen_val(TestCvMat_imageprocessing) [/home/seri/Projects/ruby-opencv/test/test_cvmat_imageprocessing.rb:158]:
23
+ FIXME: CvMat#corner_min_eigen_val is not tested yet.
24
+
25
+ 5) Failure:
26
+ test_mean_shift(TestCvMat_imageprocessing) [/home/seri/Projects/ruby-opencv/test/test_cvmat_imageprocessing.rb:1721]:
27
+ FIXME: CvMat#mean_shift is not tested yet.
28
+
29
+ 6) Failure:
30
+ test_smooth(TestCvMat_imageprocessing) [/home/seri/Projects/ruby-opencv/test/test_cvmat_imageprocessing.rb:871]:
31
+ FIXME: Cases of CvMat#smooth(CV_BILATERAL) are not tested yet.
32
+
33
+ 7) Failure:
34
+ test_threshold(TestCvMat_imageprocessing) [/home/seri/Projects/ruby-opencv/test/test_cvmat_imageprocessing.rb:1017]:
35
+ <0> expected but was
36
+ <7.0>.
37
+
38
+ 8) Failure:
39
+ test_decode(TestIplImage) [/home/seri/Projects/ruby-opencv/test/test_iplimage.rb:90]:
40
+ <"022d2afec35e400d88c532005f243314"> expected but was
41
+ <"f661ae39bb8ba3f5e559648391c7aceb">.
42
+
43
+ 9) Failure:
44
+ test_cvt_color_funcs(TestOpenCV) [/home/seri/Projects/ruby-opencv/test/test_opencv.rb:314]:
45
+ FIXME: Most cvtColor functions are not tested yet.
46
+
47
+ 10) Failure:
48
+ test_fit_ellipse2(TestPointSet) [/home/seri/Projects/ruby-opencv/test/test_pointset.rb:41]:
49
+ Expected 63.116 - 63.1306037902832 (0.014603790283203466) to be < 0.001.
50
+
51
+ 11) Failure:
52
+ test_min_area_rect2(TestPointSet) [/home/seri/Projects/ruby-opencv/test/test_pointset.rb:105]:
53
+ Expected -8.13 - -81.8698959350586 (73.7398959350586) to be < 0.001.
54
+
55
+ 393 tests, 27595 assertions, 11 failures, 0 errors, 0 skips
data/test/runner.rb ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby; coding: utf-8-unix -*-
3
+ require 'test/unit'
4
+
5
+ src_testdir = File.dirname(File.expand_path(__FILE__))
6
+ if Test::Unit.methods.include? :setup_argv
7
+ srcdir = File.dirname(src_testdir)
8
+ Test::Unit.setup_argv {|files|
9
+ if files.empty?
10
+ [src_testdir]
11
+ else
12
+ files.map {|f|
13
+ if File.exist? "#{src_testdir}/#{f}"
14
+ "#{src_testdir}/#{f}"
15
+ elsif File.exist? "#{srcdir}/#{f}"
16
+ "#{srcdir}/#{f}"
17
+ elsif File.exist? f
18
+ f
19
+ else
20
+ raise ArgumentError, "not found: #{f}"
21
+ end
22
+ }
23
+ end
24
+ }
25
+ elsif Test::Unit.constants.map {|c| c.to_sym }.include? :AutoRunner
26
+ Test::Unit::AutoRunner.run(true, src_testdir)
27
+ else
28
+ raise 'Test runner not found'
29
+ end
30
+