afeld-opencv 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/Gemfile +6 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +217 -0
- data/README.rdoc +161 -0
- data/Rakefile +52 -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/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 +499 -0
- data/ext/opencv/cvcapture.h +72 -0
- data/ext/opencv/cvchain.cpp +230 -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 +297 -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 +5627 -0
- data/ext/opencv/cvmat.h +280 -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 +246 -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 +72 -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 +194 -0
- data/ext/opencv/cvutils.h +29 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -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 +576 -0
- data/ext/opencv/iplimage.h +70 -0
- data/ext/opencv/lib/opencv.rb +3 -0
- data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
- data/ext/opencv/lib/opencv/version.rb +3 -0
- data/ext/opencv/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +710 -0
- data/ext/opencv/opencv.h +400 -0
- data/ext/opencv/pointset.cpp +284 -0
- data/ext/opencv/pointset.h +69 -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/extconf.rb +65 -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/test/helper.rb +146 -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/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 +2752 -0
- data/test/test_cvmat_drawing.rb +318 -0
- data/test/test_cvmat_dxt.rb +147 -0
- data/test/test_cvmat_imageprocessing.rb +1943 -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 +156 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +340 -0
- data/test/test_pointset.rb +130 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +399 -0
@@ -0,0 +1,70 @@
|
|
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
|
+
|
30
|
+
VALUE rb_color_model(VALUE self);
|
31
|
+
|
32
|
+
VALUE rb_get_roi(VALUE self);
|
33
|
+
VALUE rb_set_roi(VALUE self, VALUE roi);
|
34
|
+
VALUE rb_reset_roi(VALUE self);
|
35
|
+
|
36
|
+
VALUE rb_get_coi(VALUE self);
|
37
|
+
VALUE rb_set_coi(VALUE self, VALUE coi);
|
38
|
+
VALUE rb_reset_coi(VALUE self);
|
39
|
+
|
40
|
+
VALUE rb_smoothness(int argc, VALUE *argv, VALUE self);
|
41
|
+
typedef enum { SMOOTH = 1, BLANK = 2, MESSY = 3 } Smoothness;
|
42
|
+
Smoothness compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, const double blankDensity, const double messyDensity, const double highFreqRatio, double &outLowDensity, double &outHighDensity);
|
43
|
+
void cvShiftDFT(CvArr *src_arr, CvArr *dst_arr );
|
44
|
+
IplImage* create_fourier_image(const IplImage *im);
|
45
|
+
IplImage* create_frequency_filtered_image(const IplImage *pImage, int low, int high);
|
46
|
+
void high_pass_range(const IplImage *pImage, float lostPercentage, int &outLow, int &outHigh);
|
47
|
+
|
48
|
+
VALUE new_object(int width, int height, int type);
|
49
|
+
VALUE new_object(CvSize size, int type);
|
50
|
+
__NAMESPACE_END_IPLIMAGE
|
51
|
+
|
52
|
+
inline IplImage*
|
53
|
+
IPLIMAGE(VALUE object)
|
54
|
+
{
|
55
|
+
IplImage *ptr, stub;
|
56
|
+
Data_Get_Struct(object, IplImage, ptr);
|
57
|
+
return cvGetImage(ptr, &stub);
|
58
|
+
}
|
59
|
+
|
60
|
+
inline IplImage*
|
61
|
+
IPLIMAGE_WITH_CHECK(VALUE object)
|
62
|
+
{
|
63
|
+
if (!rb_obj_is_kind_of(object, cIplImage::rb_class()))
|
64
|
+
raise_typeerror(object, cIplImage::rb_class());
|
65
|
+
return IPLIMAGE(object);
|
66
|
+
}
|
67
|
+
|
68
|
+
__NAMESPACE_END_OPENCV
|
69
|
+
|
70
|
+
#endif // RUBY_OPENCV_IPLIMAGE_H
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8-unix -*-
|
2
|
+
# Psych loader for avoiding loading problem
|
3
|
+
# (borrowed from Bundler 1.1.rc.7 https://github.com/carlhuda/bundler/blob/v1.1.rc.7/lib/bundler/psyched_yaml.rb )
|
4
|
+
#
|
5
|
+
# See: https://github.com/ruby-opencv/ruby-opencv/pull/6
|
6
|
+
|
7
|
+
# Psych could be a gem
|
8
|
+
begin
|
9
|
+
gem 'psych'
|
10
|
+
rescue Gem::LoadError
|
11
|
+
end if defined?(Gem)
|
12
|
+
|
13
|
+
# Psych could be a stdlib
|
14
|
+
begin
|
15
|
+
# it's too late if Syck is already loaded
|
16
|
+
require 'psych' unless defined?(Syck)
|
17
|
+
rescue LoadError
|
18
|
+
end
|
19
|
+
|
20
|
+
# Psych might NOT EXIST AT ALL
|
21
|
+
require 'yaml'
|
22
|
+
|
@@ -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,710 @@
|
|
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
|
+
/* 0: 8bit unsigned */
|
170
|
+
rb_define_const(rb_module, "CV_8U", INT2FIX(CV_8U));
|
171
|
+
/* 1: 8bit signed */
|
172
|
+
rb_define_const(rb_module, "CV_8S", INT2FIX(CV_8S));
|
173
|
+
/* 2: 16bit unsigned */
|
174
|
+
rb_define_const(rb_module, "CV_16U", INT2FIX(CV_16U));
|
175
|
+
/* 3: 16bit signed */
|
176
|
+
rb_define_const(rb_module, "CV_16S", INT2FIX(CV_16S));
|
177
|
+
/* 4: 32bit signed */
|
178
|
+
rb_define_const(rb_module, "CV_32S", INT2FIX(CV_32S));
|
179
|
+
/* 5: 32bit floating-point */
|
180
|
+
rb_define_const(rb_module, "CV_32F", INT2FIX(CV_32F));
|
181
|
+
/* 6: 64bit floating-point */
|
182
|
+
rb_define_const(rb_module, "CV_64F", INT2FIX(CV_64F));
|
183
|
+
|
184
|
+
/* Color types of loaded images */
|
185
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_UNCHANGED", INT2FIX(CV_LOAD_IMAGE_UNCHANGED));
|
186
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_GRAYSCALE", INT2FIX(CV_LOAD_IMAGE_GRAYSCALE));
|
187
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_COLOR", INT2FIX(CV_LOAD_IMAGE_COLOR));
|
188
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_ANYDEPTH", INT2FIX(CV_LOAD_IMAGE_ANYDEPTH));
|
189
|
+
rb_define_const(rb_module, "CV_LOAD_IMAGE_ANYCOLOR", INT2FIX(CV_LOAD_IMAGE_ANYCOLOR));
|
190
|
+
|
191
|
+
/* Types of morphological operations */
|
192
|
+
rb_define_const(rb_module, "CV_MOP_OPEN", INT2FIX(CV_MOP_OPEN));
|
193
|
+
rb_define_const(rb_module, "CV_MOP_CLOSE", INT2FIX(CV_MOP_CLOSE));
|
194
|
+
rb_define_const(rb_module, "CV_MOP_GRADIENT", INT2FIX(CV_MOP_GRADIENT));
|
195
|
+
rb_define_const(rb_module, "CV_MOP_TOPHAT", INT2FIX(CV_MOP_TOPHAT));
|
196
|
+
rb_define_const(rb_module, "CV_MOP_BLACKHAT", INT2FIX(CV_MOP_BLACKHAT));
|
197
|
+
|
198
|
+
/* Shape of the structuring elements */
|
199
|
+
rb_define_const(rb_module, "CV_SHAPE_RECT", INT2FIX(CV_SHAPE_RECT));
|
200
|
+
rb_define_const(rb_module, "CV_SHAPE_CROSS", INT2FIX(CV_SHAPE_CROSS));
|
201
|
+
rb_define_const(rb_module, "CV_SHAPE_ELLIPSE", INT2FIX(CV_SHAPE_ELLIPSE));
|
202
|
+
rb_define_const(rb_module, "CV_SHAPE_CUSTOM", INT2FIX(CV_SHAPE_CUSTOM));
|
203
|
+
|
204
|
+
/* Types of the smoothing */
|
205
|
+
rb_define_const(rb_module, "CV_BLUR_NO_SCALE", INT2FIX(CV_BLUR_NO_SCALE));
|
206
|
+
rb_define_const(rb_module, "CV_BLUR", INT2FIX(CV_BLUR));
|
207
|
+
rb_define_const(rb_module, "CV_GAUSSIAN", INT2FIX(CV_GAUSSIAN));
|
208
|
+
rb_define_const(rb_module, "CV_MEDIAN", INT2FIX(CV_MEDIAN));
|
209
|
+
rb_define_const(rb_module, "CV_BILATERAL", INT2FIX(CV_BILATERAL));
|
210
|
+
|
211
|
+
/* Thresholding types */
|
212
|
+
rb_define_const(rb_module, "CV_THRESH_BINARY", INT2FIX(CV_THRESH_BINARY));
|
213
|
+
rb_define_const(rb_module, "CV_THRESH_BINARY_INV", INT2FIX(CV_THRESH_BINARY_INV));
|
214
|
+
rb_define_const(rb_module, "CV_THRESH_TRUNC", INT2FIX(CV_THRESH_TRUNC));
|
215
|
+
rb_define_const(rb_module, "CV_THRESH_TOZERO", INT2FIX(CV_THRESH_TOZERO));
|
216
|
+
rb_define_const(rb_module, "CV_THRESH_TOZERO_INV", INT2FIX(CV_THRESH_TOZERO_INV));
|
217
|
+
rb_define_const(rb_module, "CV_THRESH_OTSU", INT2FIX(CV_THRESH_OTSU));
|
218
|
+
|
219
|
+
/* Adaptive methods */
|
220
|
+
rb_define_const(rb_module, "CV_ADAPTIVE_THRESH_MEAN_C", INT2FIX(CV_ADAPTIVE_THRESH_MEAN_C));
|
221
|
+
rb_define_const(rb_module, "CV_ADAPTIVE_THRESH_GAUSSIAN_C", INT2FIX(CV_ADAPTIVE_THRESH_GAUSSIAN_C));
|
222
|
+
|
223
|
+
/* Border type */
|
224
|
+
rb_define_const(rb_module, "IPL_BORDER_CONSTANT", INT2FIX(IPL_BORDER_CONSTANT));
|
225
|
+
rb_define_const(rb_module, "IPL_BORDER_REPLICATE", INT2FIX(IPL_BORDER_REPLICATE));
|
226
|
+
|
227
|
+
/* Retrieval mode */
|
228
|
+
rb_define_const(rb_module, "CV_RETR_EXTERNAL", INT2FIX(CV_RETR_EXTERNAL));
|
229
|
+
rb_define_const(rb_module, "CV_RETR_LIST", INT2FIX(CV_RETR_LIST));
|
230
|
+
rb_define_const(rb_module, "CV_RETR_CCOMP", INT2FIX(CV_RETR_CCOMP));
|
231
|
+
rb_define_const(rb_module, "CV_RETR_TREE", INT2FIX(CV_RETR_TREE));
|
232
|
+
|
233
|
+
/* Approximation method */
|
234
|
+
rb_define_const(rb_module, "CV_CHAIN_CODE", INT2FIX(CV_CHAIN_CODE));
|
235
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_NONE", INT2FIX(CV_CHAIN_APPROX_NONE));
|
236
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_SIMPLE", INT2FIX(CV_CHAIN_APPROX_SIMPLE));
|
237
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_TC89_L1", INT2FIX(CV_CHAIN_APPROX_TC89_L1));
|
238
|
+
rb_define_const(rb_module, "CV_CHAIN_APPROX_TC89_KCOS", INT2FIX(CV_CHAIN_APPROX_TC89_KCOS));
|
239
|
+
rb_define_const(rb_module, "CV_LINK_RUNS", INT2FIX(CV_LINK_RUNS));
|
240
|
+
|
241
|
+
/* Termination criteria for iterative algorithms */
|
242
|
+
rb_define_const(rb_module, "CV_TERMCRIT_ITER", INT2FIX(CV_TERMCRIT_ITER));
|
243
|
+
rb_define_const(rb_module, "CV_TERMCRIT_NUMBER", INT2FIX(CV_TERMCRIT_NUMBER));
|
244
|
+
rb_define_const(rb_module, "CV_TERMCRIT_EPS", INT2FIX(CV_TERMCRIT_EPS));
|
245
|
+
|
246
|
+
/* Hough transform method */
|
247
|
+
rb_define_const(rb_module, "CV_HOUGH_STANDARD", INT2FIX(CV_HOUGH_STANDARD));
|
248
|
+
rb_define_const(rb_module, "CV_HOUGH_PROBABILISTIC", INT2FIX(CV_HOUGH_PROBABILISTIC));
|
249
|
+
rb_define_const(rb_module, "CV_HOUGH_MULTI_SCALE", INT2FIX(CV_HOUGH_MULTI_SCALE));
|
250
|
+
rb_define_const(rb_module, "CV_HOUGH_GRADIENT", INT2FIX(CV_HOUGH_GRADIENT));
|
251
|
+
|
252
|
+
/* Inpaint method */
|
253
|
+
rb_define_const(rb_module, "CV_INPAINT_NS", INT2FIX(CV_INPAINT_NS));
|
254
|
+
rb_define_const(rb_module, "CV_INPAINT_TELEA", INT2FIX(CV_INPAINT_TELEA));
|
255
|
+
|
256
|
+
/* Match template method */
|
257
|
+
rb_define_const(rb_module, "CV_TM_SQDIFF", INT2FIX(CV_TM_SQDIFF));
|
258
|
+
rb_define_const(rb_module, "CV_TM_SQDIFF_NORMED", INT2FIX(CV_TM_SQDIFF_NORMED));
|
259
|
+
rb_define_const(rb_module, "CV_TM_CCORR", INT2FIX(CV_TM_CCORR));
|
260
|
+
rb_define_const(rb_module, "CV_TM_CCORR_NORMED", INT2FIX(CV_TM_CCORR_NORMED));
|
261
|
+
rb_define_const(rb_module, "CV_TM_CCOEFF", INT2FIX(CV_TM_CCOEFF));
|
262
|
+
rb_define_const(rb_module, "CV_TM_CCOEFF_NORMED", INT2FIX(CV_TM_CCOEFF_NORMED));
|
263
|
+
|
264
|
+
/* Comparison method */
|
265
|
+
rb_define_const(rb_module, "CV_CONTOURS_MATCH_I1", INT2FIX(CV_CONTOURS_MATCH_I1));
|
266
|
+
rb_define_const(rb_module, "CV_CONTOURS_MATCH_I2", INT2FIX(CV_CONTOURS_MATCH_I2));
|
267
|
+
rb_define_const(rb_module, "CV_CONTOURS_MATCH_I3", INT2FIX(CV_CONTOURS_MATCH_I3));
|
268
|
+
|
269
|
+
/* Fundamental matrix computing methods */
|
270
|
+
rb_define_const(rb_module, "CV_FM_7POINT", INT2FIX(CV_FM_7POINT));
|
271
|
+
rb_define_const(rb_module, "CV_FM_8POINT", INT2FIX(CV_FM_8POINT));
|
272
|
+
rb_define_const(rb_module, "CV_FM_RANSAC", INT2FIX(CV_FM_RANSAC));
|
273
|
+
rb_define_const(rb_module, "CV_FM_LMEDS", INT2FIX(CV_FM_LMEDS));
|
274
|
+
|
275
|
+
/* Flags of window */
|
276
|
+
rb_define_const(rb_module, "CV_WINDOW_AUTOSIZE", INT2FIX(CV_WINDOW_AUTOSIZE));
|
277
|
+
|
278
|
+
/* Object detection mode */
|
279
|
+
rb_define_const(rb_module, "CV_HAAR_DO_CANNY_PRUNING", INT2FIX(CV_HAAR_DO_CANNY_PRUNING));
|
280
|
+
|
281
|
+
/* Interpolation methods */
|
282
|
+
rb_define_const(rb_module, "CV_INTER_NN", INT2FIX(CV_INTER_NN));
|
283
|
+
rb_define_const(rb_module, "CV_INTER_LINEAR", INT2FIX(CV_INTER_LINEAR));
|
284
|
+
rb_define_const(rb_module, "CV_INTER_AREA", INT2FIX(CV_INTER_AREA));
|
285
|
+
rb_define_const(rb_module, "CV_INTER_CUBIC", INT2FIX(CV_INTER_CUBIC));
|
286
|
+
|
287
|
+
/* Warp affine optional flags */
|
288
|
+
rb_define_const(rb_module, "CV_WARP_FILL_OUTLIERS", INT2FIX(CV_WARP_FILL_OUTLIERS));
|
289
|
+
rb_define_const(rb_module, "CV_WARP_INVERSE_MAP", INT2FIX(CV_WARP_INVERSE_MAP));
|
290
|
+
|
291
|
+
/* SVD optional flags */
|
292
|
+
rb_define_const(rb_module, "CV_SVD_MODIFY_A", INT2FIX(CV_SVD_MODIFY_A));
|
293
|
+
rb_define_const(rb_module, "CV_SVD_U_T", INT2FIX(CV_SVD_U_T));
|
294
|
+
rb_define_const(rb_module, "CV_SVD_V_T", INT2FIX(CV_SVD_V_T));
|
295
|
+
|
296
|
+
/* Histogram representation format */
|
297
|
+
rb_define_const(rb_module, "CV_HIST_ARRAY", INT2FIX(CV_HIST_ARRAY));
|
298
|
+
rb_define_const(rb_module, "CV_HIST_SPARSE", INT2FIX(CV_HIST_SPARSE));
|
299
|
+
rb_define_const(rb_module, "CV_HIST_TREE", INT2FIX(CV_HIST_TREE));
|
300
|
+
rb_define_const(rb_module, "CV_HIST_UNIFORM", INT2FIX(CV_HIST_UNIFORM));
|
301
|
+
|
302
|
+
/* Histogram comparison method */
|
303
|
+
rb_define_const(rb_module, "CV_COMP_CORREL", INT2FIX(CV_COMP_CORREL));
|
304
|
+
rb_define_const(rb_module, "CV_COMP_CHISQR", INT2FIX(CV_COMP_CHISQR));
|
305
|
+
rb_define_const(rb_module, "CV_COMP_INTERSECT", INT2FIX(CV_COMP_INTERSECT));
|
306
|
+
rb_define_const(rb_module, "CV_COMP_BHATTACHARYYA", INT2FIX(CV_COMP_BHATTACHARYYA));
|
307
|
+
|
308
|
+
VALUE inversion_method = rb_hash_new();
|
309
|
+
/* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */
|
310
|
+
rb_define_const(rb_module, "INVERSION_METHOD", inversion_method);
|
311
|
+
REGISTER_CVMETHOD(inversion_method, "lu", CV_LU);
|
312
|
+
REGISTER_CVMETHOD(inversion_method, "svd", CV_SVD);
|
313
|
+
REGISTER_CVMETHOD(inversion_method, "svd_sym", CV_SVD_SYM);
|
314
|
+
REGISTER_CVMETHOD(inversion_method, "svd_symmetric", CV_SVD_SYM);
|
315
|
+
|
316
|
+
VALUE dxt_flag = rb_hash_new();
|
317
|
+
/* {:forward, :inverse, :scale, :rows}: DFT and DCT flags */
|
318
|
+
rb_define_const(rb_module, "DXT_FLAG", dxt_flag);
|
319
|
+
REGISTER_CVMETHOD(dxt_flag, "forward", CV_DXT_FORWARD);
|
320
|
+
REGISTER_CVMETHOD(dxt_flag, "inverse", CV_DXT_INVERSE);
|
321
|
+
REGISTER_CVMETHOD(dxt_flag, "scale", CV_DXT_SCALE);
|
322
|
+
REGISTER_CVMETHOD(dxt_flag, "rows", CV_DXT_ROWS);
|
323
|
+
|
324
|
+
VALUE interpolation_method = rb_hash_new();
|
325
|
+
/* {:nn, :linear, :area, :cubic}: Interpolation method */
|
326
|
+
rb_define_const(rb_module, "INTERPOLATION_METHOD", interpolation_method);
|
327
|
+
REGISTER_CVMETHOD(interpolation_method, "nn", CV_INTER_NN);
|
328
|
+
REGISTER_CVMETHOD(interpolation_method, "linear", CV_INTER_LINEAR);
|
329
|
+
REGISTER_CVMETHOD(interpolation_method, "area", CV_INTER_AREA);
|
330
|
+
REGISTER_CVMETHOD(interpolation_method, "cubic", CV_INTER_CUBIC);
|
331
|
+
|
332
|
+
VALUE warp_flag = rb_hash_new();
|
333
|
+
/* {:fill_outliers, :inverse_map}: Warp affine optional flags */
|
334
|
+
rb_define_const(rb_module, "WARP_FLAG", warp_flag);
|
335
|
+
REGISTER_CVMETHOD(warp_flag, "fill_outliers", CV_WARP_FILL_OUTLIERS);
|
336
|
+
REGISTER_CVMETHOD(warp_flag, "inverse_map", CV_WARP_INVERSE_MAP);
|
337
|
+
|
338
|
+
VALUE homography_calc_method = rb_hash_new();
|
339
|
+
/* {:all, :ransac, :lmeds}: Methods used to computed homography matrix */
|
340
|
+
rb_define_const(rb_module, "HOMOGRAPHY_CALC_METHOD", homography_calc_method);
|
341
|
+
REGISTER_CVMETHOD(homography_calc_method, "all", 0);
|
342
|
+
REGISTER_CVMETHOD(homography_calc_method, "ransac", CV_RANSAC);
|
343
|
+
REGISTER_CVMETHOD(homography_calc_method, "lmeds", CV_LMEDS);
|
344
|
+
|
345
|
+
VALUE depth = rb_hash_new();
|
346
|
+
/* {:cv8u, :cv8s, :cv16u, :cv16s, :cv32s, :cv32f, :cv64f}: Depth of each pixel. */
|
347
|
+
rb_define_const(rb_module, "DEPTH", depth);
|
348
|
+
REGISTER_CVMETHOD(depth, "cv8u", CV_8U);
|
349
|
+
REGISTER_CVMETHOD(depth, "cv8s", CV_8S);
|
350
|
+
REGISTER_CVMETHOD(depth, "cv16u", CV_16U);
|
351
|
+
REGISTER_CVMETHOD(depth, "cv16s", CV_16S);
|
352
|
+
REGISTER_CVMETHOD(depth, "cv32s", CV_32S);
|
353
|
+
REGISTER_CVMETHOD(depth, "cv32f", CV_32F);
|
354
|
+
REGISTER_CVMETHOD(depth, "cv64f", CV_64F);
|
355
|
+
|
356
|
+
VALUE connectivity = rb_hash_new();
|
357
|
+
/* {:aa(:anti_alias)}: Determined by the closeness of pixel values */
|
358
|
+
rb_define_const(rb_module, "CONNECTIVITY", connectivity);
|
359
|
+
REGISTER_CVMETHOD(connectivity, "aa", CV_AA);
|
360
|
+
REGISTER_CVMETHOD(connectivity, "anti_alias", CV_AA);
|
361
|
+
|
362
|
+
VALUE structuring_element_shape = rb_hash_new();
|
363
|
+
/* {:rect, :cross, :ellipse, :custom}: Shape of the structuring elements */
|
364
|
+
rb_define_const(rb_module, "STRUCTURING_ELEMENT_SHAPE", structuring_element_shape);
|
365
|
+
REGISTER_CVMETHOD(structuring_element_shape, "rect", CV_SHAPE_RECT);
|
366
|
+
REGISTER_CVMETHOD(structuring_element_shape, "cross", CV_SHAPE_CROSS);
|
367
|
+
REGISTER_CVMETHOD(structuring_element_shape, "ellipse", CV_SHAPE_ELLIPSE);
|
368
|
+
REGISTER_CVMETHOD(structuring_element_shape, "custom", CV_SHAPE_CUSTOM);
|
369
|
+
|
370
|
+
VALUE retrieval_mode = rb_hash_new();
|
371
|
+
/* {:external, :list, :ccomp, :tree}: Retrieval mode */
|
372
|
+
rb_define_const(rb_module, "RETRIEVAL_MODE", retrieval_mode);
|
373
|
+
REGISTER_CVMETHOD(retrieval_mode, "external", CV_RETR_EXTERNAL);
|
374
|
+
REGISTER_CVMETHOD(retrieval_mode, "list", CV_RETR_LIST);
|
375
|
+
REGISTER_CVMETHOD(retrieval_mode, "ccomp", CV_RETR_CCOMP);
|
376
|
+
REGISTER_CVMETHOD(retrieval_mode, "tree", CV_RETR_TREE);
|
377
|
+
|
378
|
+
VALUE approx_chain_method = rb_hash_new();
|
379
|
+
/* {:code, :approx_none, :approx_simple, :apporx_tc89_11, :approx_tc89_kcos}: Approximation method */
|
380
|
+
rb_define_const(rb_module, "APPROX_CHAIN_METHOD", approx_chain_method);
|
381
|
+
REGISTER_CVMETHOD(approx_chain_method, "code", CV_CHAIN_CODE);
|
382
|
+
REGISTER_CVMETHOD(approx_chain_method, "approx_none", CV_CHAIN_APPROX_NONE);
|
383
|
+
REGISTER_CVMETHOD(approx_chain_method, "approx_simple", CV_CHAIN_APPROX_SIMPLE);
|
384
|
+
REGISTER_CVMETHOD(approx_chain_method, "approx_tc89_l1", CV_CHAIN_APPROX_TC89_L1);
|
385
|
+
REGISTER_CVMETHOD(approx_chain_method, "approx_tc89_kcos", CV_CHAIN_APPROX_TC89_KCOS);
|
386
|
+
|
387
|
+
VALUE approx_poly_method = rb_hash_new();
|
388
|
+
/* {:dp}: Approximation method (polygon) */
|
389
|
+
rb_define_const(rb_module, "APPROX_POLY_METHOD", approx_poly_method);
|
390
|
+
REGISTER_CVMETHOD(approx_poly_method, "dp", CV_POLY_APPROX_DP);
|
391
|
+
|
392
|
+
VALUE match_template_method = rb_hash_new();
|
393
|
+
/* {:sqdiff, :sqdiff_normed, :ccorr, :ccorr_normed, :ccoeff, :ccoeff_normed}: Match template method */
|
394
|
+
rb_define_const(rb_module, "MATCH_TEMPLATE_METHOD", match_template_method);
|
395
|
+
REGISTER_CVMETHOD(match_template_method, "sqdiff", CV_TM_SQDIFF);
|
396
|
+
REGISTER_CVMETHOD(match_template_method, "sqdiff_normed", CV_TM_SQDIFF_NORMED);
|
397
|
+
REGISTER_CVMETHOD(match_template_method, "ccorr", CV_TM_CCORR);
|
398
|
+
REGISTER_CVMETHOD(match_template_method, "ccorr_normed", CV_TM_CCORR_NORMED);
|
399
|
+
REGISTER_CVMETHOD(match_template_method, "ccoeff", CV_TM_CCOEFF);
|
400
|
+
REGISTER_CVMETHOD(match_template_method, "ccoeff_normed", CV_TM_CCOEFF_NORMED);
|
401
|
+
|
402
|
+
VALUE morphological_operation = rb_hash_new();
|
403
|
+
/* {:open, :close, :gradient, :tophat, :blackhat}: Types of morphological operations */
|
404
|
+
rb_define_const(rb_module, "MORPHOLOGICAL_OPERATION", morphological_operation);
|
405
|
+
REGISTER_CVMETHOD(morphological_operation, "open", CV_MOP_OPEN);
|
406
|
+
REGISTER_CVMETHOD(morphological_operation, "close", CV_MOP_CLOSE);
|
407
|
+
REGISTER_CVMETHOD(morphological_operation, "gradient", CV_MOP_GRADIENT);
|
408
|
+
REGISTER_CVMETHOD(morphological_operation, "tophat", CV_MOP_TOPHAT);
|
409
|
+
REGISTER_CVMETHOD(morphological_operation, "blackhat", CV_MOP_BLACKHAT);
|
410
|
+
|
411
|
+
VALUE smoothing_type = rb_hash_new();
|
412
|
+
/* {:blur_no_scale, :blur, :gaussian, :median, :bilateral}: Types of smoothing */
|
413
|
+
rb_define_const(rb_module, "SMOOTHING_TYPE", smoothing_type);
|
414
|
+
REGISTER_CVMETHOD(smoothing_type, "blur_no_scale", CV_BLUR_NO_SCALE);
|
415
|
+
REGISTER_CVMETHOD(smoothing_type, "blur", CV_BLUR);
|
416
|
+
REGISTER_CVMETHOD(smoothing_type, "gaussian", CV_GAUSSIAN);
|
417
|
+
REGISTER_CVMETHOD(smoothing_type, "median", CV_MEDIAN);
|
418
|
+
REGISTER_CVMETHOD(smoothing_type, "bilateral", CV_BILATERAL);
|
419
|
+
|
420
|
+
VALUE adaptive_method = rb_hash_new();
|
421
|
+
/* {:mean_c, :gaussian_c}: Adaptive thresholding algorithm */
|
422
|
+
rb_define_const(rb_module, "ADAPTIVE_METHOD", adaptive_method);
|
423
|
+
REGISTER_CVMETHOD(adaptive_method, "mean_c", CV_ADAPTIVE_THRESH_MEAN_C);
|
424
|
+
REGISTER_CVMETHOD(adaptive_method, "gaussian_c", CV_ADAPTIVE_THRESH_GAUSSIAN_C);
|
425
|
+
|
426
|
+
VALUE threshold_type = rb_hash_new();
|
427
|
+
/* {:binary, :binary_inv, :trunc, :tozero, :tozero_inv, :otsu} : Thresholding types */
|
428
|
+
rb_define_const(rb_module, "THRESHOLD_TYPE", threshold_type);
|
429
|
+
REGISTER_CVMETHOD(threshold_type, "binary", CV_THRESH_BINARY);
|
430
|
+
REGISTER_CVMETHOD(threshold_type, "binary_inv", CV_THRESH_BINARY_INV);
|
431
|
+
REGISTER_CVMETHOD(threshold_type, "trunc", CV_THRESH_TRUNC);
|
432
|
+
REGISTER_CVMETHOD(threshold_type, "tozero", CV_THRESH_TOZERO);
|
433
|
+
REGISTER_CVMETHOD(threshold_type, "tozero_inv", CV_THRESH_TOZERO_INV);
|
434
|
+
REGISTER_CVMETHOD(threshold_type, "otsu", CV_THRESH_OTSU);
|
435
|
+
|
436
|
+
VALUE hough_transform_method = rb_hash_new();
|
437
|
+
/* {:standard, :probabilistic, :multi_scale} : Hough transform method */
|
438
|
+
rb_define_const(rb_module, "HOUGH_TRANSFORM_METHOD", hough_transform_method);
|
439
|
+
REGISTER_CVMETHOD(hough_transform_method, "standard", CV_HOUGH_STANDARD);
|
440
|
+
REGISTER_CVMETHOD(hough_transform_method, "probabilistic", CV_HOUGH_PROBABILISTIC);
|
441
|
+
REGISTER_CVMETHOD(hough_transform_method, "multi_scale", CV_HOUGH_MULTI_SCALE);
|
442
|
+
REGISTER_CVMETHOD(hough_transform_method, "gradient", CV_HOUGH_GRADIENT);
|
443
|
+
|
444
|
+
VALUE inpaint_method = rb_hash_new();
|
445
|
+
/* {:ns, :telea} : Inpaint method */
|
446
|
+
rb_define_const(rb_module, "INPAINT_METHOD", inpaint_method);
|
447
|
+
REGISTER_CVMETHOD(inpaint_method, "ns", CV_INPAINT_NS);
|
448
|
+
REGISTER_CVMETHOD(inpaint_method, "telea", CV_INPAINT_TELEA);
|
449
|
+
|
450
|
+
VALUE comparison_method = rb_hash_new();
|
451
|
+
/* Comparison method */
|
452
|
+
rb_define_const(rb_module, "COMPARISON_METHOD", comparison_method);
|
453
|
+
REGISTER_CVMETHOD(comparison_method, "i1", CV_CONTOURS_MATCH_I1);
|
454
|
+
REGISTER_CVMETHOD(comparison_method, "i2", CV_CONTOURS_MATCH_I2);
|
455
|
+
REGISTER_CVMETHOD(comparison_method, "i3", CV_CONTOURS_MATCH_I3);
|
456
|
+
|
457
|
+
/* color convert methods */
|
458
|
+
rb_define_module_function(rb_module, "BGR2BGRA", RUBY_METHOD_FUNC(rb_BGR2BGRA), 1);
|
459
|
+
rb_define_module_function(rb_module, "RGB2RGBA", RUBY_METHOD_FUNC(rb_RGB2RGBA), 1);
|
460
|
+
rb_define_module_function(rb_module, "BGRA2BGR", RUBY_METHOD_FUNC(rb_BGRA2BGR), 1);
|
461
|
+
rb_define_module_function(rb_module, "RGBA2RGB", RUBY_METHOD_FUNC(rb_RGBA2RGB), 1);
|
462
|
+
rb_define_module_function(rb_module, "BGR2RGBA", RUBY_METHOD_FUNC(rb_BGR2RGBA), 1);
|
463
|
+
rb_define_module_function(rb_module, "RGB2BGRA", RUBY_METHOD_FUNC(rb_RGB2BGRA), 1);
|
464
|
+
rb_define_module_function(rb_module, "RGBA2BGR", RUBY_METHOD_FUNC(rb_RGBA2BGR), 1);
|
465
|
+
rb_define_module_function(rb_module, "BGRA2RGB", RUBY_METHOD_FUNC(rb_BGRA2RGB), 1);
|
466
|
+
rb_define_module_function(rb_module, "BGR2RGB", RUBY_METHOD_FUNC(rb_BGR2RGB), 1);
|
467
|
+
rb_define_module_function(rb_module, "RGB2BGR", RUBY_METHOD_FUNC(rb_RGB2BGR), 1);
|
468
|
+
rb_define_module_function(rb_module, "BGRA2RGBA", RUBY_METHOD_FUNC(rb_BGRA2RGBA), 1);
|
469
|
+
rb_define_module_function(rb_module, "RGBA2BGRA", RUBY_METHOD_FUNC(rb_RGBA2BGRA), 1);
|
470
|
+
rb_define_module_function(rb_module, "BGR2GRAY", RUBY_METHOD_FUNC(rb_BGR2GRAY), 1);
|
471
|
+
rb_define_module_function(rb_module, "RGB2GRAY", RUBY_METHOD_FUNC(rb_RGB2GRAY), 1);
|
472
|
+
rb_define_module_function(rb_module, "GRAY2BGR", RUBY_METHOD_FUNC(rb_GRAY2BGR), 1);
|
473
|
+
rb_define_module_function(rb_module, "GRAY2RGB", RUBY_METHOD_FUNC(rb_GRAY2RGB), 1);
|
474
|
+
rb_define_module_function(rb_module, "GRAY2BGRA", RUBY_METHOD_FUNC(rb_GRAY2BGRA), 1);
|
475
|
+
rb_define_module_function(rb_module, "GRAY2RGBA", RUBY_METHOD_FUNC(rb_GRAY2RGBA), 1);
|
476
|
+
rb_define_module_function(rb_module, "BGRA2GRAY", RUBY_METHOD_FUNC(rb_BGRA2GRAY), 1);
|
477
|
+
rb_define_module_function(rb_module, "RGBA2GRAY", RUBY_METHOD_FUNC(rb_RGBA2GRAY), 1);
|
478
|
+
rb_define_module_function(rb_module, "BGR2BGR565", RUBY_METHOD_FUNC(rb_BGR2BGR565), 1);
|
479
|
+
rb_define_module_function(rb_module, "RGB2BGR565", RUBY_METHOD_FUNC(rb_RGB2BGR565), 1);
|
480
|
+
rb_define_module_function(rb_module, "BGR5652BGR", RUBY_METHOD_FUNC(rb_BGR5652BGR), 1);
|
481
|
+
rb_define_module_function(rb_module, "BGR5652RGB", RUBY_METHOD_FUNC(rb_BGR5652RGB), 1);
|
482
|
+
rb_define_module_function(rb_module, "BGRA2BGR565", RUBY_METHOD_FUNC(rb_BGRA2BGR565), 1);
|
483
|
+
rb_define_module_function(rb_module, "RGBA2BGR565", RUBY_METHOD_FUNC(rb_RGBA2BGR565), 1);
|
484
|
+
rb_define_module_function(rb_module, "BGR5652BGRA", RUBY_METHOD_FUNC(rb_BGR5652BGRA), 1);
|
485
|
+
rb_define_module_function(rb_module, "BGR5652RGBA", RUBY_METHOD_FUNC(rb_BGR5652RGBA), 1);
|
486
|
+
rb_define_module_function(rb_module, "GRAY2BGR565", RUBY_METHOD_FUNC(rb_GRAY2BGR565), 1);
|
487
|
+
rb_define_module_function(rb_module, "BGR5652GRAY", RUBY_METHOD_FUNC(rb_BGR5652GRAY), 1);
|
488
|
+
rb_define_module_function(rb_module, "BGR2BGR555", RUBY_METHOD_FUNC(rb_BGR2BGR555), 1);
|
489
|
+
rb_define_module_function(rb_module, "RGB2BGR555", RUBY_METHOD_FUNC(rb_RGB2BGR555), 1);
|
490
|
+
rb_define_module_function(rb_module, "BGR5552BGR", RUBY_METHOD_FUNC(rb_BGR5552BGR), 1);
|
491
|
+
rb_define_module_function(rb_module, "BGR5552RGB", RUBY_METHOD_FUNC(rb_BGR5552RGB), 1);
|
492
|
+
rb_define_module_function(rb_module, "BGRA2BGR555", RUBY_METHOD_FUNC(rb_BGRA2BGR555), 1);
|
493
|
+
rb_define_module_function(rb_module, "RGBA2BGR555", RUBY_METHOD_FUNC(rb_RGBA2BGR555), 1);
|
494
|
+
rb_define_module_function(rb_module, "BGR5552BGRA", RUBY_METHOD_FUNC(rb_BGR5552BGRA), 1);
|
495
|
+
rb_define_module_function(rb_module, "BGR5552RGBA", RUBY_METHOD_FUNC(rb_BGR5552RGBA), 1);
|
496
|
+
rb_define_module_function(rb_module, "GRAY2BGR555", RUBY_METHOD_FUNC(rb_GRAY2BGR555), 1);
|
497
|
+
rb_define_module_function(rb_module, "BGR5552GRAY", RUBY_METHOD_FUNC(rb_BGR5552GRAY), 1);
|
498
|
+
rb_define_module_function(rb_module, "BGR2XYZ", RUBY_METHOD_FUNC(rb_BGR2XYZ), 1);
|
499
|
+
rb_define_module_function(rb_module, "RGB2XYZ", RUBY_METHOD_FUNC(rb_RGB2XYZ), 1);
|
500
|
+
rb_define_module_function(rb_module, "XYZ2BGR", RUBY_METHOD_FUNC(rb_XYZ2BGR), 1);
|
501
|
+
rb_define_module_function(rb_module, "XYZ2RGB", RUBY_METHOD_FUNC(rb_XYZ2RGB), 1);
|
502
|
+
rb_define_module_function(rb_module, "BGR2YCrCb", RUBY_METHOD_FUNC(rb_BGR2YCrCb), 1);
|
503
|
+
rb_define_module_function(rb_module, "RGB2YCrCb", RUBY_METHOD_FUNC(rb_RGB2YCrCb), 1);
|
504
|
+
rb_define_module_function(rb_module, "YCrCb2BGR", RUBY_METHOD_FUNC(rb_YCrCb2BGR), 1);
|
505
|
+
rb_define_module_function(rb_module, "YCrCb2RGB", RUBY_METHOD_FUNC(rb_YCrCb2RGB), 1);
|
506
|
+
rb_define_module_function(rb_module, "BGR2HSV", RUBY_METHOD_FUNC(rb_BGR2HSV), 1);
|
507
|
+
rb_define_module_function(rb_module, "RGB2HSV", RUBY_METHOD_FUNC(rb_RGB2HSV), 1);
|
508
|
+
rb_define_module_function(rb_module, "BGR2Lab", RUBY_METHOD_FUNC(rb_BGR2Lab), 1);
|
509
|
+
rb_define_module_function(rb_module, "RGB2Lab", RUBY_METHOD_FUNC(rb_RGB2Lab), 1);
|
510
|
+
rb_define_module_function(rb_module, "BayerBG2BGR", RUBY_METHOD_FUNC(rb_BayerBG2BGR), 1);
|
511
|
+
rb_define_module_function(rb_module, "BayerGB2BGR", RUBY_METHOD_FUNC(rb_BayerGB2BGR), 1);
|
512
|
+
rb_define_module_function(rb_module, "BayerRG2BGR", RUBY_METHOD_FUNC(rb_BayerRG2BGR), 1);
|
513
|
+
rb_define_module_function(rb_module, "BayerGR2BGR", RUBY_METHOD_FUNC(rb_BayerGR2BGR), 1);
|
514
|
+
rb_define_module_function(rb_module, "BayerBG2RGB", RUBY_METHOD_FUNC(rb_BayerBG2RGB), 1);
|
515
|
+
rb_define_module_function(rb_module, "BayerGB2RGB", RUBY_METHOD_FUNC(rb_BayerGB2RGB), 1);
|
516
|
+
rb_define_module_function(rb_module, "BayerRG2RGB", RUBY_METHOD_FUNC(rb_BayerRG2RGB), 1);
|
517
|
+
rb_define_module_function(rb_module, "BayerGR2RGB", RUBY_METHOD_FUNC(rb_BayerGR2RGB), 1);
|
518
|
+
rb_define_module_function(rb_module, "BGR2Luv", RUBY_METHOD_FUNC(rb_BGR2Luv), 1);
|
519
|
+
rb_define_module_function(rb_module, "RGB2Luv", RUBY_METHOD_FUNC(rb_RGB2Luv), 1);
|
520
|
+
rb_define_module_function(rb_module, "BGR2HLS", RUBY_METHOD_FUNC(rb_BGR2HLS), 1);
|
521
|
+
rb_define_module_function(rb_module, "RGB2HLS", RUBY_METHOD_FUNC(rb_RGB2HLS), 1);
|
522
|
+
rb_define_module_function(rb_module, "HSV2BGR", RUBY_METHOD_FUNC(rb_HSV2BGR), 1);
|
523
|
+
rb_define_module_function(rb_module, "HSV2RGB", RUBY_METHOD_FUNC(rb_HSV2RGB), 1);
|
524
|
+
rb_define_module_function(rb_module, "Lab2BGR", RUBY_METHOD_FUNC(rb_Lab2BGR), 1);
|
525
|
+
rb_define_module_function(rb_module, "Lab2RGB", RUBY_METHOD_FUNC(rb_Lab2RGB), 1);
|
526
|
+
rb_define_module_function(rb_module, "Luv2BGR", RUBY_METHOD_FUNC(rb_Luv2BGR), 1);
|
527
|
+
rb_define_module_function(rb_module, "Luv2RGB", RUBY_METHOD_FUNC(rb_Luv2RGB), 1);
|
528
|
+
rb_define_module_function(rb_module, "HLS2BGR", RUBY_METHOD_FUNC(rb_HLS2BGR), 1);
|
529
|
+
rb_define_module_function(rb_module, "HLS2RGB", RUBY_METHOD_FUNC(rb_HLS2RGB), 1);
|
530
|
+
|
531
|
+
rb_define_module_function(rb_module, "build_information", RUBY_METHOD_FUNC(rb_build_information), 0);
|
532
|
+
}
|
533
|
+
|
534
|
+
#define CREATE_CVTCOLOR_FUNC(rb_func_name, c_const_name, src_cn, dest_cn) \
|
535
|
+
VALUE rb_func_name(VALUE klass, VALUE image) \
|
536
|
+
{ \
|
537
|
+
VALUE dest = Qnil; \
|
538
|
+
CvArr* img_ptr = CVARR(image); \
|
539
|
+
try { \
|
540
|
+
int type = cvGetElemType(img_ptr); \
|
541
|
+
if (CV_MAT_CN(type) != src_cn) \
|
542
|
+
rb_raise(rb_eArgError, "argument 1 should be %d-channel.", src_cn); \
|
543
|
+
dest = cCvMat::new_mat_kind_object(cvGetSize(img_ptr), image, CV_MAT_DEPTH(type), dest_cn); \
|
544
|
+
cvCvtColor(img_ptr, CVARR(dest), c_const_name); \
|
545
|
+
} \
|
546
|
+
catch (cv::Exception& e) { \
|
547
|
+
raise_cverror(e); \
|
548
|
+
} \
|
549
|
+
return dest; \
|
550
|
+
}
|
551
|
+
|
552
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2BGRA, CV_BGR2BGRA, 3, 4);
|
553
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2RGBA, CV_RGB2RGBA, 3, 4);
|
554
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR, CV_BGRA2BGR, 4, 3);
|
555
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2RGB, CV_RGBA2RGB, 4, 3);
|
556
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2RGBA, CV_BGR2RGBA, 3, 4);
|
557
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGRA, CV_RGB2BGRA, 3, 4);
|
558
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR, CV_RGBA2BGR, 4, 3);
|
559
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2RGB, CV_BGRA2RGB, 4, 3);
|
560
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2RGB, CV_BGR2RGB, 3, 3);
|
561
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGR, CV_RGB2BGR, 3, 3);
|
562
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2RGBA, CV_BGRA2RGBA, 4, 4);
|
563
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGRA, CV_RGBA2BGRA, 4, 4);
|
564
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2GRAY, CV_BGR2GRAY, 3, 1);
|
565
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2GRAY, CV_RGB2GRAY, 3, 1);
|
566
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR, CV_GRAY2BGR, 1, 3);
|
567
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2RGB, CV_GRAY2RGB, 1, 3);
|
568
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGRA, CV_GRAY2BGRA, 1, 4);
|
569
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2RGBA, CV_GRAY2RGBA, 1, 4);
|
570
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2GRAY, CV_BGRA2GRAY, 4, 1);
|
571
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2GRAY, CV_RGBA2GRAY, 4, 1);
|
572
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2BGR565, CV_BGR2BGR565, 3, 3);
|
573
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGR565, CV_RGB2BGR565, 3, 3);
|
574
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652BGR, CV_BGR5652BGR, 3, 3);
|
575
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652RGB, CV_BGR5652RGB, 3, 3);
|
576
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR565, CV_BGRA2BGR565, 4, 3);
|
577
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR565, CV_RGBA2BGR565, 4, 3);
|
578
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652BGRA, CV_BGR5652BGRA, 3, 4);
|
579
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652RGBA, CV_BGR5652RGBA, 3, 4);
|
580
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR565, CV_GRAY2BGR565, 1, 3);
|
581
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5652GRAY, CV_BGR5652GRAY, 3, 1);
|
582
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2BGR555, CV_BGR2BGR555, 3, 3);
|
583
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2BGR555, CV_RGB2BGR555, 3, 3);
|
584
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552BGR, CV_BGR5552BGR, 3, 3);
|
585
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552RGB, CV_BGR5552RGB, 3, 3);
|
586
|
+
CREATE_CVTCOLOR_FUNC(rb_BGRA2BGR555, CV_BGRA2BGR555, 4, 3);
|
587
|
+
CREATE_CVTCOLOR_FUNC(rb_RGBA2BGR555, CV_RGBA2BGR555, 4, 3);
|
588
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552BGRA, CV_BGR5552BGRA, 3, 4);
|
589
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552RGBA, CV_BGR5552RGBA, 3, 4);
|
590
|
+
CREATE_CVTCOLOR_FUNC(rb_GRAY2BGR555, CV_GRAY2BGR555, 1, 3);
|
591
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR5552GRAY, CV_BGR5552GRAY, 3, 1);
|
592
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2XYZ, CV_BGR2XYZ, 3, 3);
|
593
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2XYZ, CV_RGB2XYZ, 3, 3);
|
594
|
+
CREATE_CVTCOLOR_FUNC(rb_XYZ2BGR, CV_XYZ2BGR, 3, 3);
|
595
|
+
CREATE_CVTCOLOR_FUNC(rb_XYZ2RGB, CV_XYZ2RGB, 3, 3);
|
596
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2YCrCb, CV_BGR2YCrCb, 3, 3);
|
597
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2YCrCb, CV_RGB2YCrCb, 3, 3);
|
598
|
+
CREATE_CVTCOLOR_FUNC(rb_YCrCb2BGR, CV_YCrCb2BGR, 3, 3);
|
599
|
+
CREATE_CVTCOLOR_FUNC(rb_YCrCb2RGB, CV_YCrCb2RGB, 0, 3);
|
600
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2HSV, CV_BGR2HSV, 3, 3);
|
601
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2HSV, CV_RGB2HSV, 3, 3);
|
602
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2Lab, CV_BGR2Lab, 3, 3);
|
603
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2Lab, CV_RGB2Lab, 3, 3);
|
604
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerBG2BGR, CV_BayerBG2BGR, 3, 3);
|
605
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGB2BGR, CV_BayerGB2BGR, 3, 3);
|
606
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerRG2BGR, CV_BayerRG2BGR, 3, 3);
|
607
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGR2BGR, CV_BayerGR2BGR, 3, 3);
|
608
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerBG2RGB, CV_BayerBG2RGB, 3, 3);
|
609
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGB2RGB, CV_BayerGB2RGB, 3, 3);
|
610
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerRG2RGB, CV_BayerRG2RGB, 3, 3);
|
611
|
+
CREATE_CVTCOLOR_FUNC(rb_BayerGR2RGB, CV_BayerGR2RGB, 3, 3);
|
612
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2Luv, CV_BGR2Luv, 3, 3);
|
613
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2Luv, CV_RGB2Luv, 3, 3);
|
614
|
+
CREATE_CVTCOLOR_FUNC(rb_BGR2HLS, CV_BGR2HLS, 3, 3);
|
615
|
+
CREATE_CVTCOLOR_FUNC(rb_RGB2HLS, CV_RGB2HLS, 3, 3);
|
616
|
+
CREATE_CVTCOLOR_FUNC(rb_HSV2BGR, CV_HSV2BGR, 3, 3);
|
617
|
+
CREATE_CVTCOLOR_FUNC(rb_HSV2RGB, CV_HSV2RGB, 3, 3);
|
618
|
+
CREATE_CVTCOLOR_FUNC(rb_Lab2BGR, CV_Lab2BGR, 3, 3);
|
619
|
+
CREATE_CVTCOLOR_FUNC(rb_Lab2RGB, CV_Lab2RGB, 3, 3);
|
620
|
+
CREATE_CVTCOLOR_FUNC(rb_Luv2BGR, CV_Luv2BGR, 3, 3);
|
621
|
+
CREATE_CVTCOLOR_FUNC(rb_Luv2RGB, CV_Luv2RGB, 3, 3);
|
622
|
+
CREATE_CVTCOLOR_FUNC(rb_HLS2BGR, CV_HLS2BGR, 3, 3);
|
623
|
+
CREATE_CVTCOLOR_FUNC(rb_HLS2RGB, CV_HLS2RGB, 3, 3);
|
624
|
+
|
625
|
+
VALUE
|
626
|
+
rb_build_information(VALUE klass)
|
627
|
+
{
|
628
|
+
return rb_str_new_cstr(cv::getBuildInformation().c_str());
|
629
|
+
}
|
630
|
+
|
631
|
+
|
632
|
+
int
|
633
|
+
error_callback(int status, const char *function_name, const char *error_message,
|
634
|
+
const char *file_name, int line, void *user_data)
|
635
|
+
{
|
636
|
+
// dummy
|
637
|
+
return 0;
|
638
|
+
}
|
639
|
+
|
640
|
+
__NAMESPACE_END_OPENCV
|
641
|
+
|
642
|
+
extern "C" {
|
643
|
+
void
|
644
|
+
Init_opencv()
|
645
|
+
{
|
646
|
+
cvRedirectError((CvErrorCallback)mOpenCV::error_callback);
|
647
|
+
|
648
|
+
mOpenCV::define_ruby_module();
|
649
|
+
|
650
|
+
mOpenCV::cCvError::define_ruby_class();
|
651
|
+
mOpenCV::cCvPoint::define_ruby_class();
|
652
|
+
mOpenCV::cCvPoint2D32f::define_ruby_class();
|
653
|
+
mOpenCV::cCvPoint3D32f::define_ruby_class();
|
654
|
+
mOpenCV::cCvSize::define_ruby_class();
|
655
|
+
mOpenCV::cCvSize2D32f::define_ruby_class();
|
656
|
+
mOpenCV::cCvRect::define_ruby_class();
|
657
|
+
mOpenCV::cCvScalar::define_ruby_class();
|
658
|
+
mOpenCV::cCvSlice::define_ruby_class();
|
659
|
+
mOpenCV::cCvTermCriteria::define_ruby_class();
|
660
|
+
mOpenCV::cCvBox2D::define_ruby_class();
|
661
|
+
mOpenCV::cCvFont::define_ruby_class();
|
662
|
+
mOpenCV::cIplConvKernel::define_ruby_class();
|
663
|
+
mOpenCV::cCvMoments::define_ruby_class();
|
664
|
+
mOpenCV::cCvHuMoments::define_ruby_class();
|
665
|
+
mOpenCV::cCvConvexityDefect::define_ruby_class();
|
666
|
+
|
667
|
+
mOpenCV::cCvSURFPoint::define_ruby_class();
|
668
|
+
mOpenCV::cCvSURFParams::define_ruby_class();
|
669
|
+
|
670
|
+
mOpenCV::cCvMemStorage::define_ruby_class();
|
671
|
+
|
672
|
+
mOpenCV::cCvSeq::define_ruby_class();
|
673
|
+
mOpenCV::mCurve::define_ruby_module();
|
674
|
+
mOpenCV::mPointSet::define_ruby_module();
|
675
|
+
mOpenCV::cCvChain::define_ruby_class();
|
676
|
+
mOpenCV::cCvContour::define_ruby_class();
|
677
|
+
mOpenCV::cCvContourTree::define_ruby_class();
|
678
|
+
|
679
|
+
mOpenCV::cCvMat::define_ruby_class();
|
680
|
+
mOpenCV::cIplImage::define_ruby_class();
|
681
|
+
mOpenCV::cCvMatND::define_ruby_class();
|
682
|
+
mOpenCV::cCvSparseMat::define_ruby_class();
|
683
|
+
mOpenCV::cCvHistogram::define_ruby_class();
|
684
|
+
mOpenCV::cCvCapture::define_ruby_class();
|
685
|
+
mOpenCV::cCvVideoWriter::define_ruby_class();
|
686
|
+
|
687
|
+
mOpenCV::cCvLine::define_ruby_class();
|
688
|
+
mOpenCV::cCvTwoPoints::define_ruby_class();
|
689
|
+
mOpenCV::cCvCircle32f::define_ruby_class();
|
690
|
+
|
691
|
+
mOpenCV::cCvConDensation::define_ruby_class();
|
692
|
+
mOpenCV::cCvFeatureTree::define_ruby_class();
|
693
|
+
|
694
|
+
mOpenCV::cCvConnectedComp::define_ruby_class();
|
695
|
+
mOpenCV::cCvAvgComp::define_ruby_class();
|
696
|
+
mOpenCV::cCvHaarClassifierCascade::define_ruby_class();
|
697
|
+
mOpenCV::mGUI::define_ruby_module();
|
698
|
+
mOpenCV::mGUI::cWindow::define_ruby_class();
|
699
|
+
mOpenCV::mGUI::cTrackbar::define_ruby_class();
|
700
|
+
mOpenCV::mGUI::cMouseEvent::define_ruby_class();
|
701
|
+
|
702
|
+
#ifdef HAVE_ML_H
|
703
|
+
/* feature support.
|
704
|
+
mOpenCV::mMachineLearning::define_ruby_module();
|
705
|
+
*/
|
706
|
+
#endif
|
707
|
+
|
708
|
+
cv::initModule_nonfree();
|
709
|
+
}
|
710
|
+
}
|