ruby-opencv 0.0.10-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +26 -0
- data/DEVELOPERS_NOTE.md +137 -0
- data/Gemfile +8 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +227 -0
- data/README.md +98 -0
- data/Rakefile +90 -0
- data/config.yml +7 -0
- data/examples/alpha_blend.rb +21 -0
- data/examples/box.png +0 -0
- data/examples/box_in_scene.png +0 -0
- data/examples/contours/bitmap-contours-with-labels.png +0 -0
- data/examples/contours/bitmap-contours.png +0 -0
- data/examples/contours/bounding-box-detect-canny.rb +62 -0
- data/examples/contours/contour_retrieval_modes.rb +139 -0
- data/examples/contours/rotated-boxes.jpg +0 -0
- data/examples/convexhull.rb +47 -0
- data/examples/face_detect.rb +20 -0
- data/examples/find_obj.rb +169 -0
- data/examples/houghcircle.rb +22 -0
- data/examples/inpaint.png +0 -0
- data/examples/inpaint.rb +57 -0
- data/examples/lenna-rotated.jpg +0 -0
- data/examples/lenna.jpg +0 -0
- data/examples/match_kdtree.rb +88 -0
- data/examples/matching_to_many_images.rb +16 -0
- data/examples/matching_to_many_images/query.png +0 -0
- data/examples/matching_to_many_images/train/1.png +0 -0
- data/examples/matching_to_many_images/train/2.png +0 -0
- data/examples/matching_to_many_images/train/3.png +0 -0
- data/examples/matching_to_many_images/train/trainImages.txt +3 -0
- data/examples/paint.rb +70 -0
- data/examples/snake.rb +43 -0
- data/examples/stuff.jpg +0 -0
- data/examples/tiffany.jpg +0 -0
- data/ext/opencv/curve.cpp +112 -0
- data/ext/opencv/curve.h +34 -0
- data/ext/opencv/cvavgcomp.cpp +67 -0
- data/ext/opencv/cvavgcomp.h +39 -0
- data/ext/opencv/cvbox2d.cpp +197 -0
- data/ext/opencv/cvbox2d.h +61 -0
- data/ext/opencv/cvcapture.cpp +506 -0
- data/ext/opencv/cvcapture.h +72 -0
- data/ext/opencv/cvchain.cpp +233 -0
- data/ext/opencv/cvchain.h +46 -0
- data/ext/opencv/cvcircle32f.cpp +116 -0
- data/ext/opencv/cvcircle32f.h +52 -0
- data/ext/opencv/cvcondensation.cpp +282 -0
- data/ext/opencv/cvcondensation.h +49 -0
- data/ext/opencv/cvconnectedcomp.cpp +143 -0
- data/ext/opencv/cvconnectedcomp.h +49 -0
- data/ext/opencv/cvcontour.cpp +296 -0
- data/ext/opencv/cvcontour.h +48 -0
- data/ext/opencv/cvcontourtree.cpp +91 -0
- data/ext/opencv/cvcontourtree.h +41 -0
- data/ext/opencv/cvconvexitydefect.cpp +103 -0
- data/ext/opencv/cvconvexitydefect.h +42 -0
- data/ext/opencv/cverror.cpp +159 -0
- data/ext/opencv/cverror.h +28 -0
- data/ext/opencv/cvfeaturetree.cpp +125 -0
- data/ext/opencv/cvfeaturetree.h +55 -0
- data/ext/opencv/cvfont.cpp +208 -0
- data/ext/opencv/cvfont.h +64 -0
- data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
- data/ext/opencv/cvhaarclassifiercascade.h +39 -0
- data/ext/opencv/cvhistogram.cpp +546 -0
- data/ext/opencv/cvhistogram.h +73 -0
- data/ext/opencv/cvhumoments.cpp +139 -0
- data/ext/opencv/cvhumoments.h +51 -0
- data/ext/opencv/cvline.cpp +154 -0
- data/ext/opencv/cvline.h +54 -0
- data/ext/opencv/cvmat.cpp +5848 -0
- data/ext/opencv/cvmat.h +284 -0
- data/ext/opencv/cvmatnd.cpp +44 -0
- data/ext/opencv/cvmatnd.h +28 -0
- data/ext/opencv/cvmemstorage.cpp +68 -0
- data/ext/opencv/cvmemstorage.h +53 -0
- data/ext/opencv/cvmoments.cpp +287 -0
- data/ext/opencv/cvmoments.h +75 -0
- data/ext/opencv/cvpoint.cpp +228 -0
- data/ext/opencv/cvpoint.h +64 -0
- data/ext/opencv/cvpoint2d32f.cpp +211 -0
- data/ext/opencv/cvpoint2d32f.h +63 -0
- data/ext/opencv/cvpoint3d32f.cpp +245 -0
- data/ext/opencv/cvpoint3d32f.h +66 -0
- data/ext/opencv/cvrect.cpp +333 -0
- data/ext/opencv/cvrect.h +79 -0
- data/ext/opencv/cvscalar.cpp +236 -0
- data/ext/opencv/cvscalar.h +71 -0
- data/ext/opencv/cvseq.cpp +599 -0
- data/ext/opencv/cvseq.h +74 -0
- data/ext/opencv/cvsize.cpp +221 -0
- data/ext/opencv/cvsize.h +65 -0
- data/ext/opencv/cvsize2d32f.cpp +209 -0
- data/ext/opencv/cvsize2d32f.h +64 -0
- data/ext/opencv/cvslice.cpp +120 -0
- data/ext/opencv/cvslice.h +61 -0
- data/ext/opencv/cvsparsemat.cpp +44 -0
- data/ext/opencv/cvsparsemat.h +28 -0
- data/ext/opencv/cvsurfparams.cpp +199 -0
- data/ext/opencv/cvsurfparams.h +58 -0
- data/ext/opencv/cvsurfpoint.cpp +223 -0
- data/ext/opencv/cvsurfpoint.h +52 -0
- data/ext/opencv/cvtermcriteria.cpp +192 -0
- data/ext/opencv/cvtermcriteria.h +71 -0
- data/ext/opencv/cvtwopoints.cpp +116 -0
- data/ext/opencv/cvtwopoints.h +51 -0
- data/ext/opencv/cvutils.cpp +192 -0
- data/ext/opencv/cvutils.h +30 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -0
- data/ext/opencv/extconf.rb +83 -0
- data/ext/opencv/gui.cpp +68 -0
- data/ext/opencv/gui.h +30 -0
- data/ext/opencv/iplconvkernel.cpp +192 -0
- data/ext/opencv/iplconvkernel.h +71 -0
- data/ext/opencv/iplimage.cpp +644 -0
- data/ext/opencv/iplimage.h +73 -0
- data/ext/opencv/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +727 -0
- data/ext/opencv/opencv.h +400 -0
- data/ext/opencv/pointset.cpp +274 -0
- data/ext/opencv/pointset.h +68 -0
- data/ext/opencv/trackbar.cpp +121 -0
- data/ext/opencv/trackbar.h +69 -0
- data/ext/opencv/window.cpp +357 -0
- data/ext/opencv/window.h +66 -0
- data/images/CvMat_sobel.png +0 -0
- data/images/CvMat_sub_rect.png +0 -0
- data/images/CvSeq_relationmap.png +0 -0
- data/images/face_detect_from_lena.jpg +0 -0
- data/lib/1.9/opencv.so +0 -0
- data/lib/2.0/opencv.so +0 -0
- data/lib/opencv.rb +12 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +3 -0
- data/ruby-opencv.gemspec +44 -0
- data/test/helper.rb +166 -0
- data/test/runner.rb +30 -0
- data/test/samples/airplane.jpg +0 -0
- data/test/samples/baboon.jpg +0 -0
- data/test/samples/baboon200.jpg +0 -0
- data/test/samples/baboon200_rotated.jpg +0 -0
- data/test/samples/blank0.jpg +0 -0
- data/test/samples/blank1.jpg +0 -0
- data/test/samples/blank2.jpg +0 -0
- data/test/samples/blank3.jpg +0 -0
- data/test/samples/blank4.jpg +0 -0
- data/test/samples/blank5.jpg +0 -0
- data/test/samples/blank6.jpg +0 -0
- data/test/samples/blank7.jpg +0 -0
- data/test/samples/blank8.jpg +0 -0
- data/test/samples/blank9.jpg +0 -0
- data/test/samples/cat.jpg +0 -0
- data/test/samples/chessboard.jpg +0 -0
- data/test/samples/contours.jpg +0 -0
- data/test/samples/fruits.jpg +0 -0
- data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
- data/test/samples/inpaint-mask.bmp +0 -0
- data/test/samples/lena-256x256.jpg +0 -0
- data/test/samples/lena-32x32.jpg +0 -0
- data/test/samples/lena-eyes.jpg +0 -0
- data/test/samples/lena-inpaint.jpg +0 -0
- data/test/samples/lena.jpg +0 -0
- data/test/samples/lines.jpg +0 -0
- data/test/samples/messy0.jpg +0 -0
- data/test/samples/messy1.jpg +0 -0
- data/test/samples/movie_sample.avi +0 -0
- data/test/samples/one_way_train_0000.jpg +0 -0
- data/test/samples/one_way_train_0001.jpg +0 -0
- data/test/samples/partially_blank0.jpg +0 -0
- data/test/samples/partially_blank1.jpg +0 -0
- data/test/samples/smooth0.jpg +0 -0
- data/test/samples/smooth1.jpg +0 -0
- data/test/samples/smooth2.jpg +0 -0
- data/test/samples/smooth3.jpg +0 -0
- data/test/samples/smooth4.jpg +0 -0
- data/test/samples/smooth5.jpg +0 -0
- data/test/samples/smooth6.jpg +0 -0
- data/test/samples/str-cv-rotated.jpg +0 -0
- data/test/samples/str-cv.jpg +0 -0
- data/test/samples/str-ov.jpg +0 -0
- data/test/samples/stuff.jpg +0 -0
- data/test/test_curve.rb +43 -0
- data/test/test_cvavgcomp.rb +24 -0
- data/test/test_cvbox2d.rb +76 -0
- data/test/test_cvcapture.rb +183 -0
- data/test/test_cvchain.rb +108 -0
- data/test/test_cvcircle32f.rb +41 -0
- data/test/test_cvconnectedcomp.rb +61 -0
- data/test/test_cvcontour.rb +150 -0
- data/test/test_cvcontourtree.rb +43 -0
- data/test/test_cverror.rb +50 -0
- data/test/test_cvfeaturetree.rb +65 -0
- data/test/test_cvfont.rb +58 -0
- data/test/test_cvhaarclassifiercascade.rb +63 -0
- data/test/test_cvhistogram.rb +271 -0
- data/test/test_cvhumoments.rb +83 -0
- data/test/test_cvline.rb +50 -0
- data/test/test_cvmat.rb +2947 -0
- data/test/test_cvmat_drawing.rb +349 -0
- data/test/test_cvmat_dxt.rb +150 -0
- data/test/test_cvmat_imageprocessing.rb +2015 -0
- data/test/test_cvmat_matching.rb +57 -0
- data/test/test_cvmoments.rb +180 -0
- data/test/test_cvpoint.rb +75 -0
- data/test/test_cvpoint2d32f.rb +75 -0
- data/test/test_cvpoint3d32f.rb +93 -0
- data/test/test_cvrect.rb +144 -0
- data/test/test_cvscalar.rb +113 -0
- data/test/test_cvseq.rb +295 -0
- data/test/test_cvsize.rb +75 -0
- data/test/test_cvsize2d32f.rb +75 -0
- data/test/test_cvslice.rb +31 -0
- data/test/test_cvsurfparams.rb +57 -0
- data/test/test_cvsurfpoint.rb +66 -0
- data/test/test_cvtermcriteria.rb +56 -0
- data/test/test_cvtwopoints.rb +40 -0
- data/test/test_cvvideowriter.rb +58 -0
- data/test/test_iplconvkernel.rb +54 -0
- data/test/test_iplimage.rb +236 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +329 -0
- data/test/test_pointset.rb +126 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +386 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
iplimage.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_IPLIMAGE_H
|
11
|
+
#define RUBY_OPENCV_IPLIMAGE_H
|
12
|
+
|
13
|
+
#include "opencv.h"
|
14
|
+
|
15
|
+
#define __NAMESPACE_BEGIN_IPLIMAGE namespace cIplImage {
|
16
|
+
#define __NAMESPACE_END_IPLIMAGE }
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_IPLIMAGE
|
20
|
+
|
21
|
+
VALUE rb_class();
|
22
|
+
|
23
|
+
void define_ruby_class();
|
24
|
+
|
25
|
+
VALUE rb_allocate(VALUE klass);
|
26
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
27
|
+
|
28
|
+
VALUE rb_load_image(int argc, VALUE *argv, VALUE self);
|
29
|
+
VALUE rb_decode_image(int argc, VALUE *argv, VALUE self);
|
30
|
+
|
31
|
+
VALUE rb_color_model(VALUE self);
|
32
|
+
|
33
|
+
VALUE rb_get_roi(VALUE self);
|
34
|
+
VALUE rb_set_roi(VALUE self, VALUE roi);
|
35
|
+
VALUE rb_reset_roi(VALUE self);
|
36
|
+
|
37
|
+
VALUE rb_get_coi(VALUE self);
|
38
|
+
VALUE rb_set_coi(VALUE self, VALUE coi);
|
39
|
+
VALUE rb_reset_coi(VALUE self);
|
40
|
+
|
41
|
+
VALUE rb_pyr_segmentation(VALUE self, VALUE level, VALUE threshold1, VALUE threshold2);
|
42
|
+
|
43
|
+
VALUE rb_smoothness(int argc, VALUE *argv, VALUE self);
|
44
|
+
typedef enum { SMOOTH = 1, BLANK = 2, MESSY = 3 } Smoothness;
|
45
|
+
Smoothness compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, const double blankDensity, const double messyDensity, const double highFreqRatio, double &outLowDensity, double &outHighDensity);
|
46
|
+
void cvShiftDFT(CvArr *src_arr, CvArr *dst_arr );
|
47
|
+
IplImage* create_fourier_image(const IplImage *im);
|
48
|
+
IplImage* create_frequency_filtered_image(const IplImage *pImage, int low, int high);
|
49
|
+
void high_pass_range(const IplImage *pImage, float lostPercentage, int &outLow, int &outHigh);
|
50
|
+
|
51
|
+
VALUE new_object(int width, int height, int type);
|
52
|
+
VALUE new_object(CvSize size, int type);
|
53
|
+
__NAMESPACE_END_IPLIMAGE
|
54
|
+
|
55
|
+
inline IplImage*
|
56
|
+
IPLIMAGE(VALUE object)
|
57
|
+
{
|
58
|
+
IplImage *ptr, stub;
|
59
|
+
Data_Get_Struct(object, IplImage, ptr);
|
60
|
+
return cvGetImage(ptr, &stub);
|
61
|
+
}
|
62
|
+
|
63
|
+
inline IplImage*
|
64
|
+
IPLIMAGE_WITH_CHECK(VALUE object)
|
65
|
+
{
|
66
|
+
if (!rb_obj_is_kind_of(object, cIplImage::rb_class()))
|
67
|
+
raise_typeerror(object, cIplImage::rb_class());
|
68
|
+
return IPLIMAGE(object);
|
69
|
+
}
|
70
|
+
|
71
|
+
__NAMESPACE_END_OPENCV
|
72
|
+
|
73
|
+
#endif // RUBY_OPENCV_IPLIMAGE_H
|
@@ -0,0 +1,181 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
mouseevent.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2007 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#include "mouseevent.h"
|
11
|
+
/*
|
12
|
+
* Document-module: OpenCV::GUI::MouseEvent
|
13
|
+
*
|
14
|
+
* MouseEvent object.
|
15
|
+
* have
|
16
|
+
* see OpenCV::GUI::Window#set_mouse_callback.
|
17
|
+
*/
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_GUI
|
20
|
+
__NAMESPACE_BEGIN_MOUSEEVENT
|
21
|
+
|
22
|
+
VALUE rb_klass;
|
23
|
+
|
24
|
+
VALUE
|
25
|
+
rb_class()
|
26
|
+
{
|
27
|
+
return rb_klass;
|
28
|
+
}
|
29
|
+
|
30
|
+
void
|
31
|
+
define_ruby_class()
|
32
|
+
{
|
33
|
+
if (rb_klass)
|
34
|
+
return;
|
35
|
+
/*
|
36
|
+
* opencv = rb_define_module("OpenCV");
|
37
|
+
* GUI = rb_define_module_under(opencv, "GUI");
|
38
|
+
* cvpoint = rb_define_class_under(opencv, "CvPoint", rb_cObject);
|
39
|
+
*/
|
40
|
+
VALUE GUI = rb_module_GUI();
|
41
|
+
VALUE cvpoint = cCvPoint::rb_class();
|
42
|
+
rb_klass = rb_define_class_under(GUI, "MouseEvent", cvpoint);
|
43
|
+
rb_define_alloc_func(rb_klass, rb_allocate);
|
44
|
+
rb_define_method(rb_klass, "event", RUBY_METHOD_FUNC(rb_event), 0);
|
45
|
+
rb_define_method(rb_klass, "left_button?", RUBY_METHOD_FUNC(rb_left_button_q), 0);
|
46
|
+
rb_define_method(rb_klass, "right_button?", RUBY_METHOD_FUNC(rb_right_button_q), 0);
|
47
|
+
rb_define_method(rb_klass, "middle_button?", RUBY_METHOD_FUNC(rb_middle_button_q), 0);
|
48
|
+
rb_define_method(rb_klass, "ctrl_key?", RUBY_METHOD_FUNC(rb_ctrl_key_q), 0);
|
49
|
+
rb_define_method(rb_klass, "shift_key?", RUBY_METHOD_FUNC(rb_shift_key_q), 0);
|
50
|
+
rb_define_method(rb_klass, "alt_key?", RUBY_METHOD_FUNC(rb_alt_key_q), 0);
|
51
|
+
}
|
52
|
+
|
53
|
+
VALUE
|
54
|
+
rb_allocate(VALUE klass)
|
55
|
+
{
|
56
|
+
MouseEvent *ptr;
|
57
|
+
return Data_Make_Struct(klass, MouseEvent, 0, 0, ptr);
|
58
|
+
}
|
59
|
+
|
60
|
+
/*
|
61
|
+
* call-seq:
|
62
|
+
* event -> symbol
|
63
|
+
*
|
64
|
+
* Return Symbol about mouse event.
|
65
|
+
*
|
66
|
+
* Currently, return these symbol:
|
67
|
+
* :move
|
68
|
+
* When mouse move.
|
69
|
+
* :right_button_down
|
70
|
+
* When mouse right button down.
|
71
|
+
* :left_button_down
|
72
|
+
* When mosue left button down.
|
73
|
+
* :middle_button_down
|
74
|
+
* When mosue middle button down.
|
75
|
+
* :left_button_up
|
76
|
+
* When mouse left button down.
|
77
|
+
* :right_button_up
|
78
|
+
* When mouse right button down.
|
79
|
+
* :middle_button_up
|
80
|
+
* When mouse middle button down.
|
81
|
+
*
|
82
|
+
* note: original OpenCV define "double-click" event(e.g. CV_EVENT_LBUTTONDBLCLK).
|
83
|
+
* But never call these event. Is it bug?
|
84
|
+
*/
|
85
|
+
VALUE rb_event(VALUE self)
|
86
|
+
{
|
87
|
+
switch(MOUSEEVENT(self)->event) {
|
88
|
+
case CV_EVENT_MOUSEMOVE:
|
89
|
+
return ID2SYM(rb_intern("move"));
|
90
|
+
case CV_EVENT_LBUTTONDOWN:
|
91
|
+
return ID2SYM(rb_intern("left_button_down"));
|
92
|
+
case CV_EVENT_RBUTTONDOWN:
|
93
|
+
return ID2SYM(rb_intern("right_button_down"));
|
94
|
+
case CV_EVENT_MBUTTONDOWN:
|
95
|
+
return ID2SYM(rb_intern("middle_button_down"));
|
96
|
+
case CV_EVENT_LBUTTONUP:
|
97
|
+
return ID2SYM(rb_intern("left_button_up"));
|
98
|
+
case CV_EVENT_RBUTTONUP:
|
99
|
+
return ID2SYM(rb_intern("right_button_up"));
|
100
|
+
case CV_EVENT_MBUTTONUP:
|
101
|
+
return ID2SYM(rb_intern("middle_button_up"));
|
102
|
+
case CV_EVENT_LBUTTONDBLCLK:
|
103
|
+
return ID2SYM(rb_intern("left_button_double_click"));
|
104
|
+
case CV_EVENT_RBUTTONDBLCLK:
|
105
|
+
return ID2SYM(rb_intern("right_button_double_click"));
|
106
|
+
case CV_EVENT_MBUTTONDBLCLK:
|
107
|
+
return ID2SYM(rb_intern("middle_button_double_click"));
|
108
|
+
}
|
109
|
+
return Qnil;
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
* Return true when mouse left button is pushed. Otherwise return false.
|
114
|
+
*/
|
115
|
+
VALUE
|
116
|
+
rb_left_button_q(VALUE self)
|
117
|
+
{
|
118
|
+
return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_LBUTTON ? Qtrue : Qfalse;
|
119
|
+
}
|
120
|
+
|
121
|
+
/*
|
122
|
+
* Return true when mouse right button is pushed. Otherwise return false.
|
123
|
+
*/
|
124
|
+
VALUE
|
125
|
+
rb_right_button_q(VALUE self)
|
126
|
+
{
|
127
|
+
return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_RBUTTON ? Qtrue : Qfalse;
|
128
|
+
}
|
129
|
+
|
130
|
+
/*
|
131
|
+
* Return true when mouse middle button is pushed. Otherwise return false.
|
132
|
+
*/
|
133
|
+
VALUE
|
134
|
+
rb_middle_button_q(VALUE self)
|
135
|
+
{
|
136
|
+
return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_MBUTTON ? Qtrue : Qfalse;
|
137
|
+
}
|
138
|
+
|
139
|
+
/*
|
140
|
+
* Return true when CTRL key is pushed. Otherwise return false.
|
141
|
+
*/
|
142
|
+
VALUE
|
143
|
+
rb_ctrl_key_q(VALUE self)
|
144
|
+
{
|
145
|
+
return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_CTRLKEY ? Qtrue : Qfalse;
|
146
|
+
}
|
147
|
+
|
148
|
+
/*
|
149
|
+
* Return true when shift key is pushed. Otherwise return false.
|
150
|
+
*/
|
151
|
+
VALUE
|
152
|
+
rb_shift_key_q(VALUE self)
|
153
|
+
{
|
154
|
+
return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_SHIFTKEY ? Qtrue : Qfalse;
|
155
|
+
}
|
156
|
+
|
157
|
+
/*
|
158
|
+
* Return true when ALT key is pushed. Otherwise return false.
|
159
|
+
*/
|
160
|
+
VALUE
|
161
|
+
rb_alt_key_q(VALUE self)
|
162
|
+
{
|
163
|
+
return MOUSEEVENT(self)->flags & CV_EVENT_FLAG_ALTKEY ? Qtrue : Qfalse;
|
164
|
+
}
|
165
|
+
|
166
|
+
VALUE
|
167
|
+
new_object(int event, int x, int y, int flags)
|
168
|
+
{
|
169
|
+
VALUE object = rb_allocate(rb_class());
|
170
|
+
MouseEvent *mouseevent = MOUSEEVENT(object);
|
171
|
+
mouseevent->point.x = x;
|
172
|
+
mouseevent->point.y = y;
|
173
|
+
mouseevent->event = event;
|
174
|
+
mouseevent->flags = flags;
|
175
|
+
return object;
|
176
|
+
}
|
177
|
+
|
178
|
+
__NAMESPACE_END_MOUSEEVENT
|
179
|
+
__NAMESPACE_END_GUI
|
180
|
+
__NAMESPACE_END_OPENCV
|
181
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
mouseevent.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#define __NAMESPACE_BEGIN_MOUSEEVENT namespace cMouseEvent {
|
11
|
+
#define __NAMESPACE_END_MOUSEEVENT }
|
12
|
+
|
13
|
+
#ifndef RUBY_OPENCV_GUI_MOUSEEVENT_H
|
14
|
+
#define RUBY_OPENCV_GUI_MOUSEEVENT_H
|
15
|
+
|
16
|
+
#include "opencv.h"
|
17
|
+
|
18
|
+
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
__NAMESPACE_BEGIN_GUI
|
20
|
+
__NAMESPACE_BEGIN_MOUSEEVENT
|
21
|
+
|
22
|
+
typedef struct MouseEvent {
|
23
|
+
CvPoint point;
|
24
|
+
int event;
|
25
|
+
int flags;
|
26
|
+
} MouseEvent;
|
27
|
+
|
28
|
+
VALUE rb_class();
|
29
|
+
|
30
|
+
void define_ruby_class();
|
31
|
+
|
32
|
+
VALUE rb_allocate(VALUE klass);
|
33
|
+
|
34
|
+
VALUE rb_event(VALUE self);
|
35
|
+
|
36
|
+
VALUE rb_left_button_q(VALUE self);
|
37
|
+
VALUE rb_right_button_q(VALUE self);
|
38
|
+
VALUE rb_middle_button_q(VALUE self);
|
39
|
+
VALUE rb_ctrl_key_q(VALUE self);
|
40
|
+
VALUE rb_shift_key_q(VALUE self);
|
41
|
+
VALUE rb_alt_key_q(VALUE self);
|
42
|
+
|
43
|
+
VALUE new_object(int event, int x, int y, int flag);
|
44
|
+
|
45
|
+
inline MouseEvent *MOUSEEVENT(VALUE object) {
|
46
|
+
MouseEvent *ptr;
|
47
|
+
Data_Get_Struct(object, MouseEvent, ptr);
|
48
|
+
return ptr;
|
49
|
+
}
|
50
|
+
|
51
|
+
__NAMESPACE_END_MOUSEEVENT
|
52
|
+
__NAMESPACE_END_GUI
|
53
|
+
__NAMESPACE_END_OPENCV
|
54
|
+
|
55
|
+
#endif // RUBY_OPENCV_GUI_MOUSEEVENT_H
|
56
|
+
|
@@ -0,0 +1,727 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
opencv.cpp -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2008 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
/*
|
11
|
+
* Document-module: OpenCV
|
12
|
+
*
|
13
|
+
* =What is OpenCV?
|
14
|
+
*
|
15
|
+
* OpenCV is "Open Source Computer Vision Library".
|
16
|
+
* OpenCV is developed by Intel and many opensource developers.
|
17
|
+
* This library include many useful function for computer vision, such as object-detection.
|
18
|
+
*
|
19
|
+
* OpenCV is developed at
|
20
|
+
* sourceforge.net[http://sourceforge.net/projects/opencvlibrary]
|
21
|
+
*
|
22
|
+
* =What is Ruby/OpenCV?
|
23
|
+
* Ruby/OpenCV is manual Wrapper of OpenCV (not use SWIG).
|
24
|
+
* This library seem to be *Ruby*.
|
25
|
+
* * object-oriented
|
26
|
+
* * support Garbage Collection by Ruby
|
27
|
+
* Ruby/OpenCV is developed
|
28
|
+
* http://rubyforge.org/projects/opencv (Official)
|
29
|
+
* and
|
30
|
+
* http://blueruby.mydns.jp/pages/opencv (Japanese)
|
31
|
+
*
|
32
|
+
* =How to install
|
33
|
+
*
|
34
|
+
* Show INSTALL
|
35
|
+
*
|
36
|
+
* =How to generate this documentation?
|
37
|
+
* This document created by rdoc.
|
38
|
+
* If you have Ruby 1.8 or later, you might use rdoc command.
|
39
|
+
* for example
|
40
|
+
* > cd opencv
|
41
|
+
* > rdoc
|
42
|
+
* and show "./doc/index.html"
|
43
|
+
*/
|
44
|
+
#include "opencv.h"
|
45
|
+
|
46
|
+
__NAMESPACE_BEGIN_OPENCV
|
47
|
+
|
48
|
+
|
49
|
+
/*
|
50
|
+
* Hashtable for protect from GC
|
51
|
+
*/
|
52
|
+
st_table *root_table = st_init_numtable();
|
53
|
+
|
54
|
+
/*
|
55
|
+
* Mark root object. (protect from GC)
|
56
|
+
*/
|
57
|
+
void
|
58
|
+
mark_root_object(void *ptr)
|
59
|
+
{
|
60
|
+
VALUE value;
|
61
|
+
if (ptr && st_lookup(root_table, (st_data_t)ptr, (st_data_t*)&value)) {
|
62
|
+
rb_gc_mark(value);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* Look-up Root root object.
|
68
|
+
*/
|
69
|
+
VALUE
|
70
|
+
lookup_root_object(void *ptr)
|
71
|
+
{
|
72
|
+
VALUE value = 0;
|
73
|
+
if (ptr)
|
74
|
+
st_lookup(root_table, (st_data_t)ptr, (st_data_t*)&value);
|
75
|
+
return value;
|
76
|
+
}
|
77
|
+
|
78
|
+
/*
|
79
|
+
* Register root object.
|
80
|
+
*/
|
81
|
+
void
|
82
|
+
register_root_object(void *ptr, VALUE root)
|
83
|
+
{
|
84
|
+
st_insert(root_table, (st_data_t)ptr, (st_data_t)root);
|
85
|
+
}
|
86
|
+
|
87
|
+
/*
|
88
|
+
* Delete mark symbol from hashtable only, not free memory.
|
89
|
+
*/
|
90
|
+
void
|
91
|
+
unregister_object(void *ptr)
|
92
|
+
{
|
93
|
+
st_delete(root_table, (st_data_t*)&ptr, 0);
|
94
|
+
}
|
95
|
+
|
96
|
+
/*
|
97
|
+
* Delete mark symbol from hash table, then free memory.
|
98
|
+
*/
|
99
|
+
void
|
100
|
+
free_object(void *ptr)
|
101
|
+
{
|
102
|
+
if (ptr) {
|
103
|
+
unregister_object(ptr);
|
104
|
+
try {
|
105
|
+
cvFree(&ptr);
|
106
|
+
}
|
107
|
+
catch (cv::Exception& e) {
|
108
|
+
raise_cverror(e);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* Release OpenCV specific structure(i.e CvMat, IplImage..) from memory and delete from hashtable.
|
115
|
+
*/
|
116
|
+
void
|
117
|
+
release_object(void *ptr)
|
118
|
+
{
|
119
|
+
if (ptr) {
|
120
|
+
unregister_object(ptr);
|
121
|
+
try {
|
122
|
+
cvRelease(&ptr);
|
123
|
+
}
|
124
|
+
catch (cv::Exception& e) {
|
125
|
+
raise_cverror(e);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
/*
|
131
|
+
* Release IplConvKernel object from memory and delete from hashtable.
|
132
|
+
*/
|
133
|
+
void
|
134
|
+
release_iplconvkernel_object(void *ptr)
|
135
|
+
{
|
136
|
+
if (ptr) {
|
137
|
+
unregister_object(ptr);
|
138
|
+
try {
|
139
|
+
cvReleaseStructuringElement((IplConvKernel**)(&ptr));
|
140
|
+
}
|
141
|
+
catch (cv::Exception& e) {
|
142
|
+
raise_cverror(e);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
VALUE rb_module;
|
148
|
+
VALUE rb_opencv_constants;
|
149
|
+
|
150
|
+
VALUE
|
151
|
+
rb_module_opencv()
|
152
|
+
{
|
153
|
+
return rb_module;
|
154
|
+
}
|
155
|
+
|
156
|
+
void
|
157
|
+
define_ruby_module()
|
158
|
+
{
|
159
|
+
if (rb_module)
|
160
|
+
return;
|
161
|
+
rb_module = rb_define_module("OpenCV");
|
162
|
+
|
163
|
+
/* OpenCV version */
|
164
|
+
rb_define_const(rb_module, "CV_VERSION", rb_str_new2(CV_VERSION));
|
165
|
+
rb_define_const(rb_module, "CV_MAJOR_VERSION", INT2FIX(CV_MAJOR_VERSION));
|
166
|
+
rb_define_const(rb_module, "CV_MINOR_VERSION", INT2FIX(CV_MINOR_VERSION));
|
167
|
+
rb_define_const(rb_module, "CV_SUBMINOR_VERSION", INT2FIX(CV_SUBMINOR_VERSION));
|
168
|
+
|
169
|
+
rb_define_const(rb_module, "CV_VERSION_EPOCH", INT2FIX(CV_VERSION_EPOCH));
|
170
|
+
rb_define_const(rb_module, "CV_VERSION_MAJOR", INT2FIX(CV_VERSION_MAJOR));
|
171
|
+
rb_define_const(rb_module, "CV_VERSION_MINOR", INT2FIX(CV_VERSION_MINOR));
|
172
|
+
rb_define_const(rb_module, "CV_VERSION_REVISION", INT2FIX(CV_VERSION_REVISION));
|
173
|
+
|
174
|
+
/* 0: 8bit unsigned */
|
175
|
+
rb_define_const(rb_module, "CV_8U", INT2FIX(CV_8U));
|
176
|
+
/* 1: 8bit signed */
|
177
|
+
rb_define_const(rb_module, "CV_8S", INT2FIX(CV_8S));
|
178
|
+
/* 2: 16bit unsigned */
|
179
|
+
rb_define_const(rb_module, "CV_16U", INT2FIX(CV_16U));
|
180
|
+
/* 3: 16bit signed */
|
181
|
+
rb_define_const(rb_module, "CV_16S", INT2FIX(CV_16S));
|
182
|
+
/* 4: 32bit signed */
|
183
|
+
rb_define_const(rb_module, "CV_32S", INT2FIX(CV_32S));
|
184
|
+
/* 5: 32bit floating-point */
|
185
|
+
rb_define_const(rb_module, "CV_32F", INT2FIX(CV_32F));
|
186
|
+
/* 6: 64bit floating-point */
|
187
|
+
rb_define_const(rb_module, "CV_64F", INT2FIX(CV_64F));
|
188
|
+
|
189
|
+
/* Color types of loaded images */
|
190
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_UNCHANGED", INT2FIX(CV_LOAD_IMAGE_UNCHANGED));
|
191
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_GRAYSCALE", INT2FIX(CV_LOAD_IMAGE_GRAYSCALE));
|
192
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_COLOR", INT2FIX(CV_LOAD_IMAGE_COLOR));
|
193
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_ANYDEPTH", INT2FIX(CV_LOAD_IMAGE_ANYDEPTH));
|
194
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_ANYCOLOR", INT2FIX(CV_LOAD_IMAGE_ANYCOLOR));
|
195
|
+
|
196
|
+
/* Format-specific save parameters */
|
197
|
+
rb_define_const(rb_module, "CV_IMWRITE_JPEG_QUALITY", INT2FIX(CV_IMWRITE_JPEG_QUALITY));
|
198
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_COMPRESSION", INT2FIX(CV_IMWRITE_PNG_COMPRESSION));
|
199
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY", INT2FIX(CV_IMWRITE_PNG_STRATEGY));
|
200
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_DEFAULT", INT2FIX(CV_IMWRITE_PNG_STRATEGY_DEFAULT));
|
201
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_FILTERED", INT2FIX(CV_IMWRITE_PNG_STRATEGY_FILTERED));
|
202
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY", INT2FIX(CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY));
|
203
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_RLE", INT2FIX(CV_IMWRITE_PNG_STRATEGY_RLE));
|
204
|
+
rb_define_const(rb_module, "CV_IMWRITE_PNG_STRATEGY_FIXED", INT2FIX(CV_IMWRITE_PNG_STRATEGY_FIXED));
|
205
|
+
rb_define_const(rb_module, "CV_IMWRITE_PXM_BINARY", INT2FIX(CV_IMWRITE_PXM_BINARY));
|
206
|
+
|
207
|
+
/* Types of morphological operations */
|
208
|
+
rb_define_const(rb_module, "CV_MOP_OPEN", INT2FIX(CV_MOP_OPEN));
|
209
|
+
rb_define_const(rb_module, "CV_MOP_CLOSE", INT2FIX(CV_MOP_CLOSE));
|
210
|
+
rb_define_const(rb_module, "CV_MOP_GRADIENT", INT2FIX(CV_MOP_GRADIENT));
|
211
|
+
rb_define_const(rb_module, "CV_MOP_TOPHAT", INT2FIX(CV_MOP_TOPHAT));
|
212
|
+
rb_define_const(rb_module, "CV_MOP_BLACKHAT", INT2FIX(CV_MOP_BLACKHAT));
|
213
|
+
|
214
|
+
/* Shape of the structuring elements */
|
215
|
+
rb_define_const(rb_module, "CV_SHAPE_RECT", INT2FIX(CV_SHAPE_RECT));
|
216
|
+
rb_define_const(rb_module, "CV_SHAPE_CROSS", INT2FIX(CV_SHAPE_CROSS));
|
217
|
+
rb_define_const(rb_module, "CV_SHAPE_ELLIPSE", INT2FIX(CV_SHAPE_ELLIPSE));
|
218
|
+
rb_define_const(rb_module, "CV_SHAPE_CUSTOM", INT2FIX(CV_SHAPE_CUSTOM));
|
219
|
+
|
220
|
+
/* Types of the smoothing */
|
221
|
+
rb_define_const(rb_module, "CV_BLUR_NO_SCALE", INT2FIX(CV_BLUR_NO_SCALE));
|
222
|
+
rb_define_const(rb_module, "CV_BLUR", INT2FIX(CV_BLUR));
|
223
|
+
rb_define_const(rb_module, "CV_GAUSSIAN", INT2FIX(CV_GAUSSIAN));
|
224
|
+
rb_define_const(rb_module, "CV_MEDIAN", INT2FIX(CV_MEDIAN));
|
225
|
+
rb_define_const(rb_module, "CV_BILATERAL", INT2FIX(CV_BILATERAL));
|
226
|
+
|
227
|
+
/* Thresholding types */
|
228
|
+
rb_define_const(rb_module, "CV_THRESH_BINARY", INT2FIX(CV_THRESH_BINARY));
|
229
|
+
rb_define_const(rb_module, "CV_THRESH_BINARY_INV", INT2FIX(CV_THRESH_BINARY_INV));
|
230
|
+
rb_define_const(rb_module, "CV_THRESH_TRUNC", INT2FIX(CV_THRESH_TRUNC));
|
231
|
+
rb_define_const(rb_module, "CV_THRESH_TOZERO", INT2FIX(CV_THRESH_TOZERO));
|
232
|
+
rb_define_const(rb_module, "CV_THRESH_TOZERO_INV", INT2FIX(CV_THRESH_TOZERO_INV));
|
233
|
+
rb_define_const(rb_module, "CV_THRESH_OTSU", INT2FIX(CV_THRESH_OTSU));
|
234
|
+
|
235
|
+
/* Adaptive methods */
|
236
|
+
rb_define_const(rb_module, "CV_ADAPTIVE_THRESH_MEAN_C", INT2FIX(CV_ADAPTIVE_THRESH_MEAN_C));
|
237
|
+
rb_define_const(rb_module, "CV_ADAPTIVE_THRESH_GAUSSIAN_C", INT2FIX(CV_ADAPTIVE_THRESH_GAUSSIAN_C));
|
238
|
+
|
239
|
+
/* Border type */
|
240
|
+
rb_define_const(rb_module, "IPL_BORDER_CONSTANT", INT2FIX(IPL_BORDER_CONSTANT));
|
241
|
+
rb_define_const(rb_module, "IPL_BORDER_REPLICATE", INT2FIX(IPL_BORDER_REPLICATE));
|
242
|
+
|
243
|
+
/* Retrieval mode */
|
244
|
+
rb_define_const(rb_module, "CV_RETR_EXTERNAL", INT2FIX(CV_RETR_EXTERNAL));
|
245
|
+
rb_define_const(rb_module, "CV_RETR_LIST", INT2FIX(CV_RETR_LIST));
|
246
|
+
rb_define_const(rb_module, "CV_RETR_CCOMP", INT2FIX(CV_RETR_CCOMP));
|
247
|
+
rb_define_const(rb_module, "CV_RETR_TREE", INT2FIX(CV_RETR_TREE));
|
248
|
+
|
249
|
+
/* Approximation method */
|
250
|
+
rb_define_const(rb_module, "CV_CHAIN_CODE", INT2FIX(CV_CHAIN_CODE));
|
251
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_NONE", INT2FIX(CV_CHAIN_APPROX_NONE));
|
252
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_SIMPLE", INT2FIX(CV_CHAIN_APPROX_SIMPLE));
|
253
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_TC89_L1", INT2FIX(CV_CHAIN_APPROX_TC89_L1));
|
254
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_TC89_KCOS", INT2FIX(CV_CHAIN_APPROX_TC89_KCOS));
|
255
|
+
rb_define_const(rb_module, "CV_LINK_RUNS", INT2FIX(CV_LINK_RUNS));
|
256
|
+
|
257
|
+
/* Termination criteria for iterative algorithms */
|
258
|
+
rb_define_const(rb_module, "CV_TERMCRIT_ITER", INT2FIX(CV_TERMCRIT_ITER));
|
259
|
+
rb_define_const(rb_module, "CV_TERMCRIT_NUMBER", INT2FIX(CV_TERMCRIT_NUMBER));
|
260
|
+
rb_define_const(rb_module, "CV_TERMCRIT_EPS", INT2FIX(CV_TERMCRIT_EPS));
|
261
|
+
|
262
|
+
/* Hough transform method */
|
263
|
+
rb_define_const(rb_module, "CV_HOUGH_STANDARD", INT2FIX(CV_HOUGH_STANDARD));
|
264
|
+
rb_define_const(rb_module, "CV_HOUGH_PROBABILISTIC", INT2FIX(CV_HOUGH_PROBABILISTIC));
|
265
|
+
rb_define_const(rb_module, "CV_HOUGH_MULTI_SCALE", INT2FIX(CV_HOUGH_MULTI_SCALE));
|
266
|
+
rb_define_const(rb_module, "CV_HOUGH_GRADIENT", INT2FIX(CV_HOUGH_GRADIENT));
|
267
|
+
|
268
|
+
/* Inpaint method */
|
269
|
+
rb_define_const(rb_module, "CV_INPAINT_NS", INT2FIX(CV_INPAINT_NS));
|
270
|
+
rb_define_const(rb_module, "CV_INPAINT_TELEA", INT2FIX(CV_INPAINT_TELEA));
|
271
|
+
|
272
|
+
/* Match template method */
|
273
|
+
rb_define_const(rb_module, "CV_TM_SQDIFF", INT2FIX(CV_TM_SQDIFF));
|
274
|
+
rb_define_const(rb_module, "CV_TM_SQDIFF_NORMED", INT2FIX(CV_TM_SQDIFF_NORMED));
|
275
|
+
rb_define_const(rb_module, "CV_TM_CCORR", INT2FIX(CV_TM_CCORR));
|
276
|
+
rb_define_const(rb_module, "CV_TM_CCORR_NORMED", INT2FIX(CV_TM_CCORR_NORMED));
|
277
|
+
rb_define_const(rb_module, "CV_TM_CCOEFF", INT2FIX(CV_TM_CCOEFF));
|
278
|
+
rb_define_const(rb_module, "CV_TM_CCOEFF_NORMED", INT2FIX(CV_TM_CCOEFF_NORMED));
|
279
|
+
|
280
|
+
/* Comparison method */
|
281
|
+
rb_define_const(rb_module, "CV_CONTOURS_MATCH_I1", INT2FIX(CV_CONTOURS_MATCH_I1));
|
282
|
+
rb_define_const(rb_module, "CV_CONTOURS_MATCH_I2", INT2FIX(CV_CONTOURS_MATCH_I2));
|
283
|
+
rb_define_const(rb_module, "CV_CONTOURS_MATCH_I3", INT2FIX(CV_CONTOURS_MATCH_I3));
|
284
|
+
|
285
|
+
/* Fundamental matrix computing methods */
|
286
|
+
rb_define_const(rb_module, "CV_FM_7POINT", INT2FIX(CV_FM_7POINT));
|
287
|
+
rb_define_const(rb_module, "CV_FM_8POINT", INT2FIX(CV_FM_8POINT));
|
288
|
+
rb_define_const(rb_module, "CV_FM_RANSAC", INT2FIX(CV_FM_RANSAC));
|
289
|
+
rb_define_const(rb_module, "CV_FM_LMEDS", INT2FIX(CV_FM_LMEDS));
|
290
|
+
|
291
|
+
/* Flags of window */
|
292
|
+
rb_define_const(rb_module, "CV_WINDOW_AUTOSIZE", INT2FIX(CV_WINDOW_AUTOSIZE));
|
293
|
+
|
294
|
+
/* Object detection mode */
|
295
|
+
rb_define_const(rb_module, "CV_HAAR_DO_CANNY_PRUNING", INT2FIX(CV_HAAR_DO_CANNY_PRUNING));
|
296
|
+
|
297
|
+
/* Interpolation methods */
|
298
|
+
rb_define_const(rb_module, "CV_INTER_NN", INT2FIX(CV_INTER_NN));
|
299
|
+
rb_define_const(rb_module, "CV_INTER_LINEAR", INT2FIX(CV_INTER_LINEAR));
|
300
|
+
rb_define_const(rb_module, "CV_INTER_AREA", INT2FIX(CV_INTER_AREA));
|
301
|
+
rb_define_const(rb_module, "CV_INTER_CUBIC", INT2FIX(CV_INTER_CUBIC));
|
302
|
+
rb_define_const(rb_module, "CV_INTER_LANCZOS4", INT2FIX(CV_INTER_LANCZOS4));
|
303
|
+
|
304
|
+
/* Warp affine optional flags */
|
305
|
+
rb_define_const(rb_module, "CV_WARP_FILL_OUTLIERS", INT2FIX(CV_WARP_FILL_OUTLIERS));
|
306
|
+
rb_define_const(rb_module, "CV_WARP_INVERSE_MAP", INT2FIX(CV_WARP_INVERSE_MAP));
|
307
|
+
|
308
|
+
/* SVD optional flags */
|
309
|
+
rb_define_const(rb_module, "CV_SVD_MODIFY_A", INT2FIX(CV_SVD_MODIFY_A));
|
310
|
+
rb_define_const(rb_module, "CV_SVD_U_T", INT2FIX(CV_SVD_U_T));
|
311
|
+
rb_define_const(rb_module, "CV_SVD_V_T", INT2FIX(CV_SVD_V_T));
|
312
|
+
|
313
|
+
/* Norm types */
|
314
|
+
rb_define_const(rb_module, "CV_NORM_INF", INT2FIX(cv::NORM_INF));
|
315
|
+
rb_define_const(rb_module, "CV_NORM_L1", INT2FIX(cv::NORM_L1));
|
316
|
+
rb_define_const(rb_module, "CV_NORM_L2", INT2FIX(cv::NORM_L2));
|
317
|
+
rb_define_const(rb_module, "CV_NORM_MINMAX", INT2FIX(cv::NORM_MINMAX));
|
318
|
+
|
319
|
+
/* Histogram representation format */
|
320
|
+
rb_define_const(rb_module, "CV_HIST_ARRAY", INT2FIX(CV_HIST_ARRAY));
|
321
|
+
rb_define_const(rb_module, "CV_HIST_SPARSE", INT2FIX(CV_HIST_SPARSE));
|
322
|
+
rb_define_const(rb_module, "CV_HIST_TREE", INT2FIX(CV_HIST_TREE));
|
323
|
+
rb_define_const(rb_module, "CV_HIST_UNIFORM", INT2FIX(CV_HIST_UNIFORM));
|
324
|
+
|
325
|
+
/* Histogram comparison method */
|
326
|
+
rb_define_const(rb_module, "CV_COMP_CORREL", INT2FIX(CV_COMP_CORREL));
|
327
|
+
rb_define_const(rb_module, "CV_COMP_CHISQR", INT2FIX(CV_COMP_CHISQR));
|
328
|
+
rb_define_const(rb_module, "CV_COMP_INTERSECT", INT2FIX(CV_COMP_INTERSECT));
|
329
|
+
rb_define_const(rb_module, "CV_COMP_BHATTACHARYYA", INT2FIX(CV_COMP_BHATTACHARYYA));
|
330
|
+
|
331
|
+
/* DFT and DCT flags */
|
332
|
+
rb_define_const(rb_module, "CV_DXT_FORWARD", INT2FIX(CV_DXT_FORWARD));
|
333
|
+
rb_define_const(rb_module, "CV_DXT_INVERSE", INT2FIX(CV_DXT_INVERSE));
|
334
|
+
rb_define_const(rb_module, "CV_DXT_SCALE", INT2FIX(CV_DXT_SCALE));
|
335
|
+
rb_define_const(rb_module, "CV_DXT_INV_SCALE", INT2FIX(CV_DXT_INV_SCALE));
|
336
|
+
rb_define_const(rb_module, "CV_DXT_INVERSE_SCALE", INT2FIX(CV_DXT_INVERSE_SCALE));
|
337
|
+
rb_define_const(rb_module, "CV_DXT_ROWS", INT2FIX(CV_DXT_ROWS));
|
338
|
+
|
339
|
+
/* FindChessboardCorners flags */
|
340
|
+
rb_define_const(rb_module, "CV_CALIB_CB_ADAPTIVE_THRESH", INT2FIX(CV_CALIB_CB_ADAPTIVE_THRESH));
|
341
|
+
rb_define_const(rb_module, "CV_CALIB_CB_NORMALIZE_IMAGE", INT2FIX(CV_CALIB_CB_NORMALIZE_IMAGE));
|
342
|
+
rb_define_const(rb_module, "CV_CALIB_CB_FILTER_QUADS", INT2FIX(CV_CALIB_CB_FILTER_QUADS));
|
343
|
+
rb_define_const(rb_module, "CV_CALIB_CB_FAST_CHECK", INT2FIX(CV_CALIB_CB_FAST_CHECK));
|
344
|
+
|
345
|
+
|
346
|
+
VALUE inversion_method = rb_hash_new();
|
347
|
+
/* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */
|
348
|
+
rb_define_const(rb_module, "INVERSION_METHOD", inversion_method);
|
349
|
+
REGISTER_HASH(inversion_method, "lu", CV_LU);
|
350
|
+
REGISTER_HASH(inversion_method, "svd", CV_SVD);
|
351
|
+
REGISTER_HASH(inversion_method, "svd_sym", CV_SVD_SYM);
|
352
|
+
REGISTER_HASH(inversion_method, "svd_symmetric", CV_SVD_SYM);
|
353
|
+
|
354
|
+
VALUE homography_calc_method = rb_hash_new();
|
355
|
+
/* {:all, :ransac, :lmeds}: Methods used to computed homography matrix */
|
356
|
+
rb_define_const(rb_module, "HOMOGRAPHY_CALC_METHOD", homography_calc_method);
|
357
|
+
REGISTER_HASH(homography_calc_method, "all", 0);
|
358
|
+
REGISTER_HASH(homography_calc_method, "ransac", CV_RANSAC);
|
359
|
+
REGISTER_HASH(homography_calc_method, "lmeds", CV_LMEDS);
|
360
|
+
|
361
|
+
VALUE depth = rb_hash_new();
|
362
|
+
/* {:cv8u, :cv8s, :cv16u, :cv16s, :cv32s, :cv32f, :cv64f}: Depth of each pixel. */
|
363
|
+
rb_define_const(rb_module, "DEPTH", depth);
|
364
|
+
REGISTER_HASH(depth, "cv8u", CV_8U);
|
365
|
+
REGISTER_HASH(depth, "cv8s", CV_8S);
|
366
|
+
REGISTER_HASH(depth, "cv16u", CV_16U);
|
367
|
+
REGISTER_HASH(depth, "cv16s", CV_16S);
|
368
|
+
REGISTER_HASH(depth, "cv32s", CV_32S);
|
369
|
+
REGISTER_HASH(depth, "cv32f", CV_32F);
|
370
|
+
REGISTER_HASH(depth, "cv64f", CV_64F);
|
371
|
+
|
372
|
+
VALUE connectivity = rb_hash_new();
|
373
|
+
/* {:aa(:anti_alias)}: Determined by the closeness of pixel values */
|
374
|
+
rb_define_const(rb_module, "CONNECTIVITY", connectivity);
|
375
|
+
REGISTER_HASH(connectivity, "aa", CV_AA);
|
376
|
+
REGISTER_HASH(connectivity, "anti_alias", CV_AA);
|
377
|
+
|
378
|
+
VALUE structuring_element_shape = rb_hash_new();
|
379
|
+
/* {:rect, :cross, :ellipse, :custom}: Shape of the structuring elements */
|
380
|
+
rb_define_const(rb_module, "STRUCTURING_ELEMENT_SHAPE", structuring_element_shape);
|
381
|
+
REGISTER_HASH(structuring_element_shape, "rect", CV_SHAPE_RECT);
|
382
|
+
REGISTER_HASH(structuring_element_shape, "cross", CV_SHAPE_CROSS);
|
383
|
+
REGISTER_HASH(structuring_element_shape, "ellipse", CV_SHAPE_ELLIPSE);
|
384
|
+
REGISTER_HASH(structuring_element_shape, "custom", CV_SHAPE_CUSTOM);
|
385
|
+
|
386
|
+
VALUE retrieval_mode = rb_hash_new();
|
387
|
+
/* {:external, :list, :ccomp, :tree}: Retrieval mode */
|
388
|
+
rb_define_const(rb_module, "RETRIEVAL_MODE", retrieval_mode);
|
389
|
+
REGISTER_HASH(retrieval_mode, "external", CV_RETR_EXTERNAL);
|
390
|
+
REGISTER_HASH(retrieval_mode, "list", CV_RETR_LIST);
|
391
|
+
REGISTER_HASH(retrieval_mode, "ccomp", CV_RETR_CCOMP);
|
392
|
+
REGISTER_HASH(retrieval_mode, "tree", CV_RETR_TREE);
|
393
|
+
|
394
|
+
VALUE approx_chain_method = rb_hash_new();
|
395
|
+
/* {:code, :approx_none, :approx_simple, :apporx_tc89_11, :approx_tc89_kcos}: Approximation method */
|
396
|
+
rb_define_const(rb_module, "APPROX_CHAIN_METHOD", approx_chain_method);
|
397
|
+
REGISTER_HASH(approx_chain_method, "code", CV_CHAIN_CODE);
|
398
|
+
REGISTER_HASH(approx_chain_method, "approx_none", CV_CHAIN_APPROX_NONE);
|
399
|
+
REGISTER_HASH(approx_chain_method, "approx_simple", CV_CHAIN_APPROX_SIMPLE);
|
400
|
+
REGISTER_HASH(approx_chain_method, "approx_tc89_l1", CV_CHAIN_APPROX_TC89_L1);
|
401
|
+
REGISTER_HASH(approx_chain_method, "approx_tc89_kcos", CV_CHAIN_APPROX_TC89_KCOS);
|
402
|
+
|
403
|
+
VALUE approx_poly_method = rb_hash_new();
|
404
|
+
/* {:dp}: Approximation method (polygon) */
|
405
|
+
rb_define_const(rb_module, "APPROX_POLY_METHOD", approx_poly_method);
|
406
|
+
REGISTER_HASH(approx_poly_method, "dp", CV_POLY_APPROX_DP);
|
407
|
+
|
408
|
+
VALUE match_template_method = rb_hash_new();
|
409
|
+
/* {:sqdiff, :sqdiff_normed, :ccorr, :ccorr_normed, :ccoeff, :ccoeff_normed}: Match template method */
|
410
|
+
rb_define_const(rb_module, "MATCH_TEMPLATE_METHOD", match_template_method);
|
411
|
+
REGISTER_HASH(match_template_method, "sqdiff", CV_TM_SQDIFF);
|
412
|
+
REGISTER_HASH(match_template_method, "sqdiff_normed", CV_TM_SQDIFF_NORMED);
|
413
|
+
REGISTER_HASH(match_template_method, "ccorr", CV_TM_CCORR);
|
414
|
+
REGISTER_HASH(match_template_method, "ccorr_normed", CV_TM_CCORR_NORMED);
|
415
|
+
REGISTER_HASH(match_template_method, "ccoeff", CV_TM_CCOEFF);
|
416
|
+
REGISTER_HASH(match_template_method, "ccoeff_normed", CV_TM_CCOEFF_NORMED);
|
417
|
+
|
418
|
+
VALUE morphological_operation = rb_hash_new();
|
419
|
+
/* {:open, :close, :gradient, :tophat, :blackhat}: Types of morphological operations */
|
420
|
+
rb_define_const(rb_module, "MORPHOLOGICAL_OPERATION", morphological_operation);
|
421
|
+
REGISTER_HASH(morphological_operation, "open", CV_MOP_OPEN);
|
422
|
+
REGISTER_HASH(morphological_operation, "close", CV_MOP_CLOSE);
|
423
|
+
REGISTER_HASH(morphological_operation, "gradient", CV_MOP_GRADIENT);
|
424
|
+
REGISTER_HASH(morphological_operation, "tophat", CV_MOP_TOPHAT);
|
425
|
+
REGISTER_HASH(morphological_operation, "blackhat", CV_MOP_BLACKHAT);
|
426
|
+
|
427
|
+
VALUE smoothing_type = rb_hash_new();
|
428
|
+
/* {:blur_no_scale, :blur, :gaussian, :median, :bilateral}: Types of smoothing */
|
429
|
+
rb_define_const(rb_module, "SMOOTHING_TYPE", smoothing_type);
|
430
|
+
REGISTER_HASH(smoothing_type, "blur_no_scale", CV_BLUR_NO_SCALE);
|
431
|
+
REGISTER_HASH(smoothing_type, "blur", CV_BLUR);
|
432
|
+
REGISTER_HASH(smoothing_type, "gaussian", CV_GAUSSIAN);
|
433
|
+
REGISTER_HASH(smoothing_type, "median", CV_MEDIAN);
|
434
|
+
REGISTER_HASH(smoothing_type, "bilateral", CV_BILATERAL);
|
435
|
+
|
436
|
+
VALUE adaptive_method = rb_hash_new();
|
437
|
+
/* {:mean_c, :gaussian_c}: Adaptive thresholding algorithm */
|
438
|
+
rb_define_const(rb_module, "ADAPTIVE_METHOD", adaptive_method);
|
439
|
+
REGISTER_HASH(adaptive_method, "mean_c", CV_ADAPTIVE_THRESH_MEAN_C);
|
440
|
+
REGISTER_HASH(adaptive_method, "gaussian_c", CV_ADAPTIVE_THRESH_GAUSSIAN_C);
|
441
|
+
|
442
|
+
VALUE threshold_type = rb_hash_new();
|
443
|
+
/* {:binary, :binary_inv, :trunc, :tozero, :tozero_inv, :otsu} : Thresholding types */
|
444
|
+
rb_define_const(rb_module, "THRESHOLD_TYPE", threshold_type);
|
445
|
+
REGISTER_HASH(threshold_type, "binary", CV_THRESH_BINARY);
|
446
|
+
REGISTER_HASH(threshold_type, "binary_inv", CV_THRESH_BINARY_INV);
|
447
|
+
REGISTER_HASH(threshold_type, "trunc", CV_THRESH_TRUNC);
|
448
|
+
REGISTER_HASH(threshold_type, "tozero", CV_THRESH_TOZERO);
|
449
|
+
REGISTER_HASH(threshold_type, "tozero_inv", CV_THRESH_TOZERO_INV);
|
450
|
+
REGISTER_HASH(threshold_type, "otsu", CV_THRESH_OTSU);
|
451
|
+
|
452
|
+
VALUE hough_transform_method = rb_hash_new();
|
453
|
+
/* {:standard, :probabilistic, :multi_scale} : Hough transform method */
|
454
|
+
rb_define_const(rb_module, "HOUGH_TRANSFORM_METHOD", hough_transform_method);
|
455
|
+
REGISTER_HASH(hough_transform_method, "standard", CV_HOUGH_STANDARD);
|
456
|
+
REGISTER_HASH(hough_transform_method, "probabilistic", CV_HOUGH_PROBABILISTIC);
|
457
|
+
REGISTER_HASH(hough_transform_method, "multi_scale", CV_HOUGH_MULTI_SCALE);
|
458
|
+
REGISTER_HASH(hough_transform_method, "gradient", CV_HOUGH_GRADIENT);
|
459
|
+
|
460
|
+
VALUE inpaint_method = rb_hash_new();
|
461
|
+
/* {:ns, :telea} : Inpaint method */
|
462
|
+
rb_define_const(rb_module, "INPAINT_METHOD", inpaint_method);
|
463
|
+
REGISTER_HASH(inpaint_method, "ns", CV_INPAINT_NS);
|
464
|
+
REGISTER_HASH(inpaint_method, "telea", CV_INPAINT_TELEA);
|
465
|
+
|
466
|
+
VALUE comparison_method = rb_hash_new();
|
467
|
+
/* Comparison method */
|
468
|
+
rb_define_const(rb_module, "COMPARISON_METHOD", comparison_method);
|
469
|
+
REGISTER_HASH(comparison_method, "i1", CV_CONTOURS_MATCH_I1);
|
470
|
+
REGISTER_HASH(comparison_method, "i2", CV_CONTOURS_MATCH_I2);
|
471
|
+
REGISTER_HASH(comparison_method, "i3", CV_CONTOURS_MATCH_I3);
|
472
|
+
|
473
|
+
/* color convert methods */
|
474
|
+
rb_define_module_function(rb_module, "BGR2BGRA", RUBY_METHOD_FUNC(rb_BGR2BGRA), 1);
|
475
|
+
rb_define_module_function(rb_module, "RGB2RGBA", RUBY_METHOD_FUNC(rb_RGB2RGBA), 1);
|
476
|
+
rb_define_module_function(rb_module, "BGRA2BGR", RUBY_METHOD_FUNC(rb_BGRA2BGR), 1);
|
477
|
+
rb_define_module_function(rb_module, "RGBA2RGB", RUBY_METHOD_FUNC(rb_RGBA2RGB), 1);
|
478
|
+
rb_define_module_function(rb_module, "BGR2RGBA", RUBY_METHOD_FUNC(rb_BGR2RGBA), 1);
|
479
|
+
rb_define_module_function(rb_module, "RGB2BGRA", RUBY_METHOD_FUNC(rb_RGB2BGRA), 1);
|
480
|
+
rb_define_module_function(rb_module, "RGBA2BGR", RUBY_METHOD_FUNC(rb_RGBA2BGR), 1);
|
481
|
+
rb_define_module_function(rb_module, "BGRA2RGB", RUBY_METHOD_FUNC(rb_BGRA2RGB), 1);
|
482
|
+
rb_define_module_function(rb_module, "BGR2RGB", RUBY_METHOD_FUNC(rb_BGR2RGB), 1);
|
483
|
+
rb_define_module_function(rb_module, "RGB2BGR", RUBY_METHOD_FUNC(rb_RGB2BGR), 1);
|
484
|
+
rb_define_module_function(rb_module, "BGRA2RGBA", RUBY_METHOD_FUNC(rb_BGRA2RGBA), 1);
|
485
|
+
rb_define_module_function(rb_module, "RGBA2BGRA", RUBY_METHOD_FUNC(rb_RGBA2BGRA), 1);
|
486
|
+
rb_define_module_function(rb_module, "BGR2GRAY", RUBY_METHOD_FUNC(rb_BGR2GRAY), 1);
|
487
|
+
rb_define_module_function(rb_module, "RGB2GRAY", RUBY_METHOD_FUNC(rb_RGB2GRAY), 1);
|
488
|
+
rb_define_module_function(rb_module, "GRAY2BGR", RUBY_METHOD_FUNC(rb_GRAY2BGR), 1);
|
489
|
+
rb_define_module_function(rb_module, "GRAY2RGB", RUBY_METHOD_FUNC(rb_GRAY2RGB), 1);
|
490
|
+
rb_define_module_function(rb_module, "GRAY2BGRA", RUBY_METHOD_FUNC(rb_GRAY2BGRA), 1);
|
491
|
+
rb_define_module_function(rb_module, "GRAY2RGBA", RUBY_METHOD_FUNC(rb_GRAY2RGBA), 1);
|
492
|
+
rb_define_module_function(rb_module, "BGRA2GRAY", RUBY_METHOD_FUNC(rb_BGRA2GRAY), 1);
|
493
|
+
rb_define_module_function(rb_module, "RGBA2GRAY", RUBY_METHOD_FUNC(rb_RGBA2GRAY), 1);
|
494
|
+
rb_define_module_function(rb_module, "BGR2BGR565", RUBY_METHOD_FUNC(rb_BGR2BGR565), 1);
|
495
|
+
rb_define_module_function(rb_module, "RGB2BGR565", RUBY_METHOD_FUNC(rb_RGB2BGR565), 1);
|
496
|
+
rb_define_module_function(rb_module, "BGR5652BGR", RUBY_METHOD_FUNC(rb_BGR5652BGR), 1);
|
497
|
+
rb_define_module_function(rb_module, "BGR5652RGB", RUBY_METHOD_FUNC(rb_BGR5652RGB), 1);
|
498
|
+
rb_define_module_function(rb_module, "BGRA2BGR565", RUBY_METHOD_FUNC(rb_BGRA2BGR565), 1);
|
499
|
+
rb_define_module_function(rb_module, "RGBA2BGR565", RUBY_METHOD_FUNC(rb_RGBA2BGR565), 1);
|
500
|
+
rb_define_module_function(rb_module, "BGR5652BGRA", RUBY_METHOD_FUNC(rb_BGR5652BGRA), 1);
|
501
|
+
rb_define_module_function(rb_module, "BGR5652RGBA", RUBY_METHOD_FUNC(rb_BGR5652RGBA), 1);
|
502
|
+
rb_define_module_function(rb_module, "GRAY2BGR565", RUBY_METHOD_FUNC(rb_GRAY2BGR565), 1);
|
503
|
+
rb_define_module_function(rb_module, "BGR5652GRAY", RUBY_METHOD_FUNC(rb_BGR5652GRAY), 1);
|
504
|
+
rb_define_module_function(rb_module, "BGR2BGR555", RUBY_METHOD_FUNC(rb_BGR2BGR555), 1);
|
505
|
+
rb_define_module_function(rb_module, "RGB2BGR555", RUBY_METHOD_FUNC(rb_RGB2BGR555), 1);
|
506
|
+
rb_define_module_function(rb_module, "BGR5552BGR", RUBY_METHOD_FUNC(rb_BGR5552BGR), 1);
|
507
|
+
rb_define_module_function(rb_module, "BGR5552RGB", RUBY_METHOD_FUNC(rb_BGR5552RGB), 1);
|
508
|
+
rb_define_module_function(rb_module, "BGRA2BGR555", RUBY_METHOD_FUNC(rb_BGRA2BGR555), 1);
|
509
|
+
rb_define_module_function(rb_module, "RGBA2BGR555", RUBY_METHOD_FUNC(rb_RGBA2BGR555), 1);
|
510
|
+
rb_define_module_function(rb_module, "BGR5552BGRA", RUBY_METHOD_FUNC(rb_BGR5552BGRA), 1);
|
511
|
+
rb_define_module_function(rb_module, "BGR5552RGBA", RUBY_METHOD_FUNC(rb_BGR5552RGBA), 1);
|
512
|
+
rb_define_module_function(rb_module, "GRAY2BGR555", RUBY_METHOD_FUNC(rb_GRAY2BGR555), 1);
|
513
|
+
rb_define_module_function(rb_module, "BGR5552GRAY", RUBY_METHOD_FUNC(rb_BGR5552GRAY), 1);
|
514
|
+
rb_define_module_function(rb_module, "BGR2XYZ", RUBY_METHOD_FUNC(rb_BGR2XYZ), 1);
|
515
|
+
rb_define_module_function(rb_module, "RGB2XYZ", RUBY_METHOD_FUNC(rb_RGB2XYZ), 1);
|
516
|
+
rb_define_module_function(rb_module, "XYZ2BGR", RUBY_METHOD_FUNC(rb_XYZ2BGR), 1);
|
517
|
+
rb_define_module_function(rb_module, "XYZ2RGB", RUBY_METHOD_FUNC(rb_XYZ2RGB), 1);
|
518
|
+
rb_define_module_function(rb_module, "BGR2YCrCb", RUBY_METHOD_FUNC(rb_BGR2YCrCb), 1);
|
519
|
+
rb_define_module_function(rb_module, "RGB2YCrCb", RUBY_METHOD_FUNC(rb_RGB2YCrCb), 1);
|
520
|
+
rb_define_module_function(rb_module, "YCrCb2BGR", RUBY_METHOD_FUNC(rb_YCrCb2BGR), 1);
|
521
|
+
rb_define_module_function(rb_module, "YCrCb2RGB", RUBY_METHOD_FUNC(rb_YCrCb2RGB), 1);
|
522
|
+
rb_define_module_function(rb_module, "BGR2HSV", RUBY_METHOD_FUNC(rb_BGR2HSV), 1);
|
523
|
+
rb_define_module_function(rb_module, "RGB2HSV", RUBY_METHOD_FUNC(rb_RGB2HSV), 1);
|
524
|
+
rb_define_module_function(rb_module, "BGR2Lab", RUBY_METHOD_FUNC(rb_BGR2Lab), 1);
|
525
|
+
rb_define_module_function(rb_module, "RGB2Lab", RUBY_METHOD_FUNC(rb_RGB2Lab), 1);
|
526
|
+
rb_define_module_function(rb_module, "BayerBG2BGR", RUBY_METHOD_FUNC(rb_BayerBG2BGR), 1);
|
527
|
+
rb_define_module_function(rb_module, "BayerGB2BGR", RUBY_METHOD_FUNC(rb_BayerGB2BGR), 1);
|
528
|
+
rb_define_module_function(rb_module, "BayerRG2BGR", RUBY_METHOD_FUNC(rb_BayerRG2BGR), 1);
|
529
|
+
rb_define_module_function(rb_module, "BayerGR2BGR", RUBY_METHOD_FUNC(rb_BayerGR2BGR), 1);
|
530
|
+
rb_define_module_function(rb_module, "BayerBG2RGB", RUBY_METHOD_FUNC(rb_BayerBG2RGB), 1);
|
531
|
+
rb_define_module_function(rb_module, "BayerGB2RGB", RUBY_METHOD_FUNC(rb_BayerGB2RGB), 1);
|
532
|
+
rb_define_module_function(rb_module, "BayerRG2RGB", RUBY_METHOD_FUNC(rb_BayerRG2RGB), 1);
|
533
|
+
rb_define_module_function(rb_module, "BayerGR2RGB", RUBY_METHOD_FUNC(rb_BayerGR2RGB), 1);
|
534
|
+
rb_define_module_function(rb_module, "BGR2Luv", RUBY_METHOD_FUNC(rb_BGR2Luv), 1);
|
535
|
+
rb_define_module_function(rb_module, "RGB2Luv", RUBY_METHOD_FUNC(rb_RGB2Luv), 1);
|
536
|
+
rb_define_module_function(rb_module, "BGR2HLS", RUBY_METHOD_FUNC(rb_BGR2HLS), 1);
|
537
|
+
rb_define_module_function(rb_module, "RGB2HLS", RUBY_METHOD_FUNC(rb_RGB2HLS), 1);
|
538
|
+
rb_define_module_function(rb_module, "HSV2BGR", RUBY_METHOD_FUNC(rb_HSV2BGR), 1);
|
539
|
+
rb_define_module_function(rb_module, "HSV2RGB", RUBY_METHOD_FUNC(rb_HSV2RGB), 1);
|
540
|
+
rb_define_module_function(rb_module, "Lab2BGR", RUBY_METHOD_FUNC(rb_Lab2BGR), 1);
|
541
|
+
rb_define_module_function(rb_module, "Lab2RGB", RUBY_METHOD_FUNC(rb_Lab2RGB), 1);
|
542
|
+
rb_define_module_function(rb_module, "Luv2BGR", RUBY_METHOD_FUNC(rb_Luv2BGR), 1);
|
543
|
+
rb_define_module_function(rb_module, "Luv2RGB", RUBY_METHOD_FUNC(rb_Luv2RGB), 1);
|
544
|
+
rb_define_module_function(rb_module, "HLS2BGR", RUBY_METHOD_FUNC(rb_HLS2BGR), 1);
|
545
|
+
rb_define_module_function(rb_module, "HLS2RGB", RUBY_METHOD_FUNC(rb_HLS2RGB), 1);
|
546
|
+
|
547
|
+
rb_define_module_function(rb_module, "build_information", RUBY_METHOD_FUNC(rb_build_information), 0);
|
548
|
+
}
|
549
|
+
|
550
|
+
#define CREATE_CVTCOLOR_FUNC(rb_func_name, c_const_name, src_cn, dest_cn) \
|
551
|
+
VALUE rb_func_name(VALUE klass, VALUE image) \
|
552
|
+
{ \
|
553
|
+
VALUE dest = Qnil; \
|
554
|
+
CvArr* img_ptr = CVARR(image); \
|
555
|
+
try { \
|
556
|
+
int type = cvGetElemType(img_ptr); \
|
557
|
+
if (CV_MAT_CN(type) != src_cn) \
|
558
|
+
rb_raise(rb_eArgError, "argument 1 should be %d-channel.", src_cn); \
|
559
|
+
dest = cCvMat::new_mat_kind_object(cvGetSize(img_ptr), image, CV_MAT_DEPTH(type), dest_cn); \
|
560
|
+
cvCvtColor(img_ptr, CVARR(dest), c_const_name); \
|
561
|
+
} \
|
562
|
+
catch (cv::Exception& e) { \
|
563
|
+
raise_cverror(e); \
|
564
|
+
} \
|
565
|
+
return dest; \
|
566
|
+
}
|
567
|
+
|
568
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2BGRA, CV_BGR2BGRA, 3, 4);
|
569
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2RGBA, CV_RGB2RGBA, 3, 4);
|
570
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR, CV_BGRA2BGR, 4, 3);
|
571
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2RGB, CV_RGBA2RGB, 4, 3);
|
572
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2RGBA, CV_BGR2RGBA, 3, 4);
|
573
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGRA, CV_RGB2BGRA, 3, 4);
|
574
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR, CV_RGBA2BGR, 4, 3);
|
575
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2RGB, CV_BGRA2RGB, 4, 3);
|
576
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2RGB, CV_BGR2RGB, 3, 3);
|
577
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGR, CV_RGB2BGR, 3, 3);
|
578
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2RGBA, CV_BGRA2RGBA, 4, 4);
|
579
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGRA, CV_RGBA2BGRA, 4, 4);
|
580
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2GRAY, CV_BGR2GRAY, 3, 1);
|
581
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2GRAY, CV_RGB2GRAY, 3, 1);
|
582
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR, CV_GRAY2BGR, 1, 3);
|
583
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2RGB, CV_GRAY2RGB, 1, 3);
|
584
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGRA, CV_GRAY2BGRA, 1, 4);
|
585
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2RGBA, CV_GRAY2RGBA, 1, 4);
|
586
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2GRAY, CV_BGRA2GRAY, 4, 1);
|
587
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2GRAY, CV_RGBA2GRAY, 4, 1);
|
588
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2BGR565, CV_BGR2BGR565, 3, 3);
|
589
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGR565, CV_RGB2BGR565, 3, 3);
|
590
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652BGR, CV_BGR5652BGR, 3, 3);
|
591
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652RGB, CV_BGR5652RGB, 3, 3);
|
592
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR565, CV_BGRA2BGR565, 4, 3);
|
593
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR565, CV_RGBA2BGR565, 4, 3);
|
594
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652BGRA, CV_BGR5652BGRA, 3, 4);
|
595
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652RGBA, CV_BGR5652RGBA, 3, 4);
|
596
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR565, CV_GRAY2BGR565, 1, 3);
|
597
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652GRAY, CV_BGR5652GRAY, 3, 1);
|
598
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2BGR555, CV_BGR2BGR555, 3, 3);
|
599
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGR555, CV_RGB2BGR555, 3, 3);
|
600
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552BGR, CV_BGR5552BGR, 3, 3);
|
601
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552RGB, CV_BGR5552RGB, 3, 3);
|
602
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR555, CV_BGRA2BGR555, 4, 3);
|
603
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR555, CV_RGBA2BGR555, 4, 3);
|
604
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552BGRA, CV_BGR5552BGRA, 3, 4);
|
605
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552RGBA, CV_BGR5552RGBA, 3, 4);
|
606
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR555, CV_GRAY2BGR555, 1, 3);
|
607
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552GRAY, CV_BGR5552GRAY, 3, 1);
|
608
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2XYZ, CV_BGR2XYZ, 3, 3);
|
609
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2XYZ, CV_RGB2XYZ, 3, 3);
|
610
|
+
CREATE_CVTCOLOR_FUNC(rb_XYZ2BGR, CV_XYZ2BGR, 3, 3);
|
611
|
+
CREATE_CVTCOLOR_FUNC(rb_XYZ2RGB, CV_XYZ2RGB, 3, 3);
|
612
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2YCrCb, CV_BGR2YCrCb, 3, 3);
|
613
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2YCrCb, CV_RGB2YCrCb, 3, 3);
|
614
|
+
CREATE_CVTCOLOR_FUNC(rb_YCrCb2BGR, CV_YCrCb2BGR, 3, 3);
|
615
|
+
CREATE_CVTCOLOR_FUNC(rb_YCrCb2RGB, CV_YCrCb2RGB, 0, 3);
|
616
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2HSV, CV_BGR2HSV, 3, 3);
|
617
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2HSV, CV_RGB2HSV, 3, 3);
|
618
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2Lab, CV_BGR2Lab, 3, 3);
|
619
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2Lab, CV_RGB2Lab, 3, 3);
|
620
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerBG2BGR, CV_BayerBG2BGR, 3, 3);
|
621
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGB2BGR, CV_BayerGB2BGR, 3, 3);
|
622
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerRG2BGR, CV_BayerRG2BGR, 3, 3);
|
623
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGR2BGR, CV_BayerGR2BGR, 3, 3);
|
624
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerBG2RGB, CV_BayerBG2RGB, 3, 3);
|
625
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGB2RGB, CV_BayerGB2RGB, 3, 3);
|
626
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerRG2RGB, CV_BayerRG2RGB, 3, 3);
|
627
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGR2RGB, CV_BayerGR2RGB, 3, 3);
|
628
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2Luv, CV_BGR2Luv, 3, 3);
|
629
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2Luv, CV_RGB2Luv, 3, 3);
|
630
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2HLS, CV_BGR2HLS, 3, 3);
|
631
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2HLS, CV_RGB2HLS, 3, 3);
|
632
|
+
CREATE_CVTCOLOR_FUNC(rb_HSV2BGR, CV_HSV2BGR, 3, 3);
|
633
|
+
CREATE_CVTCOLOR_FUNC(rb_HSV2RGB, CV_HSV2RGB, 3, 3);
|
634
|
+
CREATE_CVTCOLOR_FUNC(rb_Lab2BGR, CV_Lab2BGR, 3, 3);
|
635
|
+
CREATE_CVTCOLOR_FUNC(rb_Lab2RGB, CV_Lab2RGB, 3, 3);
|
636
|
+
CREATE_CVTCOLOR_FUNC(rb_Luv2BGR, CV_Luv2BGR, 3, 3);
|
637
|
+
CREATE_CVTCOLOR_FUNC(rb_Luv2RGB, CV_Luv2RGB, 3, 3);
|
638
|
+
CREATE_CVTCOLOR_FUNC(rb_HLS2BGR, CV_HLS2BGR, 3, 3);
|
639
|
+
CREATE_CVTCOLOR_FUNC(rb_HLS2RGB, CV_HLS2RGB, 3, 3);
|
640
|
+
|
641
|
+
VALUE
|
642
|
+
rb_build_information(VALUE klass)
|
643
|
+
{
|
644
|
+
const char* ptr = cv::getBuildInformation().c_str();
|
645
|
+
return rb_str_new(ptr, strlen(ptr));
|
646
|
+
}
|
647
|
+
|
648
|
+
|
649
|
+
int
|
650
|
+
error_callback(int status, const char *function_name, const char *error_message,
|
651
|
+
const char *file_name, int line, void *user_data)
|
652
|
+
{
|
653
|
+
// dummy
|
654
|
+
return 0;
|
655
|
+
}
|
656
|
+
|
657
|
+
__NAMESPACE_END_OPENCV
|
658
|
+
|
659
|
+
extern "C" {
|
660
|
+
void
|
661
|
+
Init_opencv()
|
662
|
+
{
|
663
|
+
cvRedirectError((CvErrorCallback)mOpenCV::error_callback);
|
664
|
+
|
665
|
+
mOpenCV::define_ruby_module();
|
666
|
+
|
667
|
+
mOpenCV::cCvError::define_ruby_class();
|
668
|
+
mOpenCV::cCvPoint::define_ruby_class();
|
669
|
+
mOpenCV::cCvPoint2D32f::define_ruby_class();
|
670
|
+
mOpenCV::cCvPoint3D32f::define_ruby_class();
|
671
|
+
mOpenCV::cCvSize::define_ruby_class();
|
672
|
+
mOpenCV::cCvSize2D32f::define_ruby_class();
|
673
|
+
mOpenCV::cCvRect::define_ruby_class();
|
674
|
+
mOpenCV::cCvScalar::define_ruby_class();
|
675
|
+
mOpenCV::cCvSlice::define_ruby_class();
|
676
|
+
mOpenCV::cCvTermCriteria::define_ruby_class();
|
677
|
+
mOpenCV::cCvBox2D::define_ruby_class();
|
678
|
+
mOpenCV::cCvFont::define_ruby_class();
|
679
|
+
mOpenCV::cIplConvKernel::define_ruby_class();
|
680
|
+
mOpenCV::cCvMoments::define_ruby_class();
|
681
|
+
mOpenCV::cCvHuMoments::define_ruby_class();
|
682
|
+
mOpenCV::cCvConvexityDefect::define_ruby_class();
|
683
|
+
|
684
|
+
mOpenCV::cCvSURFPoint::define_ruby_class();
|
685
|
+
mOpenCV::cCvSURFParams::define_ruby_class();
|
686
|
+
|
687
|
+
mOpenCV::cCvMemStorage::define_ruby_class();
|
688
|
+
|
689
|
+
mOpenCV::cCvSeq::define_ruby_class();
|
690
|
+
mOpenCV::mCurve::define_ruby_module();
|
691
|
+
mOpenCV::mPointSet::define_ruby_module();
|
692
|
+
mOpenCV::cCvChain::define_ruby_class();
|
693
|
+
mOpenCV::cCvContour::define_ruby_class();
|
694
|
+
mOpenCV::cCvContourTree::define_ruby_class();
|
695
|
+
|
696
|
+
mOpenCV::cCvMat::define_ruby_class();
|
697
|
+
mOpenCV::cIplImage::define_ruby_class();
|
698
|
+
mOpenCV::cCvMatND::define_ruby_class();
|
699
|
+
mOpenCV::cCvSparseMat::define_ruby_class();
|
700
|
+
mOpenCV::cCvHistogram::define_ruby_class();
|
701
|
+
mOpenCV::cCvCapture::define_ruby_class();
|
702
|
+
mOpenCV::cCvVideoWriter::define_ruby_class();
|
703
|
+
|
704
|
+
mOpenCV::cCvLine::define_ruby_class();
|
705
|
+
mOpenCV::cCvTwoPoints::define_ruby_class();
|
706
|
+
mOpenCV::cCvCircle32f::define_ruby_class();
|
707
|
+
|
708
|
+
mOpenCV::cCvConDensation::define_ruby_class();
|
709
|
+
mOpenCV::cCvFeatureTree::define_ruby_class();
|
710
|
+
|
711
|
+
mOpenCV::cCvConnectedComp::define_ruby_class();
|
712
|
+
mOpenCV::cCvAvgComp::define_ruby_class();
|
713
|
+
mOpenCV::cCvHaarClassifierCascade::define_ruby_class();
|
714
|
+
mOpenCV::mGUI::define_ruby_module();
|
715
|
+
mOpenCV::mGUI::cWindow::define_ruby_class();
|
716
|
+
mOpenCV::mGUI::cTrackbar::define_ruby_class();
|
717
|
+
mOpenCV::mGUI::cMouseEvent::define_ruby_class();
|
718
|
+
|
719
|
+
#ifdef HAVE_ML_H
|
720
|
+
/* feature support.
|
721
|
+
mOpenCV::mMachineLearning::define_ruby_module();
|
722
|
+
*/
|
723
|
+
#endif
|
724
|
+
|
725
|
+
cv::initModule_nonfree();
|
726
|
+
}
|
727
|
+
}
|