mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
Merge branch 'develop' into fix/issues-33_opencv_gpulib_not_found
Conflicts: ext/opencv/extconf.rb
This commit is contained in:
commit
b851cd07a5
120 changed files with 8006 additions and 7951 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -21,6 +21,8 @@ log.txt
|
|||
videowriter_result.avi
|
||||
examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg
|
||||
Gemfile.lock
|
||||
.yardoc
|
||||
.RUBYLIBDIR.*
|
||||
.RUBYARCHDIR.*
|
||||
.bundle
|
||||
|
||||
|
|
3
.yardopts
Normal file
3
.yardopts
Normal file
|
@ -0,0 +1,3 @@
|
|||
--load yard_extension.rb
|
||||
ext/opencv/*.cpp
|
||||
|
1
Gemfile
1
Gemfile
|
@ -4,5 +4,6 @@ group :development do
|
|||
gem "hoe"
|
||||
gem "hoe-gemspec"
|
||||
gem "rake-compiler"
|
||||
gem "yard"
|
||||
end
|
||||
|
||||
|
|
16
Manifest.txt
16
Manifest.txt
|
@ -1,4 +1,5 @@
|
|||
.gitignore
|
||||
.yardopts
|
||||
DEVELOPERS_NOTE.md
|
||||
Gemfile
|
||||
History.txt
|
||||
|
@ -34,12 +35,6 @@ examples/images/tiffany.jpg
|
|||
examples/inpaint.rb
|
||||
examples/match_kdtree.rb
|
||||
examples/match_template.rb
|
||||
examples/matching_to_many_images/matching_to_many_images.rb
|
||||
examples/matching_to_many_images/query.png
|
||||
examples/matching_to_many_images/train/1.png
|
||||
examples/matching_to_many_images/train/2.png
|
||||
examples/matching_to_many_images/train/3.png
|
||||
examples/matching_to_many_images/train/trainImages.txt
|
||||
examples/paint.rb
|
||||
examples/snake.rb
|
||||
ext/opencv/algorithm.cpp
|
||||
|
@ -56,8 +51,6 @@ ext/opencv/cvchain.cpp
|
|||
ext/opencv/cvchain.h
|
||||
ext/opencv/cvcircle32f.cpp
|
||||
ext/opencv/cvcircle32f.h
|
||||
ext/opencv/cvcondensation.cpp
|
||||
ext/opencv/cvcondensation.h
|
||||
ext/opencv/cvconnectedcomp.cpp
|
||||
ext/opencv/cvconnectedcomp.h
|
||||
ext/opencv/cvcontour.cpp
|
||||
|
@ -82,8 +75,6 @@ ext/opencv/cvline.cpp
|
|||
ext/opencv/cvline.h
|
||||
ext/opencv/cvmat.cpp
|
||||
ext/opencv/cvmat.h
|
||||
ext/opencv/cvmatnd.cpp
|
||||
ext/opencv/cvmatnd.h
|
||||
ext/opencv/cvmemstorage.cpp
|
||||
ext/opencv/cvmemstorage.h
|
||||
ext/opencv/cvmoments.cpp
|
||||
|
@ -106,8 +97,6 @@ ext/opencv/cvsize2d32f.cpp
|
|||
ext/opencv/cvsize2d32f.h
|
||||
ext/opencv/cvslice.cpp
|
||||
ext/opencv/cvslice.h
|
||||
ext/opencv/cvsparsemat.cpp
|
||||
ext/opencv/cvsparsemat.h
|
||||
ext/opencv/cvsurfparams.cpp
|
||||
ext/opencv/cvsurfparams.h
|
||||
ext/opencv/cvsurfpoint.cpp
|
||||
|
@ -148,7 +137,6 @@ ext/opencv/window.h
|
|||
images/CvMat_sobel.png
|
||||
images/CvMat_sub_rect.png
|
||||
images/CvSeq_relationmap.png
|
||||
images/face_detect_from_lena.jpg
|
||||
lib/opencv.rb
|
||||
lib/opencv/psyched_yaml.rb
|
||||
lib/opencv/version.rb
|
||||
|
@ -222,7 +210,6 @@ test/test_cvmat.rb
|
|||
test/test_cvmat_drawing.rb
|
||||
test/test_cvmat_dxt.rb
|
||||
test/test_cvmat_imageprocessing.rb
|
||||
test/test_cvmat_matching.rb
|
||||
test/test_cvmoments.rb
|
||||
test/test_cvpoint.rb
|
||||
test/test_cvpoint2d32f.rb
|
||||
|
@ -249,3 +236,4 @@ test/test_pointset.rb
|
|||
test/test_preliminary.rb
|
||||
test/test_trackbar.rb
|
||||
test/test_window.rb
|
||||
yard_extension.rb
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
An OpenCV wrapper for Ruby.
|
||||
|
||||
* Web site: <https://github.com/ruby-opencv/ruby-opencv>
|
||||
* Ruby 1.9.3, 2.0.0 and OpenCV 2.4.7 are supported.
|
||||
* Ruby 1.9.3, 2.0.0, 2.1.0 and OpenCV 2.4.8 are supported.
|
||||
|
||||
## Requirement
|
||||
|
||||
|
|
11
Rakefile
11
Rakefile
|
@ -6,6 +6,9 @@ require 'hoe'
|
|||
require 'rake/extensiontask'
|
||||
require 'fileutils'
|
||||
require './lib/opencv/psyched_yaml'
|
||||
require 'yard'
|
||||
require 'yard/rake/yardoc_task'
|
||||
require './yard_extension'
|
||||
|
||||
SO_FILE = 'opencv.so'
|
||||
|
||||
|
@ -27,7 +30,7 @@ hoespec = Hoe.spec 'ruby-opencv' do |s|
|
|||
s.test_globs = ['test/test_*.rb']
|
||||
s.urls = ['https://github.com/ruby-opencv/ruby-opencv/']
|
||||
|
||||
s.extra_dev_deps << ['rake-compiler', '>= 0'] << ['hoe-gemspec']
|
||||
s.extra_dev_deps << ['rake-compiler', '~> 0'] << ['hoe-gemspec', '~> 0']
|
||||
|
||||
Rake::ExtensionTask.new('opencv', spec) do |ext|
|
||||
ext.lib_dir = 'lib'
|
||||
|
@ -87,4 +90,10 @@ task 'gem:precompile' => ['gem'] do
|
|||
FileUtils.rm_rf tmp_dir
|
||||
end
|
||||
|
||||
# yard
|
||||
YARD::Rake::YardocTask.new do |t|
|
||||
t.files = ['lib/**/*.rb', 'ext/**/*.cpp']
|
||||
end
|
||||
|
||||
# vim: syntax=ruby
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ model.set_double('threshold', 0.0);
|
|||
|
||||
# Now the threshold of this model is set to 0.0. A prediction
|
||||
# now returns -1, as it's impossible to have a distance below it
|
||||
predicted_label = model.predict(test_sample)
|
||||
predicted_label, predicted_confidence = model.predict(test_sample)
|
||||
puts "Predicted class = #{predicted_label}"
|
||||
|
||||
# Show some informations about the model, as there's no cool
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
require 'opencv'
|
||||
require 'benchmark'
|
||||
include OpenCV
|
||||
|
||||
data = File.dirname(__FILE__)
|
||||
|
||||
query = CvMat.load File.join(data, 'query.png'), CV_LOAD_IMAGE_GRAYSCALE
|
||||
image_files = ['1.png', '2.png', '3.png'].map{|f| File.join(data, 'train', f)}
|
||||
images = image_files.map{|f| CvMat.load f, CV_LOAD_IMAGE_GRAYSCALE}
|
||||
|
||||
|
||||
matchs = query.match_descriptors(images)
|
||||
|
||||
match_index, count = matchs.max_by {|image_index, count| count}
|
||||
|
||||
puts "max match: #{image_files[match_index]}"
|
Binary file not shown.
Before Width: | Height: | Size: 119 KiB |
Binary file not shown.
Before Width: | Height: | Size: 116 KiB |
Binary file not shown.
Before Width: | Height: | Size: 112 KiB |
Binary file not shown.
Before Width: | Height: | Size: 118 KiB |
|
@ -1,3 +0,0 @@
|
|||
1.png
|
||||
2.png
|
||||
3.png
|
|
@ -252,8 +252,13 @@ rb_name(VALUE self)
|
|||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_ALGORITHM
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
__NAMESPACE_END_ALGORITM
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::Curve
|
||||
*
|
||||
* Curve sequence.
|
||||
* Curve sequence
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CURVE
|
||||
|
@ -24,27 +24,11 @@ rb_module()
|
|||
return module;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_module()
|
||||
{
|
||||
if (module)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
module = rb_define_module_under(opencv, "Curve");
|
||||
rb_define_method(module, "closed?", RUBY_METHOD_FUNC(rb_closed_q), 0);
|
||||
rb_define_method(module, "convex?", RUBY_METHOD_FUNC(rb_convex_q), 0);
|
||||
rb_define_method(module, "hole?", RUBY_METHOD_FUNC(rb_hole_q), 0);
|
||||
rb_define_method(module, "simple?", RUBY_METHOD_FUNC(rb_simple_q), 0);
|
||||
rb_define_method(module, "arc_length", RUBY_METHOD_FUNC(rb_arc_length), -1);
|
||||
}
|
||||
|
||||
/*
|
||||
* If curve is closed, return true. Otherwise return false.
|
||||
* If the curve is closed, return true. Otherwise return false.
|
||||
* @overload closed?
|
||||
* @return [Boolean] Closed or not
|
||||
* @opencv_func CV_IS_SEQ_CLOSED
|
||||
*/
|
||||
VALUE
|
||||
rb_closed_q(VALUE self)
|
||||
|
@ -53,7 +37,10 @@ rb_closed_q(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* If curve is convex, return true. Otherwise return false.
|
||||
* If the curve is convex, return true. Otherwise return false.
|
||||
* @overload convex?
|
||||
* @return [Boolean] Convex or not
|
||||
* @opencv_func CV_IS_SEQ_CONVEX
|
||||
*/
|
||||
VALUE
|
||||
rb_convex_q(VALUE self)
|
||||
|
@ -62,7 +49,10 @@ rb_convex_q(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* If curve is hole(inner contour), return true. Otherwise return false.
|
||||
* If the curve is hole(inner contour), return true. Otherwise return false.
|
||||
* @overload hole?
|
||||
* @return [Boolean] Hole or not
|
||||
* @opencv_func CV_IS_SEQ_HOLE
|
||||
*/
|
||||
VALUE
|
||||
rb_hole_q(VALUE self)
|
||||
|
@ -71,7 +61,10 @@ rb_hole_q(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* no idia.
|
||||
* If the curve is simple, return true. Otherwise return false.
|
||||
* @overload simple?
|
||||
* @return [Boolean] Simple or not
|
||||
* @opencv_func CV_IS_SEQ_SIMPLE
|
||||
*/
|
||||
VALUE
|
||||
rb_simple_q(VALUE self)
|
||||
|
@ -80,15 +73,17 @@ rb_simple_q(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* arc_length(<i>[slice = nil][,is_closed = nil]</i>) -> float
|
||||
*
|
||||
* Calculates contour perimeter or curve length.
|
||||
* <i>slice</i> is starting and ending points of the curve.
|
||||
* <i>is_closed</i> is indicates whether the curve is closed or not. There are 3 cases:
|
||||
* * is_closed = true - the curve is assumed to be unclosed.
|
||||
* * is_closed = false - the curve is assumed to be closed.
|
||||
* * is_closed = nil (default) use self#close?
|
||||
* Calculates length of a curve
|
||||
* @overload arc_length(slice = nil, is_closed = nil)
|
||||
* @param slice [Range,CvSlice,nil] Starting and ending points of the curve.
|
||||
* By default, the whole curve length is calculated.
|
||||
* @param is_closed [Boolean,nil] Indicates whether the curve is closed or not.
|
||||
* There are 3 cases:
|
||||
* * is_closed = true - the curve is assumed to be unclosed.
|
||||
* * is_closed = false - the curve is assumed to be closed.
|
||||
* * is_closed = nil (default) use self#closed?
|
||||
* @return [Number] Length of the curve
|
||||
* @opencv_func cvArcLength
|
||||
*/
|
||||
VALUE
|
||||
rb_arc_length(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -107,6 +102,26 @@ rb_arc_length(int argc, VALUE *argv, VALUE self)
|
|||
return rb_float_new(length);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_module()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (module)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
module = rb_define_module_under(opencv, "Curve");
|
||||
rb_define_method(module, "closed?", RUBY_METHOD_FUNC(rb_closed_q), 0);
|
||||
rb_define_method(module, "convex?", RUBY_METHOD_FUNC(rb_convex_q), 0);
|
||||
rb_define_method(module, "hole?", RUBY_METHOD_FUNC(rb_hole_q), 0);
|
||||
rb_define_method(module, "simple?", RUBY_METHOD_FUNC(rb_simple_q), 0);
|
||||
rb_define_method(module, "arc_length", RUBY_METHOD_FUNC(rb_arc_length), -1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CURVE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CURVE
|
|||
|
||||
VALUE rb_module();
|
||||
|
||||
void define_ruby_module();
|
||||
void init_ruby_module();
|
||||
|
||||
VALUE rb_closed_q(VALUE self);
|
||||
VALUE rb_convex_q(VALUE self);
|
||||
|
|
|
@ -11,13 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvAvgComp
|
||||
*
|
||||
* CvRect with parameter "neighbors".
|
||||
* CvHaarClassifierCascade#detect_object.
|
||||
*
|
||||
* typedef struct CvAvgComp {
|
||||
* CvRect rect;
|
||||
* int neighbors;
|
||||
* }
|
||||
* CvRect with parameter "neighbors"
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_AVGCOMP
|
||||
|
@ -30,23 +24,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvrect = rb_define_class_under(opencv, "CvRect", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv(), cvrect = cCvRect::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "CvAvgComp", cvrect);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "neighbors", RUBY_METHOD_FUNC(rb_neighbors), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -55,7 +32,9 @@ rb_allocate(VALUE klass)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return neighbors.
|
||||
* Return neighbors
|
||||
* @overload neighbors
|
||||
* @return [Integer] neighbors
|
||||
*/
|
||||
VALUE
|
||||
rb_neighbors(VALUE self)
|
||||
|
@ -63,5 +42,23 @@ rb_neighbors(VALUE self)
|
|||
return INT2NUM(CVAVGCOMP(self)->neighbors);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE cvrect = rb_define_class_under(opencv, "CvRect", rb_cObject);
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv(), cvrect = cCvRect::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "CvAvgComp", cvrect);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "neighbors", RUBY_METHOD_FUNC(rb_neighbors), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_AVGCOMP
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_AVGCOMP
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_neighbors(VALUE self);
|
||||
|
|
|
@ -11,12 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvBox2D
|
||||
*
|
||||
* C structure is here.
|
||||
* typdef struct CvBox2D {
|
||||
* CvPoint2D32f center; // center of the box.
|
||||
* CvSize2D32f size; // box width and length
|
||||
* float angle; // angle between the horizonal axis and the first side (i.e length) in radians
|
||||
* } CvBox2D;
|
||||
* Stores coordinates of a rotated rectangle.
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVBOX2D
|
||||
|
@ -29,29 +24,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvBox2D", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
||||
rb_define_method(rb_klass, "center=", RUBY_METHOD_FUNC(rb_set_center), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
|
||||
rb_define_method(rb_klass, "angle=", RUBY_METHOD_FUNC(rb_set_angle), 1);
|
||||
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -59,11 +31,13 @@ rb_allocate(VALUE klass)
|
|||
return Data_Make_Struct(klass, CvBox2D, 0, -1, ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvBox2D.new(<i>[center][, size][, angle]</i>) -> cvbox2d
|
||||
*
|
||||
/*
|
||||
* Create a box
|
||||
* @overload new(center=nil, size=nil, angle=nil)
|
||||
* @param center [CvPoint2D32f,nil] Center of the box
|
||||
* @param size [CvSize,nil] Size of the box
|
||||
* @param angle [Number,nil] Angle between the horizontal axis and the first side in degrees
|
||||
* @return [CvBox2D] New box
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -84,9 +58,9 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* center -> cvpoint2d32f
|
||||
* Return center point of box as CvPoint2D32f.
|
||||
* Returns center point of the box
|
||||
* @overload center
|
||||
* @return [CvPoint2D32f] Center of the box
|
||||
*/
|
||||
VALUE
|
||||
rb_center(VALUE self)
|
||||
|
@ -95,10 +69,10 @@ rb_center(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* center = <i>value</i>
|
||||
*
|
||||
* Set center to <i>value</i>
|
||||
* Set center point of the box
|
||||
* @overload center=value
|
||||
* @param value [CvPoint2D32f] Center of the box
|
||||
* @return [CvBox2D] self
|
||||
*/
|
||||
VALUE
|
||||
rb_set_center(VALUE self, VALUE value)
|
||||
|
@ -108,9 +82,9 @@ rb_set_center(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* size -> cvsize2d32f
|
||||
* Return size of box as CvSize2D32f.
|
||||
* Returns size of the box
|
||||
* @overload size
|
||||
* @return [CvSize2D32f] Size of the box
|
||||
*/
|
||||
VALUE
|
||||
rb_size(VALUE self)
|
||||
|
@ -119,10 +93,10 @@ rb_size(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* size = <i>value</i>
|
||||
*
|
||||
* Set size to <i>value</i>
|
||||
* Set size of the box
|
||||
* @overload size=value
|
||||
* @param value [CvSize2D32f] Size of the box
|
||||
* @return [CvBox2D] self
|
||||
*/
|
||||
VALUE
|
||||
rb_set_size(VALUE self, VALUE value)
|
||||
|
@ -132,10 +106,9 @@ rb_set_size(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* angle -> float
|
||||
*
|
||||
* Return angle of box as Float.
|
||||
* Returns angle of the box
|
||||
* @overload angle
|
||||
* @return [Float] Angle of the box
|
||||
*/
|
||||
VALUE
|
||||
rb_angle(VALUE self)
|
||||
|
@ -144,10 +117,10 @@ rb_angle(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* angle = <i>value</i>
|
||||
*
|
||||
* Set angle to <i>value</i>
|
||||
* Set angle of the box
|
||||
* @overload angle=value
|
||||
* @param value [Number] Angle of the box
|
||||
* @return [CvBox2D] self
|
||||
*/
|
||||
VALUE
|
||||
rb_set_angle(VALUE self, VALUE value)
|
||||
|
@ -157,9 +130,10 @@ rb_set_angle(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* points -> array(include cvpoint2d32f)
|
||||
* Find box vertices. Return Array contain 4 CvPoint2D32f.
|
||||
* Find box vertices
|
||||
* @overload points
|
||||
* @return [Array<CvPoint2D32f>] Vertices of the box
|
||||
* @opencv_func cvBoxPoints
|
||||
*/
|
||||
VALUE
|
||||
rb_points(VALUE self)
|
||||
|
@ -193,5 +167,29 @@ new_object(CvBox2D box)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvBox2D", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
||||
rb_define_method(rb_klass, "center=", RUBY_METHOD_FUNC(rb_set_center), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
|
||||
rb_define_method(rb_klass, "angle=", RUBY_METHOD_FUNC(rb_set_angle), 1);
|
||||
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVBOX2D
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVBOX2D
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvCapture
|
||||
*
|
||||
* Capture image from video stream.
|
||||
*
|
||||
* Class for video capturing from video files or cameras
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCAPTURE
|
||||
|
@ -25,75 +24,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvCapture", rb_cData);
|
||||
|
||||
VALUE video_interface = rb_hash_new();
|
||||
/* {:any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394, :stereo,
|
||||
:tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime}: video source */
|
||||
rb_define_const(rb_klass, "INTERFACE", video_interface);
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("any")), INT2FIX(CV_CAP_ANY));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("mil")), INT2FIX(CV_CAP_MIL));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("vfw")), INT2FIX(CV_CAP_VFW));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l")), INT2FIX(CV_CAP_V4L));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l2")), INT2FIX(CV_CAP_V4L2));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("fireware")), INT2FIX(CV_CAP_FIREWARE));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("ieee1394")), INT2FIX(CV_CAP_IEEE1394));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("dc1394")), INT2FIX(CV_CAP_DC1394));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("cmu1394")), INT2FIX(CV_CAP_CMU1394));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("stereo")), INT2FIX(CV_CAP_STEREO));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx")), INT2FIX(CV_CAP_TYZX));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_left")), INT2FIX(CV_TYZX_LEFT));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_right")), INT2FIX(CV_TYZX_RIGHT));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_color")), INT2FIX(CV_TYZX_COLOR));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_z")), INT2FIX(CV_TYZX_Z));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("qt")), INT2FIX(CV_CAP_QT));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("quicktime")), INT2FIX(CV_CAP_QT));
|
||||
|
||||
rb_define_singleton_method(rb_klass, "open", RUBY_METHOD_FUNC(rb_open), -1);
|
||||
|
||||
rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
|
||||
rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
|
||||
rb_define_method(rb_klass, "query", RUBY_METHOD_FUNC(rb_query), 0);
|
||||
rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_get_millisecond), 0);
|
||||
rb_define_method(rb_klass, "millisecond=", RUBY_METHOD_FUNC(rb_set_millisecond), 1);
|
||||
rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_get_frames), 0);
|
||||
rb_define_method(rb_klass, "frames=", RUBY_METHOD_FUNC(rb_set_frames), 1);
|
||||
rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_get_avi_ratio), 0);
|
||||
rb_define_method(rb_klass, "avi_ratio=", RUBY_METHOD_FUNC(rb_set_avi_ratio), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_get_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_get_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_get_fps), 0);
|
||||
rb_define_method(rb_klass, "fps=", RUBY_METHOD_FUNC(rb_set_fps), 1);
|
||||
rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_get_fourcc), 0);
|
||||
rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_get_frame_count), 0);
|
||||
rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_get_format), 0);
|
||||
rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_get_mode), 0);
|
||||
rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_get_brightness), 0);
|
||||
rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_get_contrast), 0);
|
||||
rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_get_saturation), 0);
|
||||
rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_get_hue), 0);
|
||||
rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_get_gain), 0);
|
||||
rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_get_exposure), 0);
|
||||
rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_get_convert_rgb), 0);
|
||||
rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_get_rectification), 0);
|
||||
}
|
||||
|
||||
void
|
||||
cvcapture_free(void *ptr)
|
||||
{
|
||||
|
@ -102,20 +32,16 @@ cvcapture_free(void *ptr)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvCapture.open(<i>[dev = -1]</i>)
|
||||
*
|
||||
* Reading video stream from the specified file or camera device.
|
||||
* If <i>dev</i> is string (i.e "stream.avi"), reading video stream from file.
|
||||
* If <i>dev</i> is number or symbol(include CvCapture::INTERFACE),
|
||||
* reading video stream from camera.
|
||||
* Currently two camera interfaces can be used on Windows:
|
||||
* * Video for Windows(VFW)
|
||||
* * Matrox Imaging Library(MIL)
|
||||
* and two on Linux
|
||||
* * V4L
|
||||
* * FireWire(IEEE1394).
|
||||
* If there is only one camera or it does not matter what camera to use <i>nil</i> may be passed.
|
||||
* Open video file or a capturing device for video capturing
|
||||
* @scope class
|
||||
* @overload open(dev = nil)
|
||||
* @param dev [String,Fixnum,Simbol,nil] Video capturing device
|
||||
* * If dev is a string (i.e "stream.avi"), reads video stream from a file.
|
||||
* * If dev is a number or symbol (included in CvCapture::INTERFACE), reads video stream from a device.
|
||||
* * If dev is a nil, same as CvCapture.open(:any)
|
||||
* @return [CvCapture] Opened CvCapture instance
|
||||
* @opencv_func cvCaptureFromCAM
|
||||
* @opencv_func cvCaptureFromFile
|
||||
*/
|
||||
VALUE
|
||||
rb_open(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -151,18 +77,11 @@ rb_open(int argc, VALUE *argv, VALUE self)
|
|||
return Data_Wrap_Struct(rb_klass, 0, cvcapture_free, capture);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* grab -> true or false
|
||||
*
|
||||
* Grabbed frame is stored internally. To grab frame
|
||||
* <i>fast</i> that is important for syncronization in case of reading from
|
||||
* several cameras simultaneously. The grabbed frames are not exposed because
|
||||
* they may be stored in compressed format (as defined by camera/driver).
|
||||
* To retrieve the grabbed frame, retrieve should be used.
|
||||
*
|
||||
* If grabbed frame was success, return true. Otherwise return false.
|
||||
* Grabs the next frame from video file or capturing device.
|
||||
* @overload grab
|
||||
* @return [Boolean] If grabbing a frame successed, returns true, otherwise returns false.
|
||||
* @opencv_func cvGrabFrame
|
||||
*/
|
||||
VALUE
|
||||
rb_grab(VALUE self)
|
||||
|
@ -178,10 +97,11 @@ rb_grab(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* retrieve -> IplImage or nil
|
||||
*
|
||||
* Gets the image grabbed with grab.
|
||||
* Decodes and returns the grabbed video frame.
|
||||
* @overload retrieve
|
||||
* @return [IplImage] Grabbed video frame
|
||||
* @return [nil] Failed to grabbing a frame
|
||||
* @opencv_func cvRetrieveFrame
|
||||
*/
|
||||
VALUE
|
||||
rb_retrieve(VALUE self)
|
||||
|
@ -209,10 +129,11 @@ rb_retrieve(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* query -> IplImage or nil
|
||||
*
|
||||
* Grabs and returns a frame camera or file. Just a combination of grab and retrieve in one call.
|
||||
* Grabs, decodes and returns the next video frame.
|
||||
* @overload query
|
||||
* @return [IplImage] Next video frame
|
||||
* @return [nil] Failed to read next video frame
|
||||
* @opencv_func cvQueryFrame
|
||||
*/
|
||||
VALUE
|
||||
rb_query(VALUE self)
|
||||
|
@ -266,30 +187,47 @@ rb_set_capture_property(VALUE self, int id, VALUE value)
|
|||
|
||||
/*
|
||||
* Get film current position in milliseconds or video capture timestamp.
|
||||
* @overload millisecond
|
||||
* @return [Number] Current position of the video file in milliseconds or video capture timestamp
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_POS_MSEC)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_millisecond(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_POS_MSEC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set film current position in milliseconds or video capture timestamp.
|
||||
* @overload millisecond=value
|
||||
* @param value [Number] Position in milliseconds or video capture timestamp.
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_POS_MSEC)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_millisecond(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_set_capture_property(self, CV_CAP_PROP_POS_MSEC, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get 0-based index of the frame to be decoded/captured next
|
||||
* @overload frames
|
||||
* @return [Number] 0-based index of the frame to be decoded/captured next
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_POS_FRAMES)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_frames(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_POS_FRAMES);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set 0-based index of the frame to be decoded/captured next
|
||||
* @overload frames=value
|
||||
* @param value [Number] 0-based index of the frame to be decoded/captured next
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_POS_FRAMES)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_frames(VALUE self, VALUE value)
|
||||
|
@ -297,7 +235,10 @@ rb_set_frames(VALUE self, VALUE value)
|
|||
return rb_set_capture_property(self, CV_CAP_PROP_POS_FRAMES, value);
|
||||
}
|
||||
/*
|
||||
* Get relative position of video file (0 - start of the film, 1 - end of the film)
|
||||
* Get relative position of video file
|
||||
* @overload avi_ratio
|
||||
* @return [Number] Relative position of video file (0: Start of the film, 1: End of the film)
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_POS_AVI_RATIO)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_avi_ratio(VALUE self)
|
||||
|
@ -305,15 +246,23 @@ rb_get_avi_ratio(VALUE self)
|
|||
return rb_get_capture_property(self, CV_CAP_PROP_POS_AVI_RATIO);
|
||||
}
|
||||
/*
|
||||
* Set relative position of video file (0 - start of the film, 1 - end of the film)
|
||||
* Set relative position of video file
|
||||
* @overload avi_ratio=value
|
||||
* @param value [Number] Relative position of video file (0: Start of the film, 1: End of the film)
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_POS_AVI_RATIO)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_avi_ratio(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_set_capture_property(self, CV_CAP_PROP_POS_AVI_RATIO, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get size of frames in the video stream.
|
||||
* @overload size
|
||||
* @return [Size] Size of frames in the video stream.
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FRAME_WIDTH,CV_CAP_PROP_FRAME_HEIGHT)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_size(VALUE self)
|
||||
|
@ -329,8 +278,13 @@ rb_get_size(VALUE self)
|
|||
}
|
||||
return cCvSize::new_object(size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set size of frames in the video stream.
|
||||
* @overload size=value
|
||||
* @param value [CvSize] Size of frames
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FRAME_WIDTH,CV_CAP_PROP_FRAME_HEIGHT)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_size(VALUE self, VALUE value)
|
||||
|
@ -347,56 +301,87 @@ rb_set_size(VALUE self, VALUE value)
|
|||
}
|
||||
return DBL2NUM(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get width of frames in the video stream.
|
||||
* @overload width
|
||||
* @return [Number] Width of frames in the video stream.
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_FRAME_WIDTH)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_width(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_FRAME_WIDTH);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set width of frames in the video stream.
|
||||
* @overload width=value
|
||||
* @param value [Number] Width of frames
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FRAME_WIDTH)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_width(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_set_capture_property(self, CV_CAP_PROP_FRAME_WIDTH, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get height of frames in the video stream.
|
||||
* @overload height
|
||||
* @return [Number] Height of frames in the video stream.
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FRAME_HEIGHT)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_height(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_FRAME_HEIGHT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set height of frames in the video stream.
|
||||
* @overload height=value
|
||||
* @param value [Number] Height of frames
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FRAME_HEIGHT)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_height(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_set_capture_property(self, CV_CAP_PROP_FRAME_HEIGHT, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get frame rate
|
||||
* @overload fps
|
||||
* @return [Number] Frame rate
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FPS)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_fps(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_FPS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set frame rate
|
||||
* @overload fps=value
|
||||
* @param value [Number] Frame rate
|
||||
* @return [Number]
|
||||
* @opencv_func cvSetCaptureProperty (propId=CV_CAP_PROP_FPS)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_fps(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_set_capture_property(self, CV_CAP_PROP_FPS, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get 4character code of codec. see http://www.fourcc.org/
|
||||
* Get 4 character code of codec. see http://www.fourcc.org/
|
||||
* @overload fourcc
|
||||
* @return [Number] Codec code
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FOURCC)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_fourcc(VALUE self)
|
||||
|
@ -406,48 +391,72 @@ rb_get_fourcc(VALUE self)
|
|||
sprintf(str, "%s", (char*)&fourcc);
|
||||
return rb_str_new2(str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get number of frames in video file.
|
||||
* @overload frame_count
|
||||
* @return [Number] Number of frames
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FRAME_COUNT)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_frame_count(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_FRAME_COUNT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the format of the Mat objects returned by CvCapture#retrieve
|
||||
* Get format of images returned by CvCapture#retrieve
|
||||
* @overload format
|
||||
* @return [Number] format
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_FORMAT)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_format(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_FORMAT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a backend-specific value indicating the current capture mode
|
||||
* @overload mode
|
||||
* @return [Number] Backend-specific value indicating the current capture mode
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_MODE)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_mode(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_MODE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get brightness of the image (only for cameras)
|
||||
* @overload brightness
|
||||
* @return [Number] Brightness
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_BRIGHTNESS)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_brightness(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_BRIGHTNESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get contrast of the image (only for cameras)
|
||||
* @overload contrast
|
||||
* @return [Number] Contrast
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_CONTRAST)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_contrast(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_CONTRAST);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get saturation of the image (only for cameras)
|
||||
* @overload saturation
|
||||
* @return [Number] Saturation
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_SATURATION)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_saturation(VALUE self)
|
||||
|
@ -456,30 +465,45 @@ rb_get_saturation(VALUE self)
|
|||
}
|
||||
/*
|
||||
* Get hue of the image (only for cameras)
|
||||
* @overload hue
|
||||
* @return [Number] Hue
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_HUE)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_hue(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_HUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get gain of the image (only for cameras)
|
||||
* @overload gain
|
||||
* @return [Number] Gain
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_GAIN)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_gain(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_GAIN);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get exposure (only for cameras)
|
||||
* @overload exposure
|
||||
* @return [Number] Exposure
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_EXPOSURE)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_exposure(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_EXPOSURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get boolean flags indicating whether images should be converted to RGB
|
||||
* @overload convert_rgb
|
||||
* @return [Boolean] Whether images should be converted to RGB
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_CONVERT_RGB)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_convert_rgb(VALUE self)
|
||||
|
@ -493,14 +517,91 @@ rb_get_convert_rgb(VALUE self)
|
|||
}
|
||||
return flag ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get TOWRITE (note: only supported by DC1394 v 2.x backend currently)
|
||||
* Get rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently)
|
||||
* @overload rectification
|
||||
* @return [Number] Rectification flag
|
||||
* @opencv_func cvGetCaptureProperty (propId=CV_CAP_PROP_RECTIFICATION)
|
||||
*/
|
||||
VALUE
|
||||
rb_get_rectification(VALUE self)
|
||||
{
|
||||
return rb_get_capture_property(self, CV_CAP_PROP_RECTIFICATION);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvCapture", rb_cData);
|
||||
|
||||
VALUE video_interface = rb_hash_new();
|
||||
/*
|
||||
* :any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394,
|
||||
* :stereo, :tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime
|
||||
*/
|
||||
rb_define_const(rb_klass, "INTERFACE", video_interface);
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("any")), INT2FIX(CV_CAP_ANY));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("mil")), INT2FIX(CV_CAP_MIL));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("vfw")), INT2FIX(CV_CAP_VFW));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l")), INT2FIX(CV_CAP_V4L));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("v4l2")), INT2FIX(CV_CAP_V4L2));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("fireware")), INT2FIX(CV_CAP_FIREWARE));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("ieee1394")), INT2FIX(CV_CAP_IEEE1394));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("dc1394")), INT2FIX(CV_CAP_DC1394));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("cmu1394")), INT2FIX(CV_CAP_CMU1394));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("stereo")), INT2FIX(CV_CAP_STEREO));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx")), INT2FIX(CV_CAP_TYZX));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_left")), INT2FIX(CV_TYZX_LEFT));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_right")), INT2FIX(CV_TYZX_RIGHT));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_color")), INT2FIX(CV_TYZX_COLOR));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("tyzx_z")), INT2FIX(CV_TYZX_Z));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("qt")), INT2FIX(CV_CAP_QT));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("quicktime")), INT2FIX(CV_CAP_QT));
|
||||
|
||||
rb_define_singleton_method(rb_klass, "open", RUBY_METHOD_FUNC(rb_open), -1);
|
||||
|
||||
rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
|
||||
rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
|
||||
rb_define_method(rb_klass, "query", RUBY_METHOD_FUNC(rb_query), 0);
|
||||
rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_get_millisecond), 0);
|
||||
rb_define_method(rb_klass, "millisecond=", RUBY_METHOD_FUNC(rb_set_millisecond), 1);
|
||||
rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_get_frames), 0);
|
||||
rb_define_method(rb_klass, "frames=", RUBY_METHOD_FUNC(rb_set_frames), 1);
|
||||
rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_get_avi_ratio), 0);
|
||||
rb_define_method(rb_klass, "avi_ratio=", RUBY_METHOD_FUNC(rb_set_avi_ratio), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_get_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_get_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_get_fps), 0);
|
||||
rb_define_method(rb_klass, "fps=", RUBY_METHOD_FUNC(rb_set_fps), 1);
|
||||
rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_get_fourcc), 0);
|
||||
rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_get_frame_count), 0);
|
||||
rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_get_format), 0);
|
||||
rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_get_mode), 0);
|
||||
rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_get_brightness), 0);
|
||||
rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_get_contrast), 0);
|
||||
rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_get_saturation), 0);
|
||||
rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_get_hue), 0);
|
||||
rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_get_gain), 0);
|
||||
rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_get_exposure), 0);
|
||||
rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_get_convert_rgb), 0);
|
||||
rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_get_rectification), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCAPTURE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ __NAMESPACE_BEGIN_CVCAPTURE
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
void cvcapture_free(void *ptr);
|
||||
VALUE rb_open(int argc, VALUE *argv, VALUE klass);
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvChain
|
||||
*
|
||||
* Freeman chain code.
|
||||
* CvMat#find_contours(:method => :code)
|
||||
* Freeman chain code
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCHAIN
|
||||
|
@ -31,45 +30,19 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvseq = rb_define_class_under(opencv, "CvSeq");
|
||||
* curve = rb_define_module_under(opencv, "Curve");
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvseq = cCvSeq::rb_class();
|
||||
VALUE curve = mCurve::rb_module();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvChain", cvseq);
|
||||
rb_include_module(rb_klass, curve);
|
||||
VALUE approx_chain_option = rb_hash_new();
|
||||
rb_define_const(rb_klass, "APPROX_CHAIN_OPTION", approx_chain_option);
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("method")), ID2SYM(rb_intern("approx_simple")));
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("parameter")), rb_float_new(0));
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("minimal_perimeter")), INT2FIX(0));
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("recursive")), Qfalse);
|
||||
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "origin", RUBY_METHOD_FUNC(rb_origin), 0);
|
||||
rb_define_method(rb_klass, "origin=", RUBY_METHOD_FUNC(rb_set_origin), 1);
|
||||
rb_define_method(rb_klass, "codes", RUBY_METHOD_FUNC(rb_codes), 0);
|
||||
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
||||
rb_define_method(rb_klass, "approx_chains", RUBY_METHOD_FUNC(rb_approx_chains), -1);
|
||||
rb_define_alias(rb_klass, "approx", "approx_chains");
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
return Data_Wrap_Struct(klass, mark_root_object, unregister_object, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new chain code
|
||||
* @overload new(storage=nil)
|
||||
* @param storage [CvMemStorage,nil] Sequence location (If storage is nil, allocates a new storage automatically)
|
||||
* @return [CvChain] New CvChain instance
|
||||
* @opencv_func cvCreateSeq (seq_flags=CV_SEQ_ELTYPE_CODE)
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
|
@ -96,10 +69,9 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* origin -> cvpoint
|
||||
*
|
||||
* Return Freeman chain code origin.
|
||||
* Returns Freeman chain code origin
|
||||
* @overload origin
|
||||
* @return [CvPoint] Origin of the chain code
|
||||
*/
|
||||
VALUE
|
||||
rb_origin(VALUE self)
|
||||
|
@ -108,10 +80,10 @@ rb_origin(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* origin = point -> self
|
||||
*
|
||||
* Set Freeman chain code origin.
|
||||
* Set Freeman chain code origin
|
||||
* @overload origin=value
|
||||
* @param value [CvPoint] Origin of the chain code
|
||||
* @return [CvChain] self
|
||||
*/
|
||||
VALUE
|
||||
rb_set_origin(VALUE self, VALUE origin)
|
||||
|
@ -121,10 +93,11 @@ rb_set_origin(VALUE self, VALUE origin)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* codes -> array(contain fixnum)
|
||||
*
|
||||
* Return Freeman chain codes.
|
||||
* Returns the chain codes
|
||||
* @overload codes
|
||||
* @return [Array<Fixnum>] Chain codes
|
||||
* @opencv_func cvStartReadChainPoints
|
||||
* @opencv_func CV_READ_SEQ_ELEM
|
||||
*/
|
||||
VALUE
|
||||
rb_codes(VALUE self)
|
||||
|
@ -147,10 +120,11 @@ rb_codes(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* points -> array(contain cvpoint)
|
||||
*
|
||||
* Return points that represent by Freeman chain code.
|
||||
* Returns the points of the chain codes
|
||||
* @overload points
|
||||
* @return [Array<CvPoint>] Points of the chain codes
|
||||
* @opencv_func cvStartReadChainPoints
|
||||
* @opencv_func CV_READ_CHAIN_POINT
|
||||
*/
|
||||
VALUE
|
||||
rb_points(VALUE self)
|
||||
|
@ -174,26 +148,17 @@ rb_points(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* approx_chains(<i>[approx_chain_option]</i>) -> cvcontour
|
||||
*
|
||||
* Approximates Freeman chain(s) with polygonal curve.
|
||||
* <i>approx_chain_option</i> should be Hash include these keys.
|
||||
* :method - Approximation method.
|
||||
* :approx_none - translate all the points from the chain code into points;
|
||||
* :approx_simple(default) - compress horizontal, vertical, and diagonal segments, that is,
|
||||
* the function leaves only their ending points.
|
||||
* :approx_tc89_l1
|
||||
* :approx_tc89_kcos - apply one of the flavors of Teh-Chin chain approximation algorithm.
|
||||
* If set the difference between the current pixel and seed pixel is considered,
|
||||
* otherwise difference between neighbor pixels is considered (the range is floating).
|
||||
* :parameter - Method parameter (not used now).
|
||||
* :minimal_perimeter (default 0)
|
||||
* Approximates only those contours whose perimeters are not less than minimal_perimeter. Other chains are removed from the resulting structure.
|
||||
* :recursive (default false)
|
||||
* If not nil or false, the function approximates all chains that access can be obtained to
|
||||
* from self by h_next or v_next links. If 0, the single chain is approximated.
|
||||
*
|
||||
* Approximates Freeman chains with a polygonal curve
|
||||
* @overload approx_chain(options)
|
||||
* @param options [Hash] Parameters
|
||||
* @option options [Symbol] :method Approximation method (see the description of CvMat#find_contours)
|
||||
* @option options [Number] :minimal_perimeter Approximates only those contours whose perimeters
|
||||
* are not less than minimal_perimeter. Other chains are removed from the resulting structure.
|
||||
* @option options [Boolean] :recursive Recursion flag. If it is true, the function approximates
|
||||
* all chains that can be obtained from chain by using the h_next or v_next links.
|
||||
* Otherwise, the single input chain is approximated.
|
||||
* @return [CvSeq<CvPoint>] Polygonal curve
|
||||
* @opencv_func cvApproxChains
|
||||
*/
|
||||
VALUE
|
||||
rb_approx_chains(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -229,5 +194,40 @@ new_object()
|
|||
return cCvSeq::new_sequence(cCvChain::rb_class(), seq, T_FIXNUM, storage);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
|
||||
VALUE curve = rb_define_module_under(opencv, "Curve");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvseq = cCvSeq::rb_class();
|
||||
VALUE curve = mCurve::rb_module();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvChain", cvseq);
|
||||
rb_include_module(rb_klass, curve);
|
||||
VALUE approx_chain_option = rb_hash_new();
|
||||
rb_define_const(rb_klass, "APPROX_CHAIN_OPTION", approx_chain_option);
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("method")), ID2SYM(rb_intern("approx_simple")));
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("parameter")), rb_float_new(0));
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("minimal_perimeter")), INT2FIX(0));
|
||||
rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("recursive")), Qfalse);
|
||||
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "origin", RUBY_METHOD_FUNC(rb_origin), 0);
|
||||
rb_define_method(rb_klass, "origin=", RUBY_METHOD_FUNC(rb_set_origin), 1);
|
||||
rb_define_method(rb_klass, "codes", RUBY_METHOD_FUNC(rb_codes), 0);
|
||||
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
||||
rb_define_method(rb_klass, "approx_chains", RUBY_METHOD_FUNC(rb_approx_chains), -1);
|
||||
rb_define_alias(rb_klass, "approx", "approx_chains");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCHAIN
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_CVCHAIN
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
||||
|
|
|
@ -26,27 +26,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvCircle32f", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
||||
rb_define_method(rb_klass, "radius", RUBY_METHOD_FUNC(rb_radius), 0);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -55,7 +34,9 @@ rb_allocate(VALUE klass)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return parameter on center.
|
||||
* Returns center point of the circle
|
||||
* @overload center
|
||||
* @return [CvPoint2D32f] Center point of the circle
|
||||
*/
|
||||
VALUE
|
||||
rb_center(VALUE self)
|
||||
|
@ -64,7 +45,9 @@ rb_center(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return parameter on radius.
|
||||
* Returns radius of the circle
|
||||
* @overload radius
|
||||
* @return [Number] Radius of the circle
|
||||
*/
|
||||
VALUE
|
||||
rb_radius(VALUE self)
|
||||
|
@ -73,10 +56,10 @@ rb_radius(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* [<i>index</i>]
|
||||
*
|
||||
* Return value of <i>index</i> dimension.
|
||||
* Accesses to parameters of the circle by array-like interface ([X-coordinate, Y-coordinate, radius])
|
||||
* @overload []
|
||||
* @param index [Integer] Index
|
||||
* @return [Number] X-coordinate, Y-coordinate or radius of the circle
|
||||
*/
|
||||
VALUE
|
||||
rb_aref(VALUE self, VALUE index)
|
||||
|
@ -98,6 +81,11 @@ rb_aref(VALUE self, VALUE index)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns parameters of the circle as an array which contains [center<CvPoint2D32f>, radius<Number>]
|
||||
* @overload to_ary
|
||||
* @return [Array<CvPoint2D32f,Number>] An array which contains [center, radius]
|
||||
*/
|
||||
VALUE
|
||||
rb_to_ary(VALUE self)
|
||||
{
|
||||
|
@ -112,5 +100,27 @@ new_object(CvCircle32f circle32f)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvCircle32f", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
||||
rb_define_method(rb_klass, "radius", RUBY_METHOD_FUNC(rb_radius), 0);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCIRCLE32F
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -26,7 +26,7 @@ __NAMESPACE_BEGIN_CVCIRCLE32F
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
|
|
@ -1,282 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvcondensation.cpp -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include "cvcondensation.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvConDensation
|
||||
*
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONDENSATION
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
rb_class()
|
||||
{
|
||||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvConDensation", rb_cObject);
|
||||
rb_define_method(rb_klass, "dp", RUBY_METHOD_FUNC(rb_dp), 0);
|
||||
rb_define_method(rb_klass, "mp", RUBY_METHOD_FUNC(rb_mp), 0);
|
||||
rb_define_method(rb_klass, "dynamic_matrix", RUBY_METHOD_FUNC(rb_dynamic_matrix), 0);
|
||||
rb_define_method(rb_klass, "confidence", RUBY_METHOD_FUNC(rb_confidence), 0);
|
||||
rb_define_method(rb_klass, "cumulative", RUBY_METHOD_FUNC(rb_cumulative), 0);
|
||||
rb_define_method(rb_klass, "state", RUBY_METHOD_FUNC(rb_state), 0);
|
||||
rb_define_method(rb_klass, "samples_num", RUBY_METHOD_FUNC(rb_samples_num), 0);
|
||||
rb_define_method(rb_klass, "init_sample_set", RUBY_METHOD_FUNC(rb_init_sample_set), 2);
|
||||
rb_define_method(rb_klass, "update_by_time", RUBY_METHOD_FUNC(rb_update_by_time), 0);
|
||||
rb_define_alias(rb_klass, "update", "update_by_time");
|
||||
rb_define_method(rb_klass, "each_sample", RUBY_METHOD_FUNC(rb_each_sample), 0);
|
||||
rb_define_method(rb_klass, "calculate_confidence", RUBY_METHOD_FUNC(rb_calculate_confidence), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dp -> int
|
||||
*
|
||||
* Return dimension of state vector
|
||||
*/
|
||||
VALUE
|
||||
rb_dp(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONDENSATION(self)->DP);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* mp -> int
|
||||
*
|
||||
* Return demension of measurement vector.
|
||||
*/
|
||||
VALUE
|
||||
rb_mp(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONDENSATION(self)->MP);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dynamic_matrix -> mat
|
||||
*
|
||||
* Return matrix of the linear Dynamics system.
|
||||
*/
|
||||
VALUE
|
||||
rb_dynamic_matrix(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, cd->DP, CV_MAKETYPE(CV_32F, 1), cd->DynamMatr);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* confidence -> mat
|
||||
*
|
||||
* Return confidence for each sample.
|
||||
*/
|
||||
VALUE
|
||||
rb_confidence(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->SamplesNum, 1, CV_MAKETYPE(CV_32F, 1), cd->flConfidence);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* cumulative -> mat
|
||||
*
|
||||
* Return cumulative confidence.
|
||||
*/
|
||||
VALUE
|
||||
rb_cumulative(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->SamplesNum, 1, CV_MAKETYPE(CV_32F, 1), cd->flCumulative);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* state -> mat
|
||||
*
|
||||
* Return vector of state
|
||||
*/
|
||||
VALUE
|
||||
rb_state(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->State);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* samples_num -> int
|
||||
*
|
||||
* Return number of the samples
|
||||
*/
|
||||
VALUE
|
||||
rb_samples_num(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONDENSATION(self)->SamplesNum);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* init_sample_set(upper, lower)
|
||||
*
|
||||
* Initializes sample set for ConDensation algorithm.
|
||||
* Fills the samples with values within specified(lower to upper) ranges.
|
||||
*/
|
||||
VALUE
|
||||
rb_init_sample_set(VALUE self, VALUE lower, VALUE upper)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat *lower_bound = CVMAT_WITH_CHECK(lower), *upper_bound = CVMAT_WITH_CHECK(upper), lb_stub, ub_stub;
|
||||
int lower_type = lower_bound->type, upper_type = lower_bound->type;
|
||||
try {
|
||||
if (lower_type != CV_32FC1 || lower_bound->cols != 1) {
|
||||
if (CV_MAT_DEPTH(lower_type) == CV_32F) {
|
||||
lower_bound = cvReshape(lower_bound, &lb_stub, 1, lower_bound->rows * lower_bound->cols);
|
||||
}
|
||||
else {
|
||||
lower = cCvMat::new_object(cvSize(lower_bound->rows * lower_bound->cols, 1), CV_MAKETYPE(CV_32S, 1));
|
||||
cvConvertScale(lower_bound, CVARR(lower));
|
||||
lower_bound = CVMAT(lower);
|
||||
}
|
||||
}
|
||||
if (upper_type != CV_32FC1 || upper_bound->cols != 1) {
|
||||
if (CV_MAT_DEPTH(upper_type) == CV_32F) {
|
||||
upper_bound = cvReshape(upper_bound, &ub_stub, 1, upper_bound->rows * upper_bound->cols);
|
||||
}
|
||||
else {
|
||||
upper = cCvMat::new_object(cvSize(upper_bound->rows * upper_bound->cols, 1), CV_MAKETYPE(CV_32F, 1));
|
||||
cvConvertScale(upper_bound, CVARR(upper));
|
||||
upper_bound = CVMAT(upper);
|
||||
}
|
||||
}
|
||||
if (lower_bound->rows != cd->DP || upper_bound->rows != cd->DP) {
|
||||
rb_raise(rb_eTypeError, "sample matrix step unmatch.");
|
||||
}
|
||||
cvConDensInitSampleSet(cd, lower_bound, upper_bound);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* update_by_time
|
||||
*
|
||||
* Estimates subsequent model state.
|
||||
*/
|
||||
VALUE
|
||||
rb_update_by_time(VALUE self)
|
||||
{
|
||||
try {
|
||||
cvConDensUpdateByTime(CVCONDENSATION(self));
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* each_sample {|mat| ... }
|
||||
*
|
||||
* Evaluate each sample by given block.
|
||||
*/
|
||||
VALUE
|
||||
rb_each_sample(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
if (rb_block_given_p()) {
|
||||
try {
|
||||
for (int i = 0; i < cd->SamplesNum; ++i) {
|
||||
CvMat* mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->flSamples[i]);
|
||||
rb_yield(DEPEND_OBJECT(cCvMat::rb_class(), mat, self));
|
||||
}
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* calculate_confidence {|value| ... }
|
||||
*
|
||||
* Evalute each sample by given block, then return value set to confidence.
|
||||
*/
|
||||
VALUE
|
||||
rb_calculate_confidence(VALUE self)
|
||||
{
|
||||
VALUE value;
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
if (rb_block_given_p()) {
|
||||
try {
|
||||
for (int i = 0; i < cd->SamplesNum; ++i) {
|
||||
CvMat* mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->flSamples[i]);
|
||||
value = rb_yield(DEPEND_OBJECT(cCvMat::rb_class(), mat, self));
|
||||
cd->flConfidence[i] = NUM2DBL(value);
|
||||
}
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCONDENSATION
|
||||
__NAMESPACE_END_OPENCV
|
|
@ -1,49 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvcondensation.h -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#ifndef RUBY_OPENCV_CVCONDENSATION_H
|
||||
#define RUBY_OPENCV_CVCONDENSATION_H
|
||||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVCONDENSATION namespace cCvConDensation {
|
||||
#define __NAMESPACE_END_CVCONDENSATION }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONDENSATION
|
||||
|
||||
VALUE rb_class();
|
||||
void define_ruby_class();
|
||||
|
||||
VALUE rb_dp(VALUE self);
|
||||
VALUE rb_mp(VALUE self);
|
||||
VALUE rb_dynamic_matrix(VALUE self);
|
||||
VALUE rb_state(VALUE self);
|
||||
VALUE rb_confidence(VALUE self);
|
||||
VALUE rb_cumulative(VALUE self);
|
||||
VALUE rb_samples_num(VALUE self);
|
||||
|
||||
VALUE rb_init_sample_set(VALUE self, VALUE lower, VALUE upper);
|
||||
VALUE rb_update_by_time(VALUE self);
|
||||
VALUE rb_each_sample(VALUE self);
|
||||
VALUE rb_calculate_confidence(VALUE self);
|
||||
|
||||
__NAMESPACE_END_CVCONDENSATION
|
||||
|
||||
inline CvConDensation*
|
||||
CVCONDENSATION(VALUE object)
|
||||
{
|
||||
CvConDensation *ptr;
|
||||
Data_Get_Struct(object, CvConDensation, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
#endif // RUBY_OPENCV_CVCONDENSATION_H
|
|
@ -10,17 +10,9 @@
|
|||
#include "cvconnectedcomp.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvConnectedComp
|
||||
*
|
||||
*
|
||||
* Connected component
|
||||
* see CvMat#flood_fill
|
||||
*
|
||||
* C structure is here.
|
||||
* typedef struct CvConnectedComp
|
||||
* {
|
||||
* double area;
|
||||
* CvScalar value;
|
||||
* CvRect rect;
|
||||
* CvSeq* contour;
|
||||
* } CvConnectedComp;
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONNECTEDCOMP
|
||||
|
@ -33,28 +25,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvConnectedComp", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "area", RUBY_METHOD_FUNC(rb_area), 0);
|
||||
rb_define_method(rb_klass, "value", RUBY_METHOD_FUNC(rb_value), 0);
|
||||
rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
|
||||
rb_define_method(rb_klass, "rect=", RUBY_METHOD_FUNC(rb_set_rect), 1);
|
||||
rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -62,6 +32,15 @@ rb_allocate(VALUE klass)
|
|||
return Data_Make_Struct(klass, CvConnectedComp, 0, -1, ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @overload new(area = nil, value = nil, rect = nil, contour = nil)
|
||||
* @param area [Number] Area of the segmented component
|
||||
* @param value [CvScalar] Average color of the connected component
|
||||
* @param rect [CvRect] ROI of the segmented component
|
||||
* @param contour [CvSeq] Optional component boundary
|
||||
* @return [CvConnectedComp] self
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
|
@ -80,7 +59,9 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return area of connected component.
|
||||
* Returns area of connected component
|
||||
* @overload area
|
||||
* @return [Number] Area of the connected component
|
||||
*/
|
||||
VALUE
|
||||
rb_area(VALUE self)
|
||||
|
@ -90,6 +71,8 @@ rb_area(VALUE self)
|
|||
|
||||
/*
|
||||
* Return average color of the connected component.
|
||||
* @overload value
|
||||
* @return [CvScalar] Average color of the connected component
|
||||
*/
|
||||
VALUE
|
||||
rb_value(VALUE self)
|
||||
|
@ -98,7 +81,9 @@ rb_value(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return ROI of the component.
|
||||
* Return ROI of the segmented component
|
||||
* @overload rect
|
||||
* @return [CvRect] ROI of the segmented component
|
||||
*/
|
||||
VALUE
|
||||
rb_rect(VALUE self)
|
||||
|
@ -107,7 +92,10 @@ rb_rect(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* Set ROI of the component.
|
||||
* Set ROI of the segmented component
|
||||
* @overload rect=value
|
||||
* @param value [CvRect] ROI to set
|
||||
* @return [CvRect] ROI of the segmented component
|
||||
*/
|
||||
VALUE
|
||||
rb_set_rect(VALUE self, VALUE rect)
|
||||
|
@ -117,7 +105,9 @@ rb_set_rect(VALUE self, VALUE rect)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return optional component boundary
|
||||
* Returns optional component boundary
|
||||
* @overload contour
|
||||
* @return [CvContour] Optional component boundary
|
||||
*/
|
||||
VALUE
|
||||
rb_contour(VALUE self)
|
||||
|
@ -139,5 +129,28 @@ new_object(CvConnectedComp comp)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvConnectedComp", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "area", RUBY_METHOD_FUNC(rb_area), 0);
|
||||
rb_define_method(rb_klass, "value", RUBY_METHOD_FUNC(rb_value), 0);
|
||||
rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
|
||||
rb_define_method(rb_klass, "rect=", RUBY_METHOD_FUNC(rb_set_rect), 1);
|
||||
rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCONNECTEDCOMP
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVCONNECTEDCOMP
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvContour
|
||||
*
|
||||
* Contour.
|
||||
* CvMat#find_contours
|
||||
* Contour
|
||||
*
|
||||
* @see CvMat#find_contours
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONTOUR
|
||||
|
@ -33,56 +34,19 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvseq = rb_define_class_under(opencv, "CvSeq");
|
||||
* curve = rb_define_module_under(opencv, "Curve");
|
||||
* pointset = rb_define_module_under(opencv, "PointSet");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvseq = cCvSeq::rb_class();
|
||||
VALUE curve = mCurve::rb_module();
|
||||
VALUE pointset = mPointSet::rb_module();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvContour", cvseq);
|
||||
rb_include_module(rb_klass, curve);
|
||||
rb_include_module(rb_klass, pointset);
|
||||
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
|
||||
VALUE approx_option = rb_hash_new();
|
||||
rb_define_const(rb_klass, "APPROX_OPTION", approx_option);
|
||||
rb_hash_aset(approx_option, ID2SYM(rb_intern("method")), INT2FIX(CV_POLY_APPROX_DP));
|
||||
rb_hash_aset(approx_option, ID2SYM(rb_intern("accuracy")), rb_float_new(1.0));
|
||||
rb_hash_aset(approx_option, ID2SYM(rb_intern("recursive")), Qfalse);
|
||||
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
|
||||
rb_define_method(rb_klass, "color", RUBY_METHOD_FUNC(rb_color), 0);
|
||||
rb_define_method(rb_klass, "color=", RUBY_METHOD_FUNC(rb_set_color), 1);
|
||||
rb_define_method(rb_klass, "reserved", RUBY_METHOD_FUNC(rb_reserved), 0);
|
||||
rb_define_method(rb_klass, "approx_poly", RUBY_METHOD_FUNC(rb_approx_poly), -1);
|
||||
rb_define_alias(rb_klass, "approx", "approx_poly");
|
||||
rb_define_method(rb_klass, "bounding_rect", RUBY_METHOD_FUNC(rb_bounding_rect), 0);
|
||||
rb_define_method(rb_klass, "create_tree", RUBY_METHOD_FUNC(rb_create_tree), -1);
|
||||
rb_define_method(rb_klass, "in?", RUBY_METHOD_FUNC(rb_in_q), 1);
|
||||
rb_define_method(rb_klass, "measure_distance", RUBY_METHOD_FUNC(rb_measure_distance), 1);
|
||||
rb_define_method(rb_klass, "point_polygon_test", RUBY_METHOD_FUNC(rb_point_polygon_test), 2);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
return Data_Wrap_Struct(klass, mark_root_object, unregister_object, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
* @overload new(storage = nil)
|
||||
* @param [CvMemStorage] storage Sequence location
|
||||
* @return [CvContour] self
|
||||
* @opencv_func cvCreateSeq
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
|
@ -107,18 +71,33 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns bounding box of the contour
|
||||
* @overload rect
|
||||
* @return [CvRect] Bounding box of the contour
|
||||
*/
|
||||
VALUE
|
||||
rb_rect(VALUE self)
|
||||
{
|
||||
return cCvRect::new_object(CVCONTOUR(self)->rect);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns color of the contour
|
||||
* @overload color
|
||||
* @return [Number] Color of the contour
|
||||
*/
|
||||
VALUE
|
||||
rb_color(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONTOUR(self)->color);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set color of the contour
|
||||
* @overload color=value
|
||||
* @param value [Number] Color of the contour
|
||||
*/
|
||||
VALUE
|
||||
rb_set_color(VALUE self, VALUE color)
|
||||
{
|
||||
|
@ -126,6 +105,11 @@ rb_set_color(VALUE self, VALUE color)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns reserved region values of the contour
|
||||
* @overload reserved
|
||||
* @return [Array<Number>] Reserved region values of the contour
|
||||
*/
|
||||
VALUE
|
||||
rb_reserved(VALUE self)
|
||||
{
|
||||
|
@ -136,17 +120,18 @@ rb_reserved(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* approx_poly(<i>approx_poly_option</i>) -> cvcontour
|
||||
*
|
||||
* Approximates polygonal curve(s) with desired precision.
|
||||
* <i>approx_poly_option</i> should be Hash include these keys.
|
||||
* :method - Approximation method.
|
||||
* :dp - corresponds to Douglas-Peucker algorithm.
|
||||
* :accuracy - approximation accuracy. (high-accuracy will create more simple contours)
|
||||
* :recursive - (default false)
|
||||
* If not nil or false, the function approximates all chains that access can be obtained to
|
||||
* from self by h_next or v_next links. If 0, approximated this one.
|
||||
* Approximates polygonal curves with desired precision
|
||||
* @overload approx_poly(options)
|
||||
* @param options [Hash] Parameters
|
||||
* @option options [Symbol] :method Approximation method (default :dp)
|
||||
* * :dp - Douglas-Peucker algorithm.
|
||||
* @option options [Number] :accuracy Parameter specifying the approximation accuracy.
|
||||
* This is the maximum distance between the original curve and its approximation.
|
||||
* @option options [Boolean] :recursive Recursion flag. If true, the function approximates
|
||||
* all the contours accessible from curve by h_next and v_next links.
|
||||
* @return [CvContour] Result of the approximation
|
||||
* @return [nil] Approximation faied
|
||||
* @opencv_func cvApproxPoly
|
||||
*/
|
||||
VALUE
|
||||
rb_approx_poly(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -167,11 +152,10 @@ rb_approx_poly(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* bounding_rect -> rect
|
||||
*
|
||||
* Calculates up-right bounding rectangle of point set.
|
||||
*
|
||||
* @overload bounding_rect
|
||||
* @return [CvRect] Bounding rectangle
|
||||
* @opencv_func cvBoundingRect
|
||||
*/
|
||||
VALUE
|
||||
rb_bounding_rect(VALUE self)
|
||||
|
@ -187,14 +171,12 @@ rb_bounding_rect(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* create_tree([threshold = 0.0]) -> cvcontourtree
|
||||
*
|
||||
* Creates hierarchical representation of contour.
|
||||
* If the parameter <i>threshold</i> is less than or equal to 0,
|
||||
* the method creates full binary tree representation.
|
||||
* If the threshold is greater than 0, the function creates
|
||||
* representation with the precision threshold:
|
||||
* Creates hierarchical representation of contour
|
||||
* @overload create_tree(threshold = 0.0)
|
||||
* @param threshold [Number] If <= 0, the method creates full binary tree representation.
|
||||
* If > 0, the method creates representation with the precision threshold.
|
||||
* @return [CvContourTree] Hierarchical representation of the contour
|
||||
* @opencv_func cvCreateContourTree
|
||||
*/
|
||||
VALUE
|
||||
rb_create_tree(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -213,10 +195,14 @@ rb_create_tree(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* in?(<i>point</i>) -> true or nil or false
|
||||
*
|
||||
* Determines whether the <i>point</i> is inside contour(true), outside(false) or lies on an edge(nil).
|
||||
* Performs a point-in-contour test.
|
||||
* The method determines whether the point is inside a contour, outside,
|
||||
* or lies on an edge (or coincides with a vertex).
|
||||
* @overload in?(point)
|
||||
* @param point [CvPoint2D32f] Point tested against the contour
|
||||
* @return [Boolean] If the point is inside, returns true. If outside, returns false.
|
||||
* If lies on an edge, returns nil.
|
||||
* @opencv_func cvPointPolygonTest
|
||||
*/
|
||||
VALUE
|
||||
rb_in_q(VALUE self, VALUE point)
|
||||
|
@ -232,10 +218,11 @@ rb_in_q(VALUE self, VALUE point)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* measure_distance(<i>point</i>) -> float
|
||||
*
|
||||
* Return distance between the point and the nearest contour edge.
|
||||
* Calculates distance between a point and the nearest contour edgex
|
||||
* @overload measure_distance(point)
|
||||
* @param point [CvPoint2D32f] Point tested against the contour
|
||||
* @return Signed distance between the point and the nearest contour edge
|
||||
* @opencv_func cvPointPolygonTest
|
||||
*/
|
||||
VALUE
|
||||
rb_measure_distance(VALUE self, VALUE point)
|
||||
|
@ -251,11 +238,14 @@ rb_measure_distance(VALUE self, VALUE point)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* point_polygon_test(<i>point, measure_dist</i>) -> float
|
||||
*
|
||||
* Determines whether the point is inside a contour, outside, or lies on an edge (or coinsides with a vertex).
|
||||
* It returns positive, negative or zero value, correspondingly. When measure_dist = false or 0, the return value is +1, -1 and 0, respectively. When measure_dist = true or 1, it is a signed distance between the point and the nearest contour edge.
|
||||
* @overload point_polygon_test(point, measure_dist)
|
||||
* @param point [CvPoint2D32f] Point tested against the contour
|
||||
* @param measure_dist [Boolean] If true, the method estimates the signed distance from the point to
|
||||
* the nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not.
|
||||
* @return [Number] When measure_dist = false, the return value is +1, -1 and 0, respectively.
|
||||
* When measure_dist = true, it is a signed distance between the point and the nearest contour edge.
|
||||
* @opencv_func cvPointPolygonTest
|
||||
*/
|
||||
VALUE
|
||||
rb_point_polygon_test(VALUE self, VALUE point, VALUE measure_dist)
|
||||
|
@ -291,6 +281,52 @@ VALUE new_object()
|
|||
return object;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
|
||||
VALUE curve = rb_define_module_under(opencv, "Curve");
|
||||
VALUE pointset = rb_define_module_under(opencv, "PointSet");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvseq = cCvSeq::rb_class();
|
||||
VALUE curve = mCurve::rb_module();
|
||||
VALUE pointset = mPointSet::rb_module();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvContour", cvseq);
|
||||
rb_include_module(rb_klass, curve);
|
||||
rb_include_module(rb_klass, pointset);
|
||||
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
|
||||
VALUE approx_option = rb_hash_new();
|
||||
rb_define_const(rb_klass, "APPROX_OPTION", approx_option);
|
||||
rb_hash_aset(approx_option, ID2SYM(rb_intern("method")), INT2FIX(CV_POLY_APPROX_DP));
|
||||
rb_hash_aset(approx_option, ID2SYM(rb_intern("accuracy")), rb_float_new(1.0));
|
||||
rb_hash_aset(approx_option, ID2SYM(rb_intern("recursive")), Qfalse);
|
||||
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
|
||||
rb_define_method(rb_klass, "color", RUBY_METHOD_FUNC(rb_color), 0);
|
||||
rb_define_method(rb_klass, "color=", RUBY_METHOD_FUNC(rb_set_color), 1);
|
||||
rb_define_method(rb_klass, "reserved", RUBY_METHOD_FUNC(rb_reserved), 0);
|
||||
rb_define_method(rb_klass, "approx_poly", RUBY_METHOD_FUNC(rb_approx_poly), -1);
|
||||
rb_define_alias(rb_klass, "approx", "approx_poly");
|
||||
rb_define_method(rb_klass, "bounding_rect", RUBY_METHOD_FUNC(rb_bounding_rect), 0);
|
||||
rb_define_method(rb_klass, "create_tree", RUBY_METHOD_FUNC(rb_create_tree), -1);
|
||||
rb_define_method(rb_klass, "in?", RUBY_METHOD_FUNC(rb_in_q), 1);
|
||||
rb_define_method(rb_klass, "measure_distance", RUBY_METHOD_FUNC(rb_measure_distance), 1);
|
||||
rb_define_method(rb_klass, "point_polygon_test", RUBY_METHOD_FUNC(rb_point_polygon_test), 2);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCONTOUR
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_CVCONTOUR
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_rect(VALUE self);
|
||||
|
|
|
@ -11,15 +11,9 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvContourTree
|
||||
*
|
||||
* Contour tree. CvContour#create_tree
|
||||
* Contour tree
|
||||
*
|
||||
* C structure is here.
|
||||
* typedef struct CvContourTree {
|
||||
* CV_SEQUENCE_FIELDS()
|
||||
* CvPoint p1;
|
||||
* CvPoint p2;
|
||||
* } CvContourTree;
|
||||
*
|
||||
* @see CvContour#create_tree
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONTOURTREE
|
||||
|
@ -32,32 +26,22 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvseq = rb_define_class_under(opencv, "CvSeq");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvseq = cCvSeq::rb_class();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvContourTree", cvseq);
|
||||
rb_define_method(rb_klass, "p1", RUBY_METHOD_FUNC(rb_p1), 0);
|
||||
rb_define_method(rb_klass, "p2", RUBY_METHOD_FUNC(rb_p2), 0);
|
||||
rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the first point of the binary tree root segment
|
||||
* @overload p1
|
||||
* @return [CvPoint] First point of the binary tree root segment
|
||||
*/
|
||||
VALUE
|
||||
rb_p1(VALUE self)
|
||||
{
|
||||
return REFER_OBJECT(cCvPoint::rb_class(), &CVCONTOURTREE(self)->p1, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the last point of the binary tree root segment
|
||||
* @overload p2
|
||||
* @return [CvPoint] Last point of the binary tree root segment
|
||||
*/
|
||||
VALUE
|
||||
rb_p2(VALUE self)
|
||||
{
|
||||
|
@ -65,12 +49,14 @@ rb_p2(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* contour(<i>[criteria = 0]</i>) -> cvcontour
|
||||
*
|
||||
* Restores the contour from its binary tree representation.
|
||||
* The parameter criteria determines the accuracy and/or the number of tree levels
|
||||
*
|
||||
* The parameter +criteria+ determines the accuracy and/or the number of tree levels
|
||||
* used for reconstruction, so it is possible to build approximated contour.
|
||||
* @overload contour(criteria = 0)
|
||||
* @param criteria [Integer] Criteria, where to stop reconstruction
|
||||
* @return [CvContour] Contour tree
|
||||
* @opencv_func cvContourFromContourTree
|
||||
*/
|
||||
VALUE
|
||||
rb_contour(VALUE self, VALUE criteria)
|
||||
|
@ -87,5 +73,24 @@ rb_contour(VALUE self, VALUE criteria)
|
|||
return cCvSeq::new_sequence(cCvContour::rb_class(), contour, cCvPoint::rb_class(), storage);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
|
||||
#endif
|
||||
if (rb_klass)
|
||||
return;
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvseq = cCvSeq::rb_class();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvContourTree", cvseq);
|
||||
rb_define_method(rb_klass, "p1", RUBY_METHOD_FUNC(rb_p1), 0);
|
||||
rb_define_method(rb_klass, "p2", RUBY_METHOD_FUNC(rb_p2), 0);
|
||||
rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCONTOURTREE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_CVCONTOURTREE
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_p1(VALUE self);
|
||||
VALUE rb_p2(VALUE self);
|
||||
|
|
|
@ -11,15 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvConvexityDefect
|
||||
*
|
||||
* Convexity.
|
||||
* C structure is here.
|
||||
* typedef struct CvConvexityDefect {
|
||||
* CvPoint* start;
|
||||
* CvPoint* end;
|
||||
* CvPoint* depth_point;
|
||||
* float depth;
|
||||
* } CvConvexityDefect;
|
||||
*
|
||||
* Convexity defect
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONVEXITYDEFECT
|
||||
|
@ -32,30 +24,10 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
|
||||
rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
|
||||
rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
|
||||
rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
|
||||
rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* start -> cvpoint
|
||||
*
|
||||
* Return start point as CvPoint.
|
||||
* Returns the point of the contour where the defect begins
|
||||
* @overload start
|
||||
* @return [CvPoint] Start point of the contour
|
||||
*/
|
||||
VALUE
|
||||
rb_start(VALUE self)
|
||||
|
@ -64,10 +36,9 @@ rb_start(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* end -> cvpoint
|
||||
*
|
||||
* Return end point as CvPoint.
|
||||
* Returns the point of the contour where the defect ends
|
||||
* @overload end
|
||||
* @return [CvPoint] End point of the contour
|
||||
*/
|
||||
VALUE
|
||||
rb_end(VALUE self)
|
||||
|
@ -76,10 +47,9 @@ rb_end(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* depth_point -> cvpoint
|
||||
*
|
||||
* Return depth point as CvPoint.
|
||||
* Returns the farthest from the convex hull point within the defect
|
||||
* @overload depth_point
|
||||
* @return [CvPoint] The farthest from the convex hull point within the defect
|
||||
*/
|
||||
VALUE
|
||||
rb_depth_point(VALUE self)
|
||||
|
@ -88,10 +58,9 @@ rb_depth_point(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* depth -> float
|
||||
*
|
||||
* Return depth.
|
||||
* Returns distance between the farthest point and the convex hull
|
||||
* @overload depth
|
||||
* @return [Number] Distance between the farthest point and the convex hull
|
||||
*/
|
||||
VALUE
|
||||
rb_depth(VALUE self)
|
||||
|
@ -99,5 +68,25 @@ rb_depth(VALUE self)
|
|||
return rb_float_new(CVCONVEXITYDEFECT(self)->depth);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
|
||||
rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
|
||||
rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
|
||||
rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
|
||||
rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCONVEXITYDEFECT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVCONVEXITYDEFECT
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_start(VALUE self);
|
||||
VALUE rb_end(VALUE self);
|
||||
|
|
|
@ -11,51 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvError
|
||||
*
|
||||
* =Internal OpenCV errors
|
||||
*
|
||||
* This module collect OpenCV internal error wrapper classes.
|
||||
* * CvStatusBackTrace
|
||||
* * CvStatusError
|
||||
* * CvStatusInternal
|
||||
* * CvStatusNoMemory
|
||||
* * CvStatusBadArgument
|
||||
* * CvStatusNoConverge
|
||||
* * CvStatusAutoTrace
|
||||
*
|
||||
* * CvHeaderIsNull
|
||||
* * CvBadImageSize
|
||||
* * CvBadOffset
|
||||
* * CvBadDataPointer
|
||||
* * CvBadStep
|
||||
* * CvBadModelOrChannelSequence
|
||||
* * CvBadNumChannels
|
||||
* * CvBadAlphaChannel
|
||||
* * CvBadOrder
|
||||
* * CvBadOrigin
|
||||
* * CvBadAlign
|
||||
* * CvBadCallback
|
||||
* * CvBadTileSize
|
||||
* * CvBadCOI
|
||||
* * CvBadROISize
|
||||
*
|
||||
* * CvMaskIsTiled
|
||||
*
|
||||
* * CvStatusNullPointer
|
||||
* * CvStatusVectorLengthError
|
||||
* * CvStatusFilterStructContentError
|
||||
* * CvStatusKernelStructContentError
|
||||
* * CvStatusFilterOffsetError
|
||||
*
|
||||
* * CvStatusBadSize
|
||||
* * CvStatusDivByZero
|
||||
* * CvStatusInplaceNotSupported
|
||||
* * CvStatusObjectNotFound
|
||||
* * CvStatusUnmatchedFormant
|
||||
* * CvStatusUnsupportedFormats
|
||||
* * CvStatusOutOfRange
|
||||
* * CvStatusParseError
|
||||
* * CvStatusNotImplemented
|
||||
* * CvStsBadMemoryBlock
|
||||
* OpenCV errors
|
||||
*/
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
@ -78,18 +34,32 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void define_ruby_class()
|
||||
VALUE
|
||||
by_code(int error_code)
|
||||
{
|
||||
VALUE klass = 0;
|
||||
st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
|
||||
return klass ? klass : rb_eStandardError;
|
||||
}
|
||||
|
||||
void
|
||||
raise(cv::Exception e)
|
||||
{
|
||||
rb_raise(by_code(e.code), "%s", e.what());
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvError", rb_eStandardError);
|
||||
REGISTER_CVERROR("CvStsBackTrace", CV_StsBackTrace);
|
||||
REGISTER_CVERROR("CvStsError", CV_StsError);
|
||||
|
@ -140,20 +110,6 @@ void define_ruby_class()
|
|||
REGISTER_CVERROR("CvGpuNotSupported", CV_GpuNotSupported);
|
||||
REGISTER_CVERROR("CvGpuApiCallError", CV_GpuApiCallError);
|
||||
}
|
||||
|
||||
VALUE
|
||||
by_code(int error_code)
|
||||
{
|
||||
VALUE klass = 0;
|
||||
st_lookup(cv_error, (st_data_t)error_code, (st_data_t*)&klass);
|
||||
return klass ? klass : rb_eStandardError;
|
||||
}
|
||||
|
||||
void
|
||||
raise(cv::Exception e)
|
||||
{
|
||||
rb_raise(by_code(e.code), "%s", e.what());
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVERROR
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVERROR
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
VALUE by_code(int error_code);
|
||||
void raise(cv::Exception e);
|
||||
|
||||
|
|
|
@ -48,30 +48,12 @@ rb_allocate(VALUE klass)
|
|||
rb_release_feature_tree, ptr);
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
|
||||
|
||||
rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* new(desc)
|
||||
*
|
||||
* Create a new kd-tree
|
||||
* @overload new(desc)
|
||||
* @param desc [CvMat] Descriptors
|
||||
* @return [CvFeatureTree] self
|
||||
* @opencv_func cvCreateKDTree
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(VALUE self, VALUE desc)
|
||||
|
@ -91,18 +73,15 @@ rb_initialize(VALUE self, VALUE desc)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* find_features(desc, rows, cols, k, emax) -> array(results, dist)
|
||||
*
|
||||
* Find features from kd-tree
|
||||
*
|
||||
* desc: m x d matrix of (row-)vectors to find the nearest neighbors of.
|
||||
* k: The number of neighbors to find.
|
||||
* emax: The maximum number of leaves to visit.
|
||||
*
|
||||
* return
|
||||
* results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
|
||||
* dist: m x k matrix of distances to k nearest neighbors.
|
||||
* @overload find_features(desc, k, emax)
|
||||
* @param desc [CvMat] m x d matrix of (row-)vectors to find the nearest neighbors of.
|
||||
* @param k [Integer] The number of neighbors to find.
|
||||
* @param emax [Integer] The maximum number of leaves to visit.
|
||||
* @return [Array] Array of [results, dist]
|
||||
* - results: m x k set of row indices of matching vectors (referring to matrix passed to cvCreateFeatureTree). Contains -1 in some columns if fewer than k neighbors found.
|
||||
* - dist: m x k matrix of distances to k nearest neighbors.
|
||||
* @opencv_func cvFindFeatures
|
||||
*/
|
||||
VALUE
|
||||
rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
|
||||
|
@ -120,6 +99,25 @@ rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax)
|
|||
return rb_assoc_new(results, dist);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvFeatureTree", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
|
||||
|
||||
rb_define_method(rb_klass, "find_features", RUBY_METHOD_FUNC(rb_find_features), 3);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_OPENCV
|
||||
__NAMESPACE_END_CVFEATURETREE
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV
|
|||
__NAMESPACE_BEGIN_CVFEATURETREE
|
||||
|
||||
VALUE rb_class();
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(VALUE self, VALUE desc);
|
||||
VALUE rb_find_features(VALUE self, VALUE desc, VALUE k, VALUE emax);
|
||||
|
|
|
@ -39,48 +39,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvFont", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
VALUE face = rb_hash_new();
|
||||
rb_define_const(rb_klass, "FACE", face);
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("simplex")), INT2FIX(CV_FONT_HERSHEY_SIMPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("plain")), INT2FIX(CV_FONT_HERSHEY_PLAIN));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("duplex")), INT2FIX(CV_FONT_HERSHEY_DUPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("triplex")), INT2FIX(CV_FONT_HERSHEY_TRIPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("complex_small")), INT2FIX(CV_FONT_HERSHEY_COMPLEX_SMALL));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("script_simplex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_SIMPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("script_complex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_COMPLEX));
|
||||
|
||||
VALUE default_option = rb_hash_new();
|
||||
rb_define_const(rb_klass, "FONT_OPTION", default_option);
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("hscale")), rb_float_new(1.0));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("vscale")), rb_float_new(1.0));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("shear")), INT2FIX(0));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("thickness")), INT2FIX(1));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("line_type")), INT2FIX(8));
|
||||
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "face", RUBY_METHOD_FUNC(rb_face), 0);
|
||||
rb_define_method(rb_klass, "hscale", RUBY_METHOD_FUNC(rb_hscale), 0);
|
||||
rb_define_method(rb_klass, "vscale", RUBY_METHOD_FUNC(rb_vscale), 0);
|
||||
rb_define_method(rb_klass, "shear", RUBY_METHOD_FUNC(rb_shear), 0);
|
||||
rb_define_method(rb_klass, "thickness", RUBY_METHOD_FUNC(rb_thickness), 0);
|
||||
rb_define_method(rb_klass, "line_type", RUBY_METHOD_FUNC(rb_line_type), 0);
|
||||
rb_define_method(rb_klass, "italic", RUBY_METHOD_FUNC(rb_italic), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -88,46 +46,32 @@ rb_allocate(VALUE klass)
|
|||
return Data_Make_Struct(klass, CvFont, 0, -1, ptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvFont.new(<i>face[,font_option]</i>) -> font
|
||||
* Create font object
|
||||
* @overload new(face, font_option = nil)
|
||||
* @param face [Symbol] Font name identifier. Only a subset of Hershey fonts (http://sources.isc.org/utils/misc/hershey-font.txt) are supported now:
|
||||
* - :simplex - normal size sans-serif font
|
||||
* - :plain - small size sans-serif font
|
||||
* - :duplex - normal size sans-serif font (more complex than :simplex)
|
||||
* - :complex - normal size serif font
|
||||
* - :triplex - normal size serif font (more complex than :complex)
|
||||
* - :complex_small - smaller version of :complex
|
||||
* - :script_simplex - hand-writing style font
|
||||
* - :script_complex - more complex variant of :script_simplex
|
||||
*
|
||||
* Create font object.
|
||||
* <i>face</i> is font name identifier.
|
||||
*
|
||||
* Only a subset of Hershey fonts (http://sources.isc.org/utils/misc/hershey-font.txt) are supported now:
|
||||
* * :simplex - normal size sans-serif font
|
||||
* * :plain - small size sans-serif font
|
||||
* * :duplex - normal size sans-serif font (more complex than :simplex)
|
||||
* * :complex - normal size serif font
|
||||
* * :triplex - normal size serif font (more complex than :complex)
|
||||
* * :complex_small - smaller version of :complex
|
||||
* * :script_simplex - hand-writing style font
|
||||
* * :script_complex - more complex variant of :script_simplex
|
||||
* @param font_option [Hash] should be Hash include these keys.
|
||||
* @option font_option [Number] :hscale Horizontal scale. If equal to 1.0, the characters have the original width depending on the font type. If equal to 0.5, the characters are of half the original width.
|
||||
* @option font_option [Number] :vscale Vertical scale. If equal to 1.0, the characters have the original height depending on the font type. If equal to 0.5, the characters are of half the original height.
|
||||
* @option font_option [Number] :shear Approximate tangent of the character slope relative to the vertical line. Zero value means a non-italic font, 1.0f means ~45 degree slope, etc.
|
||||
* @option font_option [Number] :thickness Thickness of the text strokes.
|
||||
* @option font_option [Number] :line_type Type of the strokes, see CvMat#Line description.
|
||||
* @option font_option [Number] :italic If value is not nil or false that means italic or oblique font.
|
||||
*
|
||||
* <i>font_option</i> should be Hash include these keys.
|
||||
* :hscale
|
||||
* Horizontal scale. If equal to 1.0, the characters have the original width depending on the font type.
|
||||
* If equal to 0.5, the characters are of half the original width.
|
||||
* :vscale
|
||||
* Vertical scale. If equal to 1.0, the characters have the original height depending on the font type.
|
||||
* If equal to 0.5, the characters are of half the original height.
|
||||
* :shear
|
||||
* Approximate tangent of the character slope relative to the vertical line.
|
||||
* Zero value means a non-italic font, 1.0f means ~45degree slope, etc.
|
||||
* :thickness
|
||||
* Thickness of the text strokes.
|
||||
* :line_type
|
||||
* Type of the strokes, see CvMat#Line description.
|
||||
* :italic
|
||||
* If value is not nil or false that means italic or oblique font.
|
||||
*
|
||||
* note: <i>font_option</i>'s default value is CvFont::FONT_OPTION.
|
||||
*
|
||||
* e.g. Create Font
|
||||
* @example Create Font
|
||||
* OpenCV::CvFont.new(:simplex, :hscale => 2, :vslace => 2, :italic => true)
|
||||
* # create 2x bigger than normal, italic type font.
|
||||
*
|
||||
* @opencv_func cvInitFont
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -161,48 +105,124 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns font face
|
||||
* @overload face
|
||||
* @return [Fixnum] Font face
|
||||
*/
|
||||
VALUE
|
||||
rb_face(VALUE self)
|
||||
{
|
||||
return INT2FIX(CVFONT(self)->font_face);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hscale
|
||||
* @overload hscale
|
||||
* @return [Number] hscale
|
||||
*/
|
||||
VALUE
|
||||
rb_hscale(VALUE self)
|
||||
{
|
||||
return rb_float_new(CVFONT(self)->hscale);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns vscale
|
||||
* @overload vscale
|
||||
* @return [Number] vscale
|
||||
*/
|
||||
VALUE
|
||||
rb_vscale(VALUE self)
|
||||
{
|
||||
return rb_float_new(CVFONT(self)->vscale);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns shear
|
||||
* @overload shear
|
||||
* @return [Number] shear
|
||||
*/
|
||||
VALUE
|
||||
rb_shear(VALUE self)
|
||||
{
|
||||
return rb_float_new(CVFONT(self)->shear);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns thickness
|
||||
* @overload thickness
|
||||
* @return [Fixnum] thickness
|
||||
*/
|
||||
VALUE
|
||||
rb_thickness(VALUE self)
|
||||
{
|
||||
return INT2FIX(CVFONT(self)->thickness);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns line type
|
||||
* @overload line_type
|
||||
* @return [Fixnum] line_type
|
||||
*/
|
||||
VALUE
|
||||
rb_line_type(VALUE self)
|
||||
{
|
||||
return INT2FIX(CVFONT(self)->line_type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns italic or not
|
||||
* @overload italic
|
||||
* @return [Boolean] self is italic or not
|
||||
*/
|
||||
VALUE
|
||||
rb_italic(VALUE self)
|
||||
{
|
||||
return ((CVFONT(self)->font_face & CV_FONT_ITALIC) > 0) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvFont", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
VALUE face = rb_hash_new();
|
||||
rb_define_const(rb_klass, "FACE", face);
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("simplex")), INT2FIX(CV_FONT_HERSHEY_SIMPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("plain")), INT2FIX(CV_FONT_HERSHEY_PLAIN));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("duplex")), INT2FIX(CV_FONT_HERSHEY_DUPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("triplex")), INT2FIX(CV_FONT_HERSHEY_TRIPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("complex_small")), INT2FIX(CV_FONT_HERSHEY_COMPLEX_SMALL));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("script_simplex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_SIMPLEX));
|
||||
rb_hash_aset(face, ID2SYM(rb_intern("script_complex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_COMPLEX));
|
||||
|
||||
VALUE default_option = rb_hash_new();
|
||||
rb_define_const(rb_klass, "FONT_OPTION", default_option);
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("hscale")), rb_float_new(1.0));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("vscale")), rb_float_new(1.0));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("shear")), INT2FIX(0));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("thickness")), INT2FIX(1));
|
||||
rb_hash_aset(default_option, ID2SYM(rb_intern("line_type")), INT2FIX(8));
|
||||
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "face", RUBY_METHOD_FUNC(rb_face), 0);
|
||||
rb_define_method(rb_klass, "hscale", RUBY_METHOD_FUNC(rb_hscale), 0);
|
||||
rb_define_method(rb_klass, "vscale", RUBY_METHOD_FUNC(rb_vscale), 0);
|
||||
rb_define_method(rb_klass, "shear", RUBY_METHOD_FUNC(rb_shear), 0);
|
||||
rb_define_method(rb_klass, "thickness", RUBY_METHOD_FUNC(rb_thickness), 0);
|
||||
rb_define_method(rb_klass, "line_type", RUBY_METHOD_FUNC(rb_line_type), 0);
|
||||
rb_define_method(rb_klass, "italic", RUBY_METHOD_FUNC(rb_italic), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVFONT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -28,7 +28,7 @@ __NAMESPACE_BEGIN_CVFONT
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
|
|
@ -11,11 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvHaarClassifierCascade
|
||||
*
|
||||
* CvHaarClassifierCascade object is "fast-object-detector".
|
||||
* This detector can discover object (e.g. human's face) from image.
|
||||
*
|
||||
* Find face-area from picture "lena"...
|
||||
* link:../images/face_detect_from_lena.jpg
|
||||
* Haar Feature-based Cascade Classifier for Object Detection
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE
|
||||
|
@ -28,23 +24,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvHaarClassifierCascade", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load), 1);
|
||||
rb_define_method(rb_klass, "detect_objects", RUBY_METHOD_FUNC(rb_detect_objects), -1);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -61,18 +40,13 @@ cvhaarclassifiercascade_free(void* ptr)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvHaarClassiferCascade.load(<i>path</i>) -> object-detector
|
||||
*
|
||||
* Load trained cascade of haar classifers from file.
|
||||
* Object detection classifiers are stored in XML or YAML files.
|
||||
* sample of object detection classifier files is included by OpenCV.
|
||||
*
|
||||
* You can found these at
|
||||
* C:\Program Files\OpenCV\data\haarcascades\*.xml (Windows, default install path)
|
||||
*
|
||||
* e.g. you want to try to detect human's face.
|
||||
* detector = CvHaarClassiferCascade.load("haarcascade_frontalface_alt.xml")
|
||||
* @overload load(filename)
|
||||
* @param filename [String] Haar classifer file name
|
||||
* @return [CvHaarClassifierCascade] Object detector
|
||||
* @scope class
|
||||
* @opencv_func cvLoad
|
||||
*/
|
||||
VALUE
|
||||
rb_load(VALUE klass, VALUE path)
|
||||
|
@ -90,35 +64,23 @@ rb_load(VALUE klass, VALUE path)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* detect_objects(image[, options]) -> cvseq(include CvAvgComp object)
|
||||
* detect_objects(image[, options]){|cmp| ... } -> cvseq(include CvAvgComp object)
|
||||
* Detects objects of different sizes in the input image.
|
||||
*
|
||||
* Detects objects in the image. This method finds rectangular regions in the
|
||||
* given image that are likely to contain objects the cascade has been trained
|
||||
* for and return those regions as a sequence of rectangles.
|
||||
*
|
||||
* * <i>option</i> should be Hash include these keys.
|
||||
* :scale_factor (should be > 1.0)
|
||||
* The factor by which the search window is scaled between the subsequent scans,
|
||||
* 1.1 mean increasing window by 10%.
|
||||
* :storage
|
||||
* @overload detect_objects(image, options = nil)
|
||||
* @param image [CvMat,IplImage] Matrix of the type CV_8U containing an image where objects are detected.
|
||||
* @param options [Hash] Options
|
||||
* @option options [Number] :scale_factor
|
||||
* Parameter specifying how much the image size is reduced at each image scale.
|
||||
* @option options [Number] :storage
|
||||
* Memory storage to store the resultant sequence of the object candidate rectangles
|
||||
* :flags
|
||||
* Mode of operation. Currently the only flag that may be specified is CV_HAAR_DO_CANNY_PRUNING .
|
||||
* If it is set, the function uses Canny edge detector to reject some image regions that contain
|
||||
* too few or too much edges and thus can not contain the searched object. The particular threshold
|
||||
* values are tuned for face detection and in this case the pruning speeds up the processing
|
||||
* :min_neighbors
|
||||
* Minimum number (minus 1) of neighbor rectangles that makes up an object.
|
||||
* All the groups of a smaller number of rectangles than min_neighbors - 1 are rejected.
|
||||
* If min_neighbors is 0, the function does not any grouping at all and returns all the detected
|
||||
* candidate rectangles, whitch many be useful if the user wants to apply a customized grouping procedure.
|
||||
* :min_size
|
||||
* Minimum window size. By default, it is set to size of samples the classifier has been
|
||||
* trained on (~20x20 for face detection).
|
||||
* :max_size
|
||||
* aximum window size to use. By default, it is set to the size of the image.
|
||||
* @option options [Number] :min_neighbors
|
||||
* Parameter specifying how many neighbors each candidate rectangle should have to retain it.
|
||||
* @option options [CvSize] :min_size
|
||||
* Minimum possible object size. Objects smaller than that are ignored.
|
||||
* @option options [CvSize] :max_size
|
||||
* Maximum possible object size. Objects larger than that are ignored.
|
||||
* @return [CvSeq<CvAvgComp>] Detected objects as a list of rectangles
|
||||
* @opencv_func cvHaarDetectObjects
|
||||
*/
|
||||
VALUE
|
||||
rb_detect_objects(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -164,5 +126,23 @@ rb_detect_objects(int argc, VALUE *argv, VALUE self)
|
|||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvHaarClassifierCascade", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load), 1);
|
||||
rb_define_method(rb_klass, "detect_objects", RUBY_METHOD_FUNC(rb_detect_objects), -1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVHAARCLASSIFERCASCADE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvHistogram
|
||||
*
|
||||
* Muti-dimensional histogram.
|
||||
* Multi-dimensional histogram.
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVHISTOGRAM
|
||||
|
@ -24,57 +24,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvHistogram", rb_cObject);
|
||||
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "is_uniform?", RUBY_METHOD_FUNC(rb_is_uniform), 0);
|
||||
rb_define_method(rb_klass, "is_sparse?", RUBY_METHOD_FUNC(rb_is_sparse), 0);
|
||||
rb_define_method(rb_klass, "has_range?", RUBY_METHOD_FUNC(rb_has_range), 0);
|
||||
rb_define_method(rb_klass, "dims", RUBY_METHOD_FUNC(rb_dims), 0);
|
||||
rb_define_method(rb_klass, "calc_hist", RUBY_METHOD_FUNC(rb_calc_hist), -1);
|
||||
rb_define_method(rb_klass, "calc_hist!", RUBY_METHOD_FUNC(rb_calc_hist_bang), -1);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), -2);
|
||||
rb_define_alias(rb_klass, "query_hist_value", "[]");
|
||||
rb_define_method(rb_klass, "min_max_value", RUBY_METHOD_FUNC(rb_min_max_value), 0);
|
||||
rb_define_method(rb_klass, "copy_hist", RUBY_METHOD_FUNC(rb_copy_hist), 0);
|
||||
|
||||
rb_define_method(rb_klass, "clear_hist", RUBY_METHOD_FUNC(rb_clear_hist), 0);
|
||||
rb_define_alias(rb_klass, "clear", "clear_hist");
|
||||
rb_define_method(rb_klass, "clear_hist!", RUBY_METHOD_FUNC(rb_clear_hist_bang), 0);
|
||||
rb_define_alias(rb_klass, "clear!", "clear_hist!");
|
||||
|
||||
rb_define_method(rb_klass, "normalize_hist", RUBY_METHOD_FUNC(rb_normalize_hist), 1);
|
||||
rb_define_alias(rb_klass, "normalize", "normalize_hist");
|
||||
rb_define_method(rb_klass, "normalize_hist!", RUBY_METHOD_FUNC(rb_normalize_hist_bang), 1);
|
||||
rb_define_alias(rb_klass, "normalize!", "normalize_hist!");
|
||||
|
||||
rb_define_method(rb_klass, "thresh_hist", RUBY_METHOD_FUNC(rb_thresh_hist), 1);
|
||||
rb_define_alias(rb_klass, "thresh", "thresh_hist");
|
||||
rb_define_method(rb_klass, "thresh_hist!", RUBY_METHOD_FUNC(rb_thresh_hist_bang), 1);
|
||||
rb_define_alias(rb_klass, "thresh!", "thresh_hist!");
|
||||
|
||||
rb_define_method(rb_klass, "set_hist_bin_ranges", RUBY_METHOD_FUNC(rb_set_hist_bin_ranges), -1);
|
||||
rb_define_method(rb_klass, "set_hist_bin_ranges!", RUBY_METHOD_FUNC(rb_set_hist_bin_ranges_bang), -1);
|
||||
|
||||
rb_define_method(rb_klass, "calc_back_project", RUBY_METHOD_FUNC(rb_calc_back_project), 1);
|
||||
rb_define_method(rb_klass, "calc_back_project_patch", RUBY_METHOD_FUNC(rb_calc_back_project_patch), 4);
|
||||
|
||||
rb_define_singleton_method(rb_klass, "calc_prob_density", RUBY_METHOD_FUNC(rb_calc_prob_density), -1);
|
||||
rb_define_singleton_method(rb_klass, "compare_hist", RUBY_METHOD_FUNC(rb_compare_hist), 3);
|
||||
}
|
||||
|
||||
void
|
||||
release_hist(void* ptr)
|
||||
{
|
||||
|
@ -119,6 +68,23 @@ ary2intptr(VALUE ary, int* buff)
|
|||
return buff;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a histogram
|
||||
* @overload new(dims, sizes, type, ranges=nil, uniform=true)
|
||||
* @param dims [Integer] Number of histogram dimensions
|
||||
* @param sizes [Array<Integer>] Array of the histogram dimension sizes
|
||||
* @param type [Integer]
|
||||
* Histogram representation format. CV_HIST_ARRAY means that the histogram data is represented
|
||||
* as a multi-dimensional dense array CvMatND. CV_HIST_SPARSE means that histogram data is
|
||||
* represented as a multi-dimensional sparse array CvSparseMat.
|
||||
* @param ranges [Array<Integer>]
|
||||
* Array of ranges for the histogram bins. Its meaning depends on the uniform parameter value.
|
||||
* The ranges are used when the histogram is calculated or backprojected to determine which
|
||||
* histogram bin corresponds to which value/tuple of values from the input image(s).
|
||||
* @param uniform [Boolean] Uniformity flag.
|
||||
* @return [CvHistogram] Histogram
|
||||
* @opencv_func cvCreateHist
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
|
@ -157,9 +123,10 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* is_uniform? -> true or false
|
||||
*
|
||||
* Returns <tt>self</tt> is uniform histogram or not
|
||||
* @overload is_uniform?
|
||||
* @return [Boolean] Uniform or not
|
||||
* @opencv_func CV_IS_UNIFORM_HIST
|
||||
*/
|
||||
VALUE
|
||||
rb_is_uniform(VALUE self)
|
||||
|
@ -168,9 +135,10 @@ rb_is_uniform(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* is_sparse? -> true or false
|
||||
*
|
||||
* Returns <tt>self</tt> is sparse histogram or not
|
||||
* @overload is_sparse?
|
||||
* @return [Boolean] Sparse or not
|
||||
* @opencv_func CV_IS_SPARSE_HIST
|
||||
*/
|
||||
VALUE
|
||||
rb_is_sparse(VALUE self)
|
||||
|
@ -179,21 +147,45 @@ rb_is_sparse(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* has_range? -> true or false
|
||||
*/
|
||||
* Returns <tt>self</tt> has range or not
|
||||
* @overload has_range?
|
||||
* @return [Boolean] Has range or not
|
||||
* @opencv_func CV_HIST_HAS_RANGES
|
||||
*/
|
||||
VALUE
|
||||
rb_has_range(VALUE self)
|
||||
{
|
||||
return CV_HIST_HAS_RANGES(CVHISTOGRAM(self)) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculates a histogram of a set of arrays.
|
||||
* @overload calc_hist(images, accumulate=nil, mask=nil)
|
||||
* @param images [Array<IplImage>]
|
||||
* Source arrays. They all should have the same depth, CV_8U or CV_32F, and the same size.
|
||||
* Each of them can have an arbitrary number of channels.
|
||||
* @param accumulate [Boolean]
|
||||
* Accumulation flag. If it is set, the histogram is not cleared in the beginning when it is allocated.
|
||||
* This feature enables you to compute a single histogram from several sets of arrays,
|
||||
* or to update the histogram in time.
|
||||
* @param mask [CvMat]
|
||||
* Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as images[i].
|
||||
* The non-zero mask elements mark the array elements counted in the histogram.
|
||||
* @return [CvHistogram] Histogram of a set of arrays
|
||||
* @opencv_func cvCalcHist
|
||||
*/
|
||||
VALUE
|
||||
rb_calc_hist(int argc, VALUE* argv, VALUE self)
|
||||
{
|
||||
return rb_calc_hist_bang(argc, argv, rb_copy_hist(self));
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculates a histogram of a set of arrays.
|
||||
* @overload calc_hist!(images, accumulate=nil, mask=nil)
|
||||
* @see #calc_hist
|
||||
* @opencv_func cvCalcHist
|
||||
*/
|
||||
VALUE
|
||||
rb_calc_hist_bang(int argc, VALUE* argv, VALUE self)
|
||||
{
|
||||
|
@ -218,8 +210,17 @@ rb_calc_hist_bang(int argc, VALUE* argv, VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* [<i>idx1[,idx2]...</i>]
|
||||
* Queries the value of the histogram bin.
|
||||
* @overload [](idx0)
|
||||
* @overload [](idx0, idx1)
|
||||
* @overload [](idx0, idx1, idx2)
|
||||
* @overload [](idx0, idx1, idx2, idx3, ...)
|
||||
* @param idx* [Integer] *-th index
|
||||
* @return [Number] The value of the specified bin of the 1D, 2D, 3D, or N-D histogram.
|
||||
* @opencv_func cvQueryHistValue_1D
|
||||
* @opencv_func cvQueryHistValue_2D
|
||||
* @opencv_func cvQueryHistValue_3D
|
||||
* @opencv_func cvQueryHistValue_nD
|
||||
*/
|
||||
VALUE
|
||||
rb_aref(VALUE self, VALUE args)
|
||||
|
@ -256,6 +257,18 @@ rb_aref(VALUE self, VALUE args)
|
|||
return rb_float_new((double)value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds the minimum and maximum histogram bins.
|
||||
* @overload min_max_value
|
||||
* @return [Array]
|
||||
* [min_value, max_value, min_idx, max_idx]: Array of the minimum / maximum value of the histogram
|
||||
* and their coordinates.
|
||||
* - min_value: The minimum value of the histogram.
|
||||
* - max_value: The maximum value of the histogram.
|
||||
* - min_idx: The array of coordinates for the minimum.
|
||||
* - max_idx: The array of coordinates for the maximum.
|
||||
* @opencv_func cvGetMinMaxHistValue
|
||||
*/
|
||||
VALUE
|
||||
rb_min_max_value(VALUE self)
|
||||
{
|
||||
|
@ -286,8 +299,16 @@ rb_min_max_value(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dims -> [int[,int...]]
|
||||
* Returns number of array dimensions
|
||||
* @overload [](idx0, idx1, ...)
|
||||
* @param idx* [Integer] *-th index
|
||||
* @return [Array<Integer, Array<Integer>>]
|
||||
* [dims, sizes]: Number of array dimensions and its sizes.
|
||||
* - dims (Integer): Number of array dimensions
|
||||
* - sizes (Array<Integer>): Vector of the array dimension sizes.
|
||||
* For 2D arrays the number of rows (height) goes first,
|
||||
* number of columns (width) next.
|
||||
* @opencv_func cvGetDims
|
||||
*/
|
||||
VALUE
|
||||
rb_dims(VALUE self)
|
||||
|
@ -309,10 +330,10 @@ rb_dims(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* copy_hist -> cvhist
|
||||
*
|
||||
* Clone histogram.
|
||||
* Clones histogram
|
||||
* @overload copy_hist
|
||||
* @return [CvHistogram] Copy of the histogram
|
||||
* @opencv_func cvCopyHist
|
||||
*/
|
||||
VALUE
|
||||
rb_copy_hist(VALUE self)
|
||||
|
@ -328,8 +349,11 @@ rb_copy_hist(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* clear_hist
|
||||
* Sets all histogram bins to 0 in case of dense histogram
|
||||
* and removes all histogram bins in case of sparse array.
|
||||
* @overload clear_hist
|
||||
* @return [CvHistogram] Cleared histogram
|
||||
* @opencv_func cvClearHist
|
||||
*/
|
||||
VALUE
|
||||
rb_clear_hist(VALUE self)
|
||||
|
@ -338,10 +362,13 @@ rb_clear_hist(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* clear_hist!
|
||||
*
|
||||
* Sets all histogram bins to 0 in case of dense histogram and removes all histogram bins in case of sparse array.
|
||||
* Sets all histogram bins to 0 in case of dense histogram
|
||||
* and removes all histogram bins in case of sparse array.
|
||||
* This method changes <tt>self</tt>.
|
||||
* @overload clear_hist!
|
||||
* @see #clear_hist
|
||||
* @return [CvHistogram] Cleared histogram
|
||||
* @opencv_func cvClearHist
|
||||
*/
|
||||
VALUE
|
||||
rb_clear_hist_bang(VALUE self)
|
||||
|
@ -356,10 +383,12 @@ rb_clear_hist_bang(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* normalize(<i>factor</i>) -> cvhist
|
||||
*
|
||||
* Return normalized the histogram bins by scaling them, such that the sum of the bins becomes equal to <i>factor</i>.
|
||||
* Returns normalized the histogram bins by scaling them,
|
||||
* such that the sum of the bins becomes equal to <tt>factor</tt>.
|
||||
* @overload normalize(factor)
|
||||
* @param factor [Number] Normalization factor. The sum of the bins becomes equal to this value.
|
||||
* @return [CvHistogram] Normalized histogram
|
||||
* @opencv_func cvNormalizeHist
|
||||
*/
|
||||
VALUE
|
||||
rb_normalize_hist(VALUE self, VALUE factor)
|
||||
|
@ -368,10 +397,14 @@ rb_normalize_hist(VALUE self, VALUE factor)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* normalize!(<i>factor</i>) -> self
|
||||
*
|
||||
* normalizes the histogram bins by scaling them, such that the sum of the bins becomes equal to <i>factor</i>.
|
||||
* Returns normalized the histogram bins by scaling them,
|
||||
* such that the sum of the bins becomes equal to <tt>factor</tt>.
|
||||
* This method changes <tt>self</tt>.
|
||||
* @overload normalize!(factor)
|
||||
* @param factor [Number] Normalization factor. The sum of the bins becomes equal to this value.
|
||||
* @return [CvHistogram] Normalized histogram
|
||||
* @see #normalize
|
||||
* @opencv_func cvNormalizeHist
|
||||
*/
|
||||
VALUE
|
||||
rb_normalize_hist_bang(VALUE self, VALUE factor)
|
||||
|
@ -386,10 +419,11 @@ rb_normalize_hist_bang(VALUE self, VALUE factor)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* thresh_hist(<i>threshold</i>) -> cvhist
|
||||
*
|
||||
* Return cleared histogram bins that are below the specified threshold.
|
||||
* Returns cleared histogram bins that are below the specified threshold.
|
||||
* @overload thresh_hist(threshold)
|
||||
* @param threshold [Number] Threshold value
|
||||
* @return [CvHistogram] Cleared histogram
|
||||
* @opencv_func cvThreshHist
|
||||
*/
|
||||
VALUE
|
||||
rb_thresh_hist(VALUE self, VALUE threshold)
|
||||
|
@ -398,10 +432,13 @@ rb_thresh_hist(VALUE self, VALUE threshold)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* thresh_hist!(<i>threshold</i>) -> self
|
||||
*
|
||||
* Cleares histogram bins that are below the specified threshold.
|
||||
* This method changes <tt>self</tt>.
|
||||
* @overload thresh_hist!(threshold)
|
||||
* @param threshold [Number] Threshold value
|
||||
* @return [CvHistogram] Cleared histogram
|
||||
* @see #thresh_hist
|
||||
* @opencv_func cvThreshHist
|
||||
*/
|
||||
VALUE
|
||||
rb_thresh_hist_bang(VALUE self, VALUE threshold)
|
||||
|
@ -415,12 +452,39 @@ rb_thresh_hist_bang(VALUE self, VALUE threshold)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the bounds of the histogram bins.
|
||||
* @overload set_hist_bin_ranges(ranges, uniform=true)
|
||||
* @param ranges [Array<Number>]
|
||||
* Array of ranges for the histogram bins. Its meaning depends on the uniform parameter value.
|
||||
* The ranges are used when the histogram is calculated or backprojected to determine
|
||||
* which histogram bin corresponds to which value/tuple of values from the input image(s).
|
||||
* @param uniform [Boolean]
|
||||
* Uniformity flag.
|
||||
* @return [CvHistogram]
|
||||
* Histogram
|
||||
* @opencv_func cvSetHistBinRanges
|
||||
*/
|
||||
VALUE
|
||||
rb_set_hist_bin_ranges(int argc, VALUE* argv, VALUE self)
|
||||
{
|
||||
return rb_set_hist_bin_ranges_bang(argc, argv, rb_copy_hist(self));
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the bounds of the histogram bins. This method changes <tt>self</tt>.
|
||||
* @overload set_hist_bin_ranges!(ranges, uniform=true)
|
||||
* @param ranges [Array<Number>]
|
||||
* Array of ranges for the histogram bins. Its meaning depends on the uniform parameter value.
|
||||
* The ranges are used when the histogram is calculated or backprojected to determine
|
||||
* which histogram bin corresponds to which value/tuple of values from the input image(s).
|
||||
* @param uniform [Boolean]
|
||||
* Uniformity flag.
|
||||
* @return [CvHistogram]
|
||||
* Histogram
|
||||
* @see #set_hist_bin_ranges
|
||||
* @opencv_func cvSetHistBinRanges
|
||||
*/
|
||||
VALUE
|
||||
rb_set_hist_bin_ranges_bang(int argc, VALUE* argv, VALUE self)
|
||||
{
|
||||
|
@ -446,6 +510,17 @@ rb_set_hist_bin_ranges_bang(int argc, VALUE* argv, VALUE self)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculates the back projection of a histogram.
|
||||
* @overload calc_back_project(images)
|
||||
* @param images [Array<IplImage>]
|
||||
* Source arrays. They all should have the same depth, CV_8U or CV_32F, and the same size.
|
||||
* Each of them can have an arbitrary number of channels.
|
||||
* @return [CvMat,IplImage]
|
||||
* Destination back projection array that is a single-channel array of the same size and depth
|
||||
* as the first element of <tt>images</tt>
|
||||
* @opencv_func cvCalcBackProject
|
||||
*/
|
||||
VALUE
|
||||
rb_calc_back_project(VALUE self, VALUE image)
|
||||
{
|
||||
|
@ -475,6 +550,24 @@ rb_calc_back_project(VALUE self, VALUE image)
|
|||
return back_project;
|
||||
}
|
||||
|
||||
/*
|
||||
* Locates a template within an image by using a histogram comparison.
|
||||
* @overload calc_back_project_patch(images, patch_size, method, factor)
|
||||
* @param images [Array<IplImage>] Source arrays.
|
||||
* @param pach_size [CvSize] Size of the patch slid though the source image.
|
||||
* @param method [Integer]
|
||||
* Comparison method that could be one of the following:
|
||||
* - <tt>CV_COMP_CORREL</tt>: Correlation
|
||||
* - <tt>CV_COMP_CHISQR</tt>: Chi-Square
|
||||
* - <tt>CV_COMP_INTERSECT</tt>: Intersection
|
||||
* - <tt>CV_COMP_BHATTACHARYYA</tt>: Bhattacharyya distance
|
||||
* - <tt>CV_COMP_HELLINGER</tt>: Synonym for <tt>CV_COMP_BHATTACHARYYA</tt>
|
||||
* @param factor [Number]
|
||||
* Normalization factor for histograms that affects the normalization scale
|
||||
* of the destination image. Pass 1 if not sure.
|
||||
* @return [CvMat,IplImage] Destination image.
|
||||
* @opencv_func cvCalcBackProject
|
||||
*/
|
||||
VALUE
|
||||
rb_calc_back_project_patch(VALUE self, VALUE image, VALUE patch_size, VALUE method, VALUE factor)
|
||||
{
|
||||
|
@ -507,6 +600,22 @@ rb_calc_back_project_patch(VALUE self, VALUE image, VALUE patch_size, VALUE meth
|
|||
return dst;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compares two histograms.
|
||||
* @overload compare_hist(hist1, hist2, method)
|
||||
* @param hist1 [CvHistogram] First compared histogram.
|
||||
* @param hist2 [CvHistogram] Second compared histogram of the same size as <tt>hist1</tt>.
|
||||
* @param method [Integer]
|
||||
* Comparison method that could be one of the following:
|
||||
* - <tt>CV_COMP_CORREL</tt>: Correlation
|
||||
* - <tt>CV_COMP_CHISQR</tt>: Chi-Square
|
||||
* - <tt>CV_COMP_INTERSECT</tt>: Intersection
|
||||
* - <tt>CV_COMP_BHATTACHARYYA</tt>: Bhattacharyya distance
|
||||
* - <tt>CV_COMP_HELLINGER</tt>: Synonym for <tt>CV_COMP_BHATTACHARYYA</tt>
|
||||
* @return [Number] Distance of the two histograms.
|
||||
* @scope class
|
||||
* @opencv_func cvCompareHist
|
||||
*/
|
||||
VALUE
|
||||
rb_compare_hist(VALUE self, VALUE hist1, VALUE hist2, VALUE method)
|
||||
{
|
||||
|
@ -522,6 +631,15 @@ rb_compare_hist(VALUE self, VALUE hist1, VALUE hist2, VALUE method)
|
|||
return rb_float_new(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Divides one histogram by another.
|
||||
* @overload calc_prob_density(hist1, hist2, scale=255)
|
||||
* @param hist1 [CvHistogram] First histogram (the divisor).
|
||||
* @param hist2 [CvHistogram] Second histogram.
|
||||
* @param scale [Number] Scale factor for the destination histogram.
|
||||
* @return [CvHistogram] Destination histogram.
|
||||
* @opencv_func cvCalcProbDensity
|
||||
*/
|
||||
VALUE
|
||||
rb_calc_prob_density(int argc, VALUE* argv, VALUE self)
|
||||
{
|
||||
|
@ -542,5 +660,56 @@ rb_calc_prob_density(int argc, VALUE* argv, VALUE self)
|
|||
return dst_hist;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvHistogram", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "is_uniform?", RUBY_METHOD_FUNC(rb_is_uniform), 0);
|
||||
rb_define_method(rb_klass, "is_sparse?", RUBY_METHOD_FUNC(rb_is_sparse), 0);
|
||||
rb_define_method(rb_klass, "has_range?", RUBY_METHOD_FUNC(rb_has_range), 0);
|
||||
rb_define_method(rb_klass, "dims", RUBY_METHOD_FUNC(rb_dims), 0);
|
||||
rb_define_method(rb_klass, "calc_hist", RUBY_METHOD_FUNC(rb_calc_hist), -1);
|
||||
rb_define_method(rb_klass, "calc_hist!", RUBY_METHOD_FUNC(rb_calc_hist_bang), -1);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), -2);
|
||||
rb_define_alias(rb_klass, "query_hist_value", "[]");
|
||||
rb_define_method(rb_klass, "min_max_value", RUBY_METHOD_FUNC(rb_min_max_value), 0);
|
||||
rb_define_method(rb_klass, "copy_hist", RUBY_METHOD_FUNC(rb_copy_hist), 0);
|
||||
|
||||
rb_define_method(rb_klass, "clear_hist", RUBY_METHOD_FUNC(rb_clear_hist), 0);
|
||||
rb_define_alias(rb_klass, "clear", "clear_hist");
|
||||
rb_define_method(rb_klass, "clear_hist!", RUBY_METHOD_FUNC(rb_clear_hist_bang), 0);
|
||||
rb_define_alias(rb_klass, "clear!", "clear_hist!");
|
||||
|
||||
rb_define_method(rb_klass, "normalize_hist", RUBY_METHOD_FUNC(rb_normalize_hist), 1);
|
||||
rb_define_alias(rb_klass, "normalize", "normalize_hist");
|
||||
rb_define_method(rb_klass, "normalize_hist!", RUBY_METHOD_FUNC(rb_normalize_hist_bang), 1);
|
||||
rb_define_alias(rb_klass, "normalize!", "normalize_hist!");
|
||||
|
||||
rb_define_method(rb_klass, "thresh_hist", RUBY_METHOD_FUNC(rb_thresh_hist), 1);
|
||||
rb_define_alias(rb_klass, "thresh", "thresh_hist");
|
||||
rb_define_method(rb_klass, "thresh_hist!", RUBY_METHOD_FUNC(rb_thresh_hist_bang), 1);
|
||||
rb_define_alias(rb_klass, "thresh!", "thresh_hist!");
|
||||
|
||||
rb_define_method(rb_klass, "set_hist_bin_ranges", RUBY_METHOD_FUNC(rb_set_hist_bin_ranges), -1);
|
||||
rb_define_method(rb_klass, "set_hist_bin_ranges!", RUBY_METHOD_FUNC(rb_set_hist_bin_ranges_bang), -1);
|
||||
|
||||
rb_define_method(rb_klass, "calc_back_project", RUBY_METHOD_FUNC(rb_calc_back_project), 1);
|
||||
rb_define_method(rb_klass, "calc_back_project_patch", RUBY_METHOD_FUNC(rb_calc_back_project_patch), 4);
|
||||
|
||||
rb_define_singleton_method(rb_klass, "calc_prob_density", RUBY_METHOD_FUNC(rb_calc_prob_density), -1);
|
||||
rb_define_singleton_method(rb_klass, "compare_hist", RUBY_METHOD_FUNC(rb_compare_hist), 3);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVHISTOGRAM
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVHISTOGRAM
|
|||
|
||||
VALUE rb_class();
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_is_uniform(VALUE self);
|
||||
|
|
|
@ -12,17 +12,11 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvHuMoments
|
||||
*
|
||||
* moments
|
||||
* Hu invariants
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVHUMOMENTS
|
||||
|
||||
#define DEFINE_CVHUMOMENTS_GETTER(elem) \
|
||||
rb_define_method(rb_klass, #elem, RUBY_METHOD_FUNC(rb_##elem), 0)
|
||||
|
||||
#define CVHUMOMENTS_GETTER(elem) \
|
||||
VALUE rb_##elem(VALUE self) { return DBL2NUM(CVHUMOMENTS(self)->elem); }
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
|
@ -31,33 +25,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvHuMoments", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu1);
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu2);
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu3);
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu4);
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu5);
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu6);
|
||||
DEFINE_CVHUMOMENTS_GETTER(hu7);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -66,21 +33,12 @@ rb_allocate(VALUE klass)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvHuMoments.new(<i>src_moments</i>)
|
||||
*
|
||||
* Calculates the seven Hu invariants.
|
||||
* <i>src_moments</i> The input moments
|
||||
*
|
||||
* seven Hu invariants that are defined as:
|
||||
* h1=η20+η02
|
||||
* h2=(η20-η02)²+4η11²
|
||||
* h3=(η30-3η12)²+ (3η21-η03)²
|
||||
* h4=(η30+η12)²+ (η21+η03)²
|
||||
* h5=(η30-3η12)(η30+η12)[(η30+η12)²-3(η21+η03)²]+(3η21-η03)(η21+η03)[3(η30+η12)²-(η21+η03)²]
|
||||
* h6=(η20-η02)[(η30+η12)²- (η21+η03)²]+4η11(η30+η12)(η21+η03)
|
||||
* h7=(3η21-η03)(η21+η03)[3(η30+η12)²-(η21+η03)²]-(η30-3η12)(η21+η03)[3(η30+η12)²-(η21+η03)²]
|
||||
* where ηi,j are normalized central moments of 2-nd and 3-rd orders. The computed values are proved to be invariant to the image scaling, rotation, and reflection except the seventh one, whose sign is changed by reflection.
|
||||
* Calculates the seven Hu invariants
|
||||
* @overload new(src_moments)
|
||||
* @param src_moments [CvMoment] Input moments
|
||||
* @return [CvHuMoments] Output Hu invariants
|
||||
* @opencv_func cvGetHuMoments
|
||||
* @see http://en.wikipedia.org/wiki/Image_moment#Rotation_invariant_moments
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(VALUE self, VALUE src_moments)
|
||||
|
@ -94,19 +52,73 @@ rb_initialize(VALUE self, VALUE src_moments)
|
|||
return self;
|
||||
}
|
||||
|
||||
CVHUMOMENTS_GETTER(hu1);
|
||||
CVHUMOMENTS_GETTER(hu2);
|
||||
CVHUMOMENTS_GETTER(hu3);
|
||||
CVHUMOMENTS_GETTER(hu4);
|
||||
CVHUMOMENTS_GETTER(hu5);
|
||||
CVHUMOMENTS_GETTER(hu6);
|
||||
CVHUMOMENTS_GETTER(hu7);
|
||||
/*
|
||||
* Returns hu1 invariant
|
||||
* @overload hu1
|
||||
* @return [Number] hu1 invariant
|
||||
*/
|
||||
VALUE rb_hu1(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu1);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* to_ary -> [hu1, hu2, ... ,hu7]
|
||||
*
|
||||
* Return values by Array.
|
||||
* Returns hu2 invariant
|
||||
* @overload hu2
|
||||
* @return [Number] hu2 invariant
|
||||
*/
|
||||
VALUE rb_hu2(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hu3 invariant
|
||||
* @overload hu3
|
||||
* @return [Number] hu3 invariant
|
||||
*/
|
||||
VALUE rb_hu3(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hu4 invariant
|
||||
* @overload hu4
|
||||
* @return [Number] hu4 invariant
|
||||
*/
|
||||
VALUE rb_hu4(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu4);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hu5 invariant
|
||||
* @overload hu5
|
||||
* @return [Number] hu5 invariant
|
||||
*/
|
||||
VALUE rb_hu5(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hu6 invariant
|
||||
* @overload hu6
|
||||
* @return [Number] hu6 invariant
|
||||
*/
|
||||
VALUE rb_hu6(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu6);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hu7 invariant
|
||||
* @overload hu7
|
||||
* @return [Number] hu7 invariant
|
||||
*/
|
||||
VALUE rb_hu7(VALUE self) {
|
||||
return DBL2NUM(CVHUMOMENTS(self)->hu7);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hu invaliants as an Array
|
||||
* @overload to_ary
|
||||
* @return [Array<Number>] Hu invaliants
|
||||
*/
|
||||
VALUE
|
||||
rb_to_ary(VALUE self)
|
||||
|
@ -135,5 +147,32 @@ new_object(CvMoments *src_moments)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvHuMoments", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
|
||||
rb_define_method(rb_klass, "hu1", RUBY_METHOD_FUNC(rb_hu1), 0);
|
||||
rb_define_method(rb_klass, "hu2", RUBY_METHOD_FUNC(rb_hu2), 0);
|
||||
rb_define_method(rb_klass, "hu3", RUBY_METHOD_FUNC(rb_hu3), 0);
|
||||
rb_define_method(rb_klass, "hu4", RUBY_METHOD_FUNC(rb_hu4), 0);
|
||||
rb_define_method(rb_klass, "hu5", RUBY_METHOD_FUNC(rb_hu5), 0);
|
||||
rb_define_method(rb_klass, "hu6", RUBY_METHOD_FUNC(rb_hu6), 0);
|
||||
rb_define_method(rb_klass, "hu7", RUBY_METHOD_FUNC(rb_hu7), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVHUMOMENTS
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVHUMOMENTS
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(VALUE src_moments, VALUE self);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
/*
|
||||
* Document-class: OpenCV::CvLine
|
||||
*
|
||||
* Line parameters represented by a two-element (rho, theta)
|
||||
* for CvMat#hough_lines
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVLINE
|
||||
|
@ -23,28 +25,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvLine", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "rho", RUBY_METHOD_FUNC(rb_rho), 0);
|
||||
rb_define_method(rb_klass, "rho=", RUBY_METHOD_FUNC(rb_set_rho), 1);
|
||||
rb_define_method(rb_klass, "theta", RUBY_METHOD_FUNC(rb_theta), 0);
|
||||
rb_define_method(rb_klass, "theta=", RUBY_METHOD_FUNC(rb_set_theta), 1);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -53,7 +33,9 @@ rb_allocate(VALUE klass)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return parameter on rho.
|
||||
* Returns distance from the coordinate origin (0, 0)
|
||||
* @overload rho
|
||||
* @return [Number] Distance from the coordinate origin
|
||||
*/
|
||||
VALUE
|
||||
rb_rho(VALUE self)
|
||||
|
@ -62,10 +44,9 @@ rb_rho(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* rho = val
|
||||
*
|
||||
* Set rho parameter, return self.
|
||||
* Set distance from the coordinate origin (0, 0)
|
||||
* @overload rho=(value)
|
||||
* @param value [Number] Distance from the coordinate origin
|
||||
*/
|
||||
VALUE
|
||||
rb_set_rho(VALUE self, VALUE rho)
|
||||
|
@ -75,7 +56,9 @@ rb_set_rho(VALUE self, VALUE rho)
|
|||
}
|
||||
|
||||
/*
|
||||
* Return parameter on theta.
|
||||
* Returns line rotation angle in radians
|
||||
* @overload theta
|
||||
* @return [Number] Line rotation angle in radians
|
||||
*/
|
||||
VALUE
|
||||
rb_theta(VALUE self)
|
||||
|
@ -84,10 +67,9 @@ rb_theta(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* y = val
|
||||
*
|
||||
* Set theta parameter, return self.
|
||||
* Set line rotation angle in radians
|
||||
* @overload theta=(value)
|
||||
* @param value [Number] Line rotation angle
|
||||
*/
|
||||
VALUE
|
||||
rb_set_theta(VALUE self, VALUE theta)
|
||||
|
@ -97,10 +79,10 @@ rb_set_theta(VALUE self, VALUE theta)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* [<i>index</i>]
|
||||
*
|
||||
* Return value of <i>index</i> dimension.
|
||||
* Returns value of rho, theta
|
||||
* @overload [](index)
|
||||
* @param index [Integer] Index
|
||||
* @return [Number] If index = 0, returns rho, else if index = 1, returns theta.
|
||||
*/
|
||||
VALUE
|
||||
rb_aref(VALUE self, VALUE index)
|
||||
|
@ -120,10 +102,11 @@ rb_aref(VALUE self, VALUE index)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* [<i>index</i>] = <i>value</i>
|
||||
*
|
||||
* Set value of <i>index</i> dimension to <i>value</i>
|
||||
* Set value of rho, theta
|
||||
* @overload []=(index, value)
|
||||
* @param index [Integer] Index
|
||||
* @param value [Number] Value
|
||||
* @return [Number] If index = 0, set rho, else if index = 1, set theta.
|
||||
*/
|
||||
VALUE
|
||||
rb_aset(VALUE self, VALUE index, VALUE value)
|
||||
|
@ -150,5 +133,27 @@ new_object(CvLine line)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvLine", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "rho", RUBY_METHOD_FUNC(rb_rho), 0);
|
||||
rb_define_method(rb_klass, "rho=", RUBY_METHOD_FUNC(rb_set_rho), 1);
|
||||
rb_define_method(rb_klass, "theta", RUBY_METHOD_FUNC(rb_theta), 0);
|
||||
rb_define_method(rb_klass, "theta=", RUBY_METHOD_FUNC(rb_set_theta), 1);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVLINE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -26,7 +26,7 @@ __NAMESPACE_BEGIN_CVLINE
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
|
11237
ext/opencv/cvmat.cpp
11237
ext/opencv/cvmat.cpp
File diff suppressed because it is too large
Load diff
|
@ -21,7 +21,7 @@ __NAMESPACE_BEGIN_CVMAT
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
@ -177,7 +177,7 @@ VALUE rb_warp_affine(int argc, VALUE *argv, VALUE self);
|
|||
VALUE rb_rotation_matrix2D(VALUE self, VALUE center, VALUE angle, VALUE scale);
|
||||
VALUE rb_get_perspective_transform(VALUE self, VALUE source, VALUE dest);
|
||||
VALUE rb_warp_perspective(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_find_homograpy(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_find_homography(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_remap(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_log_polar(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
|
@ -221,7 +221,6 @@ VALUE rb_apply_color_map(VALUE self, VALUE colormap);
|
|||
/* Matching*/
|
||||
VALUE rb_match_template(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_shapes(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_descriptors(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
/* Object Tracking */
|
||||
VALUE rb_mean_shift(VALUE self, VALUE window, VALUE criteria);
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/***********************************************************
|
||||
|
||||
cvmatnd.cpp -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2007 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include "cvmatnd.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvMatND
|
||||
*
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVMATND
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
rb_class()
|
||||
{
|
||||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv(), cvmat = cCvMat::rb_class();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvMatND", cvmat);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVMATND
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvmatnd.h -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2007 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#ifndef RUBY_OPENCV_CVMATND_H
|
||||
#define RUBY_OPENCV_CVMATND_H
|
||||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVMATND namespace cCvMatND {
|
||||
#define __NAMESPACE_END_CVMATND }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVMATND
|
||||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
|
||||
__NAMESPACE_END_CVMATND
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
#endif // RUBY_OPENCV_CVMATND_H
|
|
@ -24,20 +24,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvMemStorage", rb_cObject);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -63,6 +49,25 @@ new_object(int blocksize)
|
|||
return Data_Wrap_Struct(rb_klass, 0, cvmemstorage_free, storage);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvMemStorage", rb_cObject);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVMEMSTORAGE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVMEMSTORAGE
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_class();
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
|
|
@ -30,50 +30,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvMoments", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "spatial", RUBY_METHOD_FUNC(rb_spatial), 2);
|
||||
rb_define_method(rb_klass, "central", RUBY_METHOD_FUNC(rb_central), 2);
|
||||
rb_define_method(rb_klass, "normalized_central", RUBY_METHOD_FUNC(rb_normalized_central), 2);
|
||||
rb_define_method(rb_klass, "hu", RUBY_METHOD_FUNC(rb_hu), 0);
|
||||
rb_define_method(rb_klass, "gravity_center", RUBY_METHOD_FUNC(rb_gravity_center), 0);
|
||||
rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
|
||||
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m00);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m10);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m01);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m20);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m11);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m02);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m30);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m21);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m12);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m03);
|
||||
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu20);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu11);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu02);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu30);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu21);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu12);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu03);
|
||||
|
||||
DEFINE_CVMOMENTS_ACCESSOR(inv_sqrt_m00);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -82,7 +38,7 @@ rb_allocate(VALUE klass)
|
|||
}
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMoments.new(<i>src[,is_binary = nil]</i>)
|
||||
* CvMoments.new(src[,is_binary = nil])
|
||||
*
|
||||
* Calculates all moments up to third order of a polygon or rasterized shape.
|
||||
* <i>src</i> should be CvMat or CvPolygon.
|
||||
|
@ -283,5 +239,55 @@ new_object(CvArr *arr, int is_binary = 0)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvMoments", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "spatial", RUBY_METHOD_FUNC(rb_spatial), 2);
|
||||
rb_define_method(rb_klass, "central", RUBY_METHOD_FUNC(rb_central), 2);
|
||||
rb_define_method(rb_klass, "normalized_central", RUBY_METHOD_FUNC(rb_normalized_central), 2);
|
||||
rb_define_method(rb_klass, "hu", RUBY_METHOD_FUNC(rb_hu), 0);
|
||||
rb_define_method(rb_klass, "gravity_center", RUBY_METHOD_FUNC(rb_gravity_center), 0);
|
||||
rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
|
||||
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m00);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m10);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m01);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m20);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m11);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m02);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m30);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m21);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m12);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(m03);
|
||||
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu20);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu11);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu02);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu30);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu21);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu12);
|
||||
DEFINE_CVMOMENTS_ACCESSOR(mu03);
|
||||
|
||||
DEFINE_CVMOMENTS_ACCESSOR(inv_sqrt_m00);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVMOMENTS
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVMOMENTS
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
|
|
@ -31,32 +31,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvPoint", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* combatible?(obj)
|
||||
|
@ -224,5 +198,37 @@ new_object(CvPoint point)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvPoint", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVPOINT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVPOINT
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
|
||||
|
|
|
@ -31,32 +31,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* combatible?(obj)
|
||||
|
@ -207,5 +181,36 @@ new_object(CvPoint2D32f point)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVPOINT2D32F
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVPOINT2D32F
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
|
||||
|
|
|
@ -32,35 +32,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvpoint2d32f = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvpoint2d32f = cCvPoint2D32f::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "CvPoint3D32f", cvpoint2d32f);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
rb_define_method(rb_klass, "z", RUBY_METHOD_FUNC(rb_z), 0);
|
||||
rb_define_method(rb_klass, "z=", RUBY_METHOD_FUNC(rb_set_z), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* combatible?(obj)
|
||||
|
@ -241,5 +212,41 @@ new_object(CvPoint3D32f point)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE cvpoint2d32f = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvpoint2d32f = rb_define_class_under(opencv, "CvPoint2D32f", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
VALUE cvpoint2d32f = cCvPoint2D32f::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "CvPoint3D32f", cvpoint2d32f);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
rb_define_method(rb_klass, "z", RUBY_METHOD_FUNC(rb_z), 0);
|
||||
rb_define_method(rb_klass, "z=", RUBY_METHOD_FUNC(rb_set_z), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVPOINT3D32F
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVPOINT3D32F
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
|
||||
|
|
|
@ -34,39 +34,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvRect", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_singleton_method(rb_klass, "max_rect", RUBY_METHOD_FUNC(rb_max_rect), 2);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
||||
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
||||
rb_define_method(rb_klass, "top_left", RUBY_METHOD_FUNC(rb_top_left), 0);
|
||||
rb_define_method(rb_klass, "top_right", RUBY_METHOD_FUNC(rb_top_right), 0);
|
||||
rb_define_method(rb_klass, "bottom_left", RUBY_METHOD_FUNC(rb_bottom_left), 0);
|
||||
rb_define_method(rb_klass, "bottom_right", RUBY_METHOD_FUNC(rb_bottom_right), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* combatible?(obj)
|
||||
|
@ -329,5 +296,43 @@ new_object(CvRect rect)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvRect", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_singleton_method(rb_klass, "max_rect", RUBY_METHOD_FUNC(rb_max_rect), 2);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
|
||||
rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
|
||||
rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
|
||||
rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
|
||||
rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
|
||||
rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
|
||||
rb_define_method(rb_klass, "top_left", RUBY_METHOD_FUNC(rb_top_left), 0);
|
||||
rb_define_method(rb_klass, "top_right", RUBY_METHOD_FUNC(rb_top_right), 0);
|
||||
rb_define_method(rb_klass, "bottom_left", RUBY_METHOD_FUNC(rb_bottom_left), 0);
|
||||
rb_define_method(rb_klass, "bottom_right", RUBY_METHOD_FUNC(rb_bottom_right), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVRECT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVRECT
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
VALUE rb_max_rect(VALUE klass, VALUE rect1, VALUE rect2);
|
||||
|
|
|
@ -42,50 +42,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvScalar", rb_cObject);
|
||||
/* CvScalar: class */
|
||||
rb_define_const(opencv, "CvColor", rb_klass);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
|
||||
rb_define_method(rb_klass, "sub", RUBY_METHOD_FUNC(rb_sub), -1);
|
||||
rb_define_alias(rb_klass, "-", "sub");
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
|
||||
rb_define_const(rb_klass, "Black", cCvScalar::new_object(cvScalar(0x0,0x0,0x0)));
|
||||
rb_define_const(rb_klass, "Silver", cCvScalar::new_object(cvScalar(0x0c,0x0c,0x0c)));
|
||||
rb_define_const(rb_klass, "Gray", cCvScalar::new_object(cvScalar(0x80,0x80,0x80)));
|
||||
rb_define_const(rb_klass, "White", cCvScalar::new_object(cvScalar(0xff,0xff,0xff)));
|
||||
rb_define_const(rb_klass, "Maroon", cCvScalar::new_object(cvScalar(0x0,0x0,0x80)));
|
||||
rb_define_const(rb_klass, "Red", cCvScalar::new_object(cvScalar(0x0,0x0,0xff)));
|
||||
rb_define_const(rb_klass, "Purple", cCvScalar::new_object(cvScalar(0x80,0x0,0x80)));
|
||||
rb_define_const(rb_klass, "Fuchsia", cCvScalar::new_object(cvScalar(0xff,0x0,0xff)));
|
||||
rb_define_const(rb_klass, "Green", cCvScalar::new_object(cvScalar(0x0,0x80,0x0)));
|
||||
rb_define_const(rb_klass, "Lime", cCvScalar::new_object(cvScalar(0x0,0xff,0x0)));
|
||||
rb_define_const(rb_klass, "Olive", cCvScalar::new_object(cvScalar(0x0,0x80,0x80)));
|
||||
rb_define_const(rb_klass, "Yellow", cCvScalar::new_object(cvScalar(0x0,0xff,0xff)));
|
||||
rb_define_const(rb_klass, "Navy", cCvScalar::new_object(cvScalar(0x80,0x0,0x0)));
|
||||
rb_define_const(rb_klass, "Blue", cCvScalar::new_object(cvScalar(0xff,0x0,0x0)));
|
||||
rb_define_const(rb_klass, "Teal", cCvScalar::new_object(cvScalar(0x80,0x80,0x0)));
|
||||
rb_define_const(rb_klass, "Aqua", cCvScalar::new_object(cvScalar(0xff,0xff,0x0)));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -95,7 +51,7 @@ rb_allocate(VALUE klass)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* new(<i>[d1][,d2][,d3][,d4]</i>)
|
||||
* new([d1][,d2][,d3][,d4])
|
||||
*
|
||||
* Create new Scalar. Argument should be Fixnum (or nil as 0).
|
||||
*/
|
||||
|
@ -231,6 +187,55 @@ new_object(CvScalar scalar)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvScalar", rb_cObject);
|
||||
/* CvScalar: class */
|
||||
rb_define_const(opencv, "CvColor", rb_klass);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
|
||||
rb_define_method(rb_klass, "sub", RUBY_METHOD_FUNC(rb_sub), -1);
|
||||
rb_define_alias(rb_klass, "-", "sub");
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
|
||||
rb_define_const(rb_klass, "Black", cCvScalar::new_object(cvScalar(0x0,0x0,0x0)));
|
||||
rb_define_const(rb_klass, "Silver", cCvScalar::new_object(cvScalar(0x0c,0x0c,0x0c)));
|
||||
rb_define_const(rb_klass, "Gray", cCvScalar::new_object(cvScalar(0x80,0x80,0x80)));
|
||||
rb_define_const(rb_klass, "White", cCvScalar::new_object(cvScalar(0xff,0xff,0xff)));
|
||||
rb_define_const(rb_klass, "Maroon", cCvScalar::new_object(cvScalar(0x0,0x0,0x80)));
|
||||
rb_define_const(rb_klass, "Red", cCvScalar::new_object(cvScalar(0x0,0x0,0xff)));
|
||||
rb_define_const(rb_klass, "Purple", cCvScalar::new_object(cvScalar(0x80,0x0,0x80)));
|
||||
rb_define_const(rb_klass, "Fuchsia", cCvScalar::new_object(cvScalar(0xff,0x0,0xff)));
|
||||
rb_define_const(rb_klass, "Green", cCvScalar::new_object(cvScalar(0x0,0x80,0x0)));
|
||||
rb_define_const(rb_klass, "Lime", cCvScalar::new_object(cvScalar(0x0,0xff,0x0)));
|
||||
rb_define_const(rb_klass, "Olive", cCvScalar::new_object(cvScalar(0x0,0x80,0x80)));
|
||||
rb_define_const(rb_klass, "Yellow", cCvScalar::new_object(cvScalar(0x0,0xff,0xff)));
|
||||
rb_define_const(rb_klass, "Navy", cCvScalar::new_object(cvScalar(0x80,0x0,0x0)));
|
||||
rb_define_const(rb_klass, "Blue", cCvScalar::new_object(cvScalar(0xff,0x0,0x0)));
|
||||
rb_define_const(rb_klass, "Teal", cCvScalar::new_object(cvScalar(0x80,0x80,0x0)));
|
||||
rb_define_const(rb_klass, "Aqua", cCvScalar::new_object(cvScalar(0xff,0xff,0x0)));
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSCALAR
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSCALAR
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
|
||||
|
|
|
@ -73,49 +73,6 @@ unregister_elem_class(void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSeq", rb_cObject);
|
||||
rb_include_module(rb_klass, rb_mEnumerable);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "total", RUBY_METHOD_FUNC(rb_total), 0);
|
||||
rb_define_alias(rb_klass, "length", "total");
|
||||
rb_define_alias(rb_klass, "size", "total");
|
||||
rb_define_method(rb_klass, "empty?", RUBY_METHOD_FUNC(rb_empty_q), 0);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "first", RUBY_METHOD_FUNC(rb_first), 0);
|
||||
rb_define_method(rb_klass, "last", RUBY_METHOD_FUNC(rb_last), 0);
|
||||
|
||||
rb_define_method(rb_klass, "h_prev", RUBY_METHOD_FUNC(rb_h_prev), 0);
|
||||
rb_define_method(rb_klass, "h_next", RUBY_METHOD_FUNC(rb_h_next), 0);
|
||||
rb_define_method(rb_klass, "v_prev", RUBY_METHOD_FUNC(rb_v_prev), 0);
|
||||
rb_define_method(rb_klass, "v_next", RUBY_METHOD_FUNC(rb_v_next), 0);
|
||||
|
||||
rb_define_method(rb_klass, "push", RUBY_METHOD_FUNC(rb_push), -2);
|
||||
rb_define_alias(rb_klass, "<<", "push");
|
||||
rb_define_method(rb_klass, "pop", RUBY_METHOD_FUNC(rb_pop), 0);
|
||||
rb_define_method(rb_klass, "unshift", RUBY_METHOD_FUNC(rb_unshift), -2);
|
||||
rb_define_alias(rb_klass, "push_front", "unshift");
|
||||
rb_define_method(rb_klass, "shift", RUBY_METHOD_FUNC(rb_shift), 0);
|
||||
rb_define_alias(rb_klass, "pop_front", "shift");
|
||||
rb_define_method(rb_klass, "each", RUBY_METHOD_FUNC(rb_each), 0);
|
||||
rb_define_method(rb_klass, "each_index", RUBY_METHOD_FUNC(rb_each_index), 0);
|
||||
rb_define_method(rb_klass, "insert", RUBY_METHOD_FUNC(rb_insert), 2);
|
||||
rb_define_method(rb_klass, "remove", RUBY_METHOD_FUNC(rb_remove), 1);
|
||||
rb_define_alias(rb_klass, "delete_at", "remove");
|
||||
rb_define_method(rb_klass, "clear", RUBY_METHOD_FUNC(rb_clear), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -125,7 +82,7 @@ rb_allocate(VALUE klass)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvSeq.new(<i>type[,storage]</i>)
|
||||
* CvSeq.new(type[,storage])
|
||||
*
|
||||
* Return a new CvSeq. <i>type</i> should be following classes.
|
||||
*
|
||||
|
@ -378,7 +335,7 @@ rb_seq_push(VALUE self, VALUE args, int flag)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* push(<i>obj, ...</i>) -> self
|
||||
* push(obj, ...) -> self
|
||||
*
|
||||
* Append - Pushes the given object(s) on the end of this sequence. This expression return the sequence itself,
|
||||
* so several append may be chained together.
|
||||
|
@ -542,7 +499,7 @@ rb_each_index(VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* insert(<i>index,obj</i>) -> self
|
||||
* insert(index,obj) -> self
|
||||
*
|
||||
* Inserts the given values before element with the given index (which may be negative).
|
||||
*/
|
||||
|
@ -570,7 +527,7 @@ rb_insert(VALUE self, VALUE index, VALUE object)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* remove(<i>index</i>) -> obj or nil
|
||||
* remove(index) -> obj or nil
|
||||
*
|
||||
* Deletes the elements at the specified index.
|
||||
*/
|
||||
|
@ -595,5 +552,54 @@ new_sequence(VALUE klass, CvSeq *seq, VALUE element_klass, VALUE storage)
|
|||
return Data_Wrap_Struct(klass, mark_root_object, unregister_elem_class, seq);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSeq", rb_cObject);
|
||||
rb_include_module(rb_klass, rb_mEnumerable);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "total", RUBY_METHOD_FUNC(rb_total), 0);
|
||||
rb_define_alias(rb_klass, "length", "total");
|
||||
rb_define_alias(rb_klass, "size", "total");
|
||||
rb_define_method(rb_klass, "empty?", RUBY_METHOD_FUNC(rb_empty_q), 0);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "first", RUBY_METHOD_FUNC(rb_first), 0);
|
||||
rb_define_method(rb_klass, "last", RUBY_METHOD_FUNC(rb_last), 0);
|
||||
|
||||
rb_define_method(rb_klass, "h_prev", RUBY_METHOD_FUNC(rb_h_prev), 0);
|
||||
rb_define_method(rb_klass, "h_next", RUBY_METHOD_FUNC(rb_h_next), 0);
|
||||
rb_define_method(rb_klass, "v_prev", RUBY_METHOD_FUNC(rb_v_prev), 0);
|
||||
rb_define_method(rb_klass, "v_next", RUBY_METHOD_FUNC(rb_v_next), 0);
|
||||
|
||||
rb_define_method(rb_klass, "push", RUBY_METHOD_FUNC(rb_push), -2);
|
||||
rb_define_alias(rb_klass, "<<", "push");
|
||||
rb_define_method(rb_klass, "pop", RUBY_METHOD_FUNC(rb_pop), 0);
|
||||
rb_define_method(rb_klass, "unshift", RUBY_METHOD_FUNC(rb_unshift), -2);
|
||||
rb_define_alias(rb_klass, "push_front", "unshift");
|
||||
rb_define_method(rb_klass, "shift", RUBY_METHOD_FUNC(rb_shift), 0);
|
||||
rb_define_alias(rb_klass, "pop_front", "shift");
|
||||
rb_define_method(rb_klass, "each", RUBY_METHOD_FUNC(rb_each), 0);
|
||||
rb_define_method(rb_klass, "each_index", RUBY_METHOD_FUNC(rb_each_index), 0);
|
||||
rb_define_method(rb_klass, "insert", RUBY_METHOD_FUNC(rb_insert), 2);
|
||||
rb_define_method(rb_klass, "remove", RUBY_METHOD_FUNC(rb_remove), 1);
|
||||
rb_define_alias(rb_klass, "delete_at", "remove");
|
||||
rb_define_method(rb_klass, "clear", RUBY_METHOD_FUNC(rb_clear), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSEQ
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV
|
|||
__NAMESPACE_BEGIN_CVSEQ
|
||||
|
||||
VALUE rb_class();
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE seqblock_class(void *ptr);
|
||||
void register_elem_class(CvSeq *seq, VALUE klass);
|
||||
|
|
|
@ -31,32 +31,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvSize", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* compatible?(obj)
|
||||
|
@ -217,5 +191,37 @@ new_object(CvSize size)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvSize", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSIZE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSIZE
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
|
||||
|
|
|
@ -31,31 +31,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvSize2D32f", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* compatible?(obj)
|
||||
|
@ -205,5 +180,36 @@ new_object(CvSize2D32f size)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvSize2D32f", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSIZE2D32F
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSIZE2D32F
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
************************************************************/
|
||||
#include "cvslice.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvClice
|
||||
* Document-class: OpenCV::CvSlice
|
||||
*
|
||||
* C structure is here, very simple.
|
||||
* typdef struct CvSlice {
|
||||
|
@ -28,26 +28,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSlice", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
|
||||
rb_define_method(rb_klass, "start_index", RUBY_METHOD_FUNC(rb_start_index_aref), 0);
|
||||
rb_define_method(rb_klass, "end_index", RUBY_METHOD_FUNC(rb_end_index_aref), 0);
|
||||
rb_define_method(rb_klass, "start_index=", RUBY_METHOD_FUNC(rb_start_index_aset), 1);
|
||||
rb_define_method(rb_klass, "end_index=", RUBY_METHOD_FUNC(rb_end_index_aset), 1);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -57,7 +37,7 @@ rb_allocate(VALUE klass)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* new(<i>start, end</i>)
|
||||
* new(start, end)
|
||||
*
|
||||
* Create new slice object.
|
||||
*/
|
||||
|
@ -116,5 +96,31 @@ rb_end_index_aset(VALUE self, VALUE index)
|
|||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSlice", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
|
||||
rb_define_method(rb_klass, "start_index", RUBY_METHOD_FUNC(rb_start_index_aref), 0);
|
||||
rb_define_method(rb_klass, "end_index", RUBY_METHOD_FUNC(rb_end_index_aref), 0);
|
||||
rb_define_method(rb_klass, "start_index=", RUBY_METHOD_FUNC(rb_start_index_aset), 1);
|
||||
rb_define_method(rb_klass, "end_index=", RUBY_METHOD_FUNC(rb_end_index_aset), 1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSLICE
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSLICE
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(VALUE self, VALUE start, VALUE end);
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/***********************************************************
|
||||
|
||||
cvsparse.cpp -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2007 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include "cvsparsemat.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvSparseMat
|
||||
*
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVSPARSEMAT
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
rb_class()
|
||||
{
|
||||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv(), cvmat = cCvMat::rb_class();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvSparseMat", cvmat);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSPARSEMAT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvsparsemat.h -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#ifndef RUBY_OPENCV_CVSPARSEMAT_H
|
||||
#define RUBY_OPENCV_CVSPARSEMAT_H
|
||||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVSPARSEMAT namespace cCvSparseMat {
|
||||
#define __NAMESPACE_END_CVSPARSEMAT }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVSPARSEMAT
|
||||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
|
||||
__NAMESPACE_END_CVSPARSEMAT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
#endif // RUBY_OPENCV_CVSPARSEMAT_H
|
|
@ -30,30 +30,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSURFParams", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "hessian_threshold", RUBY_METHOD_FUNC(rb_get_hessian_threshold), 0);
|
||||
rb_define_method(rb_klass, "hessian_threshold=", RUBY_METHOD_FUNC(rb_set_hessian_threshold), 1);
|
||||
rb_define_method(rb_klass, "extended", RUBY_METHOD_FUNC(rb_get_extended), 0);
|
||||
rb_define_method(rb_klass, "extended=", RUBY_METHOD_FUNC(rb_set_extended), 1);
|
||||
rb_define_method(rb_klass, "n_octaves", RUBY_METHOD_FUNC(rb_get_n_octaves), 0);
|
||||
rb_define_method(rb_klass, "n_octaves=", RUBY_METHOD_FUNC(rb_set_n_octaves), 1);
|
||||
rb_define_method(rb_klass, "n_octave_layers", RUBY_METHOD_FUNC(rb_get_n_octave_layers), 0);
|
||||
rb_define_method(rb_klass, "n_octave_layers=", RUBY_METHOD_FUNC(rb_set_n_octave_layers), 1);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -61,11 +37,15 @@ rb_allocate(VALUE klass)
|
|||
return Data_Make_Struct(klass, CvSURFParams, 0, -1, ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvSURFParams.new(<i>hessian_threshold[,extended=false,n_octaves=3,n_octave_layers=4]</i>) -> cvsurfparams
|
||||
*
|
||||
/*
|
||||
* Create a CvSURFParams
|
||||
*
|
||||
* @overload CvSURFParams.new(hessian_threshold, extended = false, n_octaves = 3, n_octave_layers = 4)
|
||||
* @param hessian_threshold [Number]
|
||||
* @param extended [Boolean] If <tt>true</tt>, exteneded descriptors (128 elements each),
|
||||
* otherwise basic descriptors (64 elements each)
|
||||
* @param n_octaves [Integer] Number of octaves to be used for extraction
|
||||
* @param n_octave_layers [Integer] Number of layers within each octave
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -194,6 +174,35 @@ new_object(CvSURFParams* cvsurfparams)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSURFParams", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "hessian_threshold", RUBY_METHOD_FUNC(rb_get_hessian_threshold), 0);
|
||||
rb_define_method(rb_klass, "hessian_threshold=", RUBY_METHOD_FUNC(rb_set_hessian_threshold), 1);
|
||||
rb_define_method(rb_klass, "extended", RUBY_METHOD_FUNC(rb_get_extended), 0);
|
||||
rb_define_method(rb_klass, "extended=", RUBY_METHOD_FUNC(rb_set_extended), 1);
|
||||
rb_define_method(rb_klass, "n_octaves", RUBY_METHOD_FUNC(rb_get_n_octaves), 0);
|
||||
rb_define_method(rb_klass, "n_octaves=", RUBY_METHOD_FUNC(rb_set_n_octaves), 1);
|
||||
rb_define_method(rb_klass, "n_octave_layers", RUBY_METHOD_FUNC(rb_get_n_octave_layers), 0);
|
||||
rb_define_method(rb_klass, "n_octave_layers=", RUBY_METHOD_FUNC(rb_set_n_octave_layers), 1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSURFPARAMS
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSURFPARAMS
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
|
|
@ -35,32 +35,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
|
||||
rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
|
||||
rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
|
||||
rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
|
||||
rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
|
||||
rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
|
||||
rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
|
||||
rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -69,10 +43,18 @@ rb_allocate(VALUE klass)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvSURFPoint.new(<i>pt,laplacian,size,dir,hessian</i>) -> cvsurfpoint
|
||||
*
|
||||
* Create a CvSURFPoint
|
||||
*
|
||||
* @overload new(pt, laplacian, size, dir, hessian)
|
||||
* @param pt [CvPoint2D32f] Position of the feature within the image
|
||||
* @param laplacian [Integer] -1, 0 or +1. sign of the laplacian at the point.
|
||||
* Can be used to speedup feature comparison
|
||||
* (normally features with laplacians of different signs can not match)
|
||||
* @param size [Integer] Size of the feature
|
||||
* @param dir [Number] Orientation of the feature: 0..360 degrees
|
||||
* @param hessian [Number] Value of the hessian (can be used to
|
||||
* approximately estimate the feature strengths)
|
||||
* @return [CvSURFPoint] self
|
||||
*/
|
||||
VALUE
|
||||
rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian)
|
||||
|
@ -88,9 +70,10 @@ rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALU
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* pt -> cvpoint2d32f
|
||||
* Return position of the feature as CvPoint2D32f.
|
||||
*
|
||||
* @overload pt
|
||||
* @return [CvPoint2D32f] Position of the feature.
|
||||
*/
|
||||
VALUE
|
||||
rb_get_pt(VALUE self)
|
||||
|
@ -99,10 +82,10 @@ rb_get_pt(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* pt = <i>value</i>
|
||||
*
|
||||
* Set position of the feature to <i>value</i>
|
||||
* Set position of the feature.
|
||||
*
|
||||
* @overload pt=(value)
|
||||
* @param value [CvPoint2D32f] Valuet to set.
|
||||
*/
|
||||
VALUE
|
||||
rb_set_pt(VALUE self, VALUE value)
|
||||
|
@ -112,9 +95,10 @@ rb_set_pt(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* laplacian -> number
|
||||
* Return sign of the laplacian at the point (-1, 0 or +1)
|
||||
*
|
||||
* @overload laplacian
|
||||
* @return [Integer] Sign of the laplacian at the point.
|
||||
*/
|
||||
VALUE
|
||||
rb_get_laplacian(VALUE self)
|
||||
|
@ -123,9 +107,10 @@ rb_get_laplacian(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* laplacian = <i>value</i> (-1, 0 or +1)
|
||||
* Set sign of the laplacian at the point
|
||||
*
|
||||
* @overload laplacian=(value)
|
||||
* @param value [Integer] Value to set.
|
||||
*/
|
||||
VALUE
|
||||
rb_set_laplacian(VALUE self, VALUE value)
|
||||
|
@ -136,9 +121,10 @@ rb_set_laplacian(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* size -> number
|
||||
* Return size of feature
|
||||
* Returns size of feature.
|
||||
*
|
||||
* @overload size
|
||||
* @return [Integer] Size of feature.
|
||||
*/
|
||||
VALUE
|
||||
rb_get_size(VALUE self)
|
||||
|
@ -147,9 +133,10 @@ rb_get_size(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* size = <i>value</i>
|
||||
* Return size of feature
|
||||
*
|
||||
* @overload size=(value)
|
||||
* @param [Integer] Value to set.
|
||||
*/
|
||||
VALUE
|
||||
rb_set_size(VALUE self, VALUE value)
|
||||
|
@ -159,9 +146,10 @@ rb_set_size(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dir -> number
|
||||
* Return orientation of the feature: 0..360 degrees
|
||||
*
|
||||
* @overload dir
|
||||
* @return [Number] Orientation of the feature.
|
||||
*/
|
||||
VALUE
|
||||
rb_get_dir(VALUE self)
|
||||
|
@ -170,9 +158,10 @@ rb_get_dir(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dir = <i>value</i>
|
||||
* Set orientation of the feature: 0..360 degrees
|
||||
* Set orientation of the feature: 0..360 degrees.
|
||||
*
|
||||
* @overload dir=(value)
|
||||
* @param [Number] Value to set.
|
||||
*/
|
||||
VALUE
|
||||
rb_set_dir(VALUE self, VALUE value)
|
||||
|
@ -182,9 +171,10 @@ rb_set_dir(VALUE self, VALUE value)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hessian -> number
|
||||
* Return value of the hessian
|
||||
*
|
||||
* @overload hessian
|
||||
* @return [Number] Hessian
|
||||
*/
|
||||
VALUE
|
||||
rb_get_hessian(VALUE self)
|
||||
|
@ -193,9 +183,10 @@ rb_get_hessian(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hessian = <i>value</i>
|
||||
* Set value of the hessian
|
||||
*
|
||||
* @overload hessian=(value)
|
||||
* @param [Number] Value to set.
|
||||
*/
|
||||
VALUE
|
||||
rb_set_hessian(VALUE self, VALUE value)
|
||||
|
@ -219,5 +210,37 @@ new_object(CvSURFPoint* cvsurfpoint)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
|
||||
rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
|
||||
rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
|
||||
rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
|
||||
rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
|
||||
rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
|
||||
rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
|
||||
rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSURFPOINT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVSURFPOINT
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(VALUE self, VALUE pt, VALUE laplacian, VALUE size, VALUE dir, VALUE hessian);
|
||||
|
|
|
@ -29,32 +29,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvTermCriteria", rb_cObject);
|
||||
/* CvTermCriteria: class */
|
||||
rb_define_const(opencv, "CvTerm", rb_klass);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "type", RUBY_METHOD_FUNC(rb_type), 0);
|
||||
rb_define_method(rb_klass, "max", RUBY_METHOD_FUNC(rb_max), 0);
|
||||
rb_define_method(rb_klass, "max=", RUBY_METHOD_FUNC(rb_set_max), 1);
|
||||
rb_define_method(rb_klass, "eps", RUBY_METHOD_FUNC(rb_eps), 0);
|
||||
rb_define_method(rb_klass, "eps=", RUBY_METHOD_FUNC(rb_set_eps), 1);
|
||||
rb_define_alias(rb_klass, "epsilon", "eps");
|
||||
rb_define_alias(rb_klass, "epsilon=", "eps=");
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -188,5 +162,37 @@ new_object(CvTermCriteria criteria)
|
|||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvTermCriteria", rb_cObject);
|
||||
/* CvTermCriteria: class */
|
||||
rb_define_const(opencv, "CvTerm", rb_klass);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "type", RUBY_METHOD_FUNC(rb_type), 0);
|
||||
rb_define_method(rb_klass, "max", RUBY_METHOD_FUNC(rb_max), 0);
|
||||
rb_define_method(rb_klass, "max=", RUBY_METHOD_FUNC(rb_set_max), 1);
|
||||
rb_define_method(rb_klass, "eps", RUBY_METHOD_FUNC(rb_eps), 0);
|
||||
rb_define_method(rb_klass, "eps=", RUBY_METHOD_FUNC(rb_set_eps), 1);
|
||||
rb_define_alias(rb_klass, "epsilon", "eps");
|
||||
rb_define_alias(rb_klass, "epsilon=", "eps=");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVTERMCRITERIA
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVTERMCRITERIA
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
************************************************************/
|
||||
#include "cvtwopoints.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvTwopoints
|
||||
* Document-class: OpenCV::CvTwoPoints
|
||||
*
|
||||
* This class means one twopoints on X axis Y axis.
|
||||
* X and Y takes the value of the Fixnum. see also CvTwopoints2D32F
|
||||
|
@ -31,27 +31,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvTwoPoints", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "point1", RUBY_METHOD_FUNC(rb_point1), 0);
|
||||
rb_define_method(rb_klass, "point2", RUBY_METHOD_FUNC(rb_point2), 0);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -112,5 +91,32 @@ rb_to_ary(VALUE self)
|
|||
return rb_ary_new3(2, rb_point1(self), rb_point2(self));
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvTwoPoints", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
rb_define_method(rb_klass, "point1", RUBY_METHOD_FUNC(rb_point1), 0);
|
||||
rb_define_method(rb_klass, "point2", RUBY_METHOD_FUNC(rb_point2), 0);
|
||||
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
rb_define_alias(rb_klass, "to_a", "to_ary");
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVTWOPOINTS
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ __NAMESPACE_BEGIN_CVTWOPOINTS
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
||||
|
|
|
@ -26,27 +26,10 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvVideoWriter", rb_cObject);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "write", RUBY_METHOD_FUNC(rb_write), 1);
|
||||
rb_define_method(rb_klass, "close", RUBY_METHOD_FUNC(rb_close), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvVideoWriter.new(<i>filname, fourcc, fps, size[, is_color]</i>) -> cvvideowriter
|
||||
* CvVideoWriter.new(<i>filname, fourcc, fps, size[, is_color]</i>){|vw| ... } -> nil
|
||||
* CvVideoWriter.new(filname, fourcc, fps, size[, is_color]) -> cvvideowriter
|
||||
* CvVideoWriter.new(filname, fourcc, fps, size[, is_color]){|vw| ... } -> nil
|
||||
*
|
||||
* Open new video writer. If block given, writer is closed automatically when end of block.
|
||||
*
|
||||
|
@ -98,7 +81,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* write(<i>frame</i>)
|
||||
* write(frame)
|
||||
*
|
||||
* Write image as frame of video stream.
|
||||
* <i>frame</i> should be IplImage
|
||||
|
@ -132,6 +115,28 @@ rb_close(VALUE self)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvVideoWriter", rb_cObject);
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "write", RUBY_METHOD_FUNC(rb_write), 1);
|
||||
rb_define_method(rb_klass, "close", RUBY_METHOD_FUNC(rb_close), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVVIDEOWRITER
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_CVVIDEOWRITER
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_write(VALUE self, VALUE frame);
|
||||
|
|
|
@ -47,8 +47,15 @@ rb_initialize(int argc, VALUE argv[], VALUE self)
|
|||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE alghorithm = rb_define_class_under(opencv, "Algorithm", rb_cObject);
|
||||
VALUE face_recognizer = rb_define_class_under(opencv, "FaceRecognizer", alghorithm);
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
|
@ -57,7 +64,8 @@ define_ruby_class()
|
|||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "EigenFaces", cFaceRecognizer::rb_class());
|
||||
VALUE face_recognizer = cFaceRecognizer::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "EigenFaces", face_recognizer);
|
||||
rb_define_alloc_func(rb_klass, cFaceRecognizer::allocate_facerecognizer);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_EIGENFACES
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
VALUE rb_initialize(int argc, VALUE argv[], VALUE self);
|
||||
|
||||
__NAMESPACE_END_EIGENFACES
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
CC = RbConfig::CONFIG['CC']
|
||||
if CC =~ /clang/
|
||||
RbConfig::MAKEFILE_CONFIG['try_header'] = :try_cpp
|
||||
RbConfig::CONFIG['CPP'] = "#{CC} -E"
|
||||
elsif RbConfig::CONFIG['arch'] =~ /mswin32/
|
||||
RbConfig::MAKEFILE_CONFIG['try_header'] = :try_cpp
|
||||
RbConfig::CONFIG['CPP'] = "#{CC} /P"
|
||||
end
|
||||
|
||||
require "mkmf"
|
||||
|
||||
def cv_version_suffix(incdir)
|
||||
|
@ -46,6 +56,7 @@ when /mswin32/
|
|||
warn "#{lib}.lib not found." unless have_library(lib)
|
||||
}
|
||||
$CFLAGS << ' /EHsc'
|
||||
CONFIG['CXXFLAGS'] << ' /EHsc'
|
||||
when /mingw32/
|
||||
suffix = cv_version_suffix(incdir)
|
||||
opencv_libraries.map! {|lib| lib + suffix }
|
||||
|
@ -73,15 +84,7 @@ opencv_headers.each {|header|
|
|||
raise "#{header} not found." unless have_header(header)
|
||||
}
|
||||
opencv_headers_opt.each {|header|
|
||||
unless have_header(header)
|
||||
if CONFIG["arch"] =~ /mswin32/ and File.exists? "#{incdir}/#{header}"
|
||||
# In mswin32, have_header('opencv2/nonfree/nonfree.hpp') fails because of a syntax problem.
|
||||
warn "warning: #{header} found but `have_header` failed."
|
||||
$defs << "-DHAVE_#{header.tr_cpp}"
|
||||
else
|
||||
warn "#{header} not found."
|
||||
end
|
||||
end
|
||||
raise "#{header} not found." unless have_header(header)
|
||||
}
|
||||
have_header("stdarg.h")
|
||||
|
||||
|
|
|
@ -18,20 +18,19 @@ __NAMESPACE_BEGIN_FACERECOGNIZER
|
|||
|
||||
VALUE rb_klass;
|
||||
|
||||
std::map< long, cv::Ptr<cv::FaceRecognizer> > ptr_guard_map;
|
||||
std::map<void*, cv::Ptr<cv::FaceRecognizer> > ptr_guard_map;
|
||||
|
||||
void
|
||||
guard_facerecognizer(void* data_ptr, cv::Ptr<cv::FaceRecognizer> ptr)
|
||||
{
|
||||
ptr_guard_map[(long)data_ptr] = ptr;
|
||||
ptr_guard_map[data_ptr] = ptr;
|
||||
}
|
||||
|
||||
void
|
||||
release_facerecognizer(void *ptr)
|
||||
release_facerecognizer(void *data_ptr)
|
||||
{
|
||||
long key = (long)ptr;
|
||||
ptr_guard_map[key].release();
|
||||
ptr_guard_map.erase(key);
|
||||
ptr_guard_map[data_ptr].release();
|
||||
ptr_guard_map.erase(data_ptr);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -153,8 +152,14 @@ rb_load(VALUE self, VALUE filename)
|
|||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE alghorithm = rb_define_class_under(opencv, "Algorithm", rb_cObject);
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
|
@ -163,7 +168,8 @@ define_ruby_class()
|
|||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "FaceRecognizer", cAlgorithm::rb_class());
|
||||
VALUE alghorithm = cAlgorithm::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "FaceRecognizer", alghorithm);
|
||||
rb_define_method(rb_klass, "train", RUBY_METHOD_FUNC(rb_train), 2);
|
||||
rb_define_method(rb_klass, "predict", RUBY_METHOD_FUNC(rb_predict), 1);
|
||||
rb_define_method(rb_klass, "save", RUBY_METHOD_FUNC(rb_save), 1);
|
||||
|
@ -172,3 +178,4 @@ define_ruby_class()
|
|||
|
||||
__NAMESPACE_END_FACERECOGNIZER
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ __NAMESPACE_BEGIN_FACERECOGNIZER
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
VALUE rb_train(VALUE self, VALUE src, VALUE labels);
|
||||
VALUE rb_predict(VALUE self, VALUE src);
|
||||
VALUE rb_save(VALUE self, VALUE filename);
|
||||
VALUE rb_load(VALUE self, VALUE filename);
|
||||
|
||||
void guard_facerecognizer(void* data_ptr, cv::Ptr<cv::FaceRecognizer> ptr);
|
||||
void release_facerecognizer(void *ptr);
|
||||
void release_facerecognizer(void *data_ptr);
|
||||
VALUE allocate_facerecognizer(VALUE klass);
|
||||
|
||||
__NAMESPACE_END_FACERECOGNIZER
|
||||
|
|
|
@ -47,8 +47,15 @@ rb_initialize(int argc, VALUE argv[], VALUE self)
|
|||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
VALUE alghorithm = rb_define_class_under(opencv, "Algorithm", rb_cObject);
|
||||
VALUE face_recognizer = rb_define_class_under(opencv, "FaceRecognizer", alghorithm);
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
|
@ -57,7 +64,8 @@ define_ruby_class()
|
|||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "FisherFaces", cFaceRecognizer::rb_class());
|
||||
VALUE face_recognizer = cFaceRecognizer::rb_class();
|
||||
rb_klass = rb_define_class_under(opencv, "FisherFaces", face_recognizer);
|
||||
rb_define_alloc_func(rb_klass, cFaceRecognizer::allocate_facerecognizer);
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ __NAMESPACE_BEGIN_FISHERFACES
|
|||
|
||||
VALUE rb_class();
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
VALUE rb_initialize(int argc, VALUE argv[], VALUE self);
|
||||
|
||||
__NAMESPACE_END_FISHERFACES
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#include "gui.h"
|
||||
/*
|
||||
* Document-module: OpenCV::GUI
|
||||
*
|
||||
* OpenCV simple GUI interface. Provides Window, Trackbar.
|
||||
* This GUI work on GTK or Microsoft Windows native GUI.
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_GUI
|
||||
|
@ -25,28 +22,14 @@ rb_module_GUI()
|
|||
return rb_module;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_module()
|
||||
{
|
||||
if (rb_module)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_module = rb_define_module_under(opencv, "GUI");
|
||||
rb_define_singleton_method(rb_module, "wait_key", RUBY_METHOD_FUNC(rb_wait_key), -1);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* wait_key(<i>[delay]</i>) -> int or nil
|
||||
* Waits for a pressed key.
|
||||
*
|
||||
* Waits for a pressed key each GUI wedget.
|
||||
* Return the code of the pressed key or nil if no key were pressed until the specified timeout has elapsed.
|
||||
* <i>delay</i> should be Fixnum. Wait <i>delay</i> millisecond.
|
||||
* @overload wait_key(delay = 0)
|
||||
* @param delay [Integer] Delay in milliseconds. 0 is the special value that means "forever".
|
||||
* @return [Number] The code of the pressed key or <tt>nil</tt> if no key was pressed
|
||||
* before the specified time had elapsed.
|
||||
* @opencv_func cvWaitKey
|
||||
*/
|
||||
VALUE
|
||||
rb_wait_key(int argc, VALUE *argv, VALUE self)
|
||||
|
@ -63,6 +46,26 @@ rb_wait_key(int argc, VALUE *argv, VALUE self)
|
|||
return (keycode < 0) ? Qnil : INT2NUM(keycode);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_module()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_module)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_module = rb_define_module_under(opencv, "GUI");
|
||||
rb_define_singleton_method(rb_module, "wait_key", RUBY_METHOD_FUNC(rb_wait_key), -1);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_GUI
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ __NAMESPACE_BEGIN_OPENCV
|
|||
__NAMESPACE_BEGIN_GUI
|
||||
|
||||
VALUE rb_module_GUI();
|
||||
void define_ruby_module();
|
||||
void init_ruby_module();
|
||||
|
||||
VALUE rb_wait_key(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
|
|
|
@ -29,30 +29,6 @@ rb_class()
|
|||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "IplConvKernel", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
|
||||
rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
|
||||
rb_define_method(rb_klass, "cols", RUBY_METHOD_FUNC(rb_cols), 0);
|
||||
rb_define_alias(rb_klass, "columns", "cols");
|
||||
rb_define_method(rb_klass, "rows", RUBY_METHOD_FUNC(rb_rows), 0);
|
||||
rb_define_method(rb_klass, "anchor", RUBY_METHOD_FUNC(rb_anchor), 0);
|
||||
rb_define_method(rb_klass, "anchor_x", RUBY_METHOD_FUNC(rb_anchor_x), 0);
|
||||
rb_define_method(rb_klass, "anchor_y", RUBY_METHOD_FUNC(rb_anchor_y), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -188,5 +164,35 @@ rb_anchor_y(VALUE self)
|
|||
return INT2NUM(IPLCONVKERNEL(self)->anchorY);
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
#if 0
|
||||
// For documentation using YARD
|
||||
VALUE opencv = rb_define_module("OpenCV");
|
||||
#endif
|
||||
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "IplConvKernel", rb_cObject);
|
||||
rb_define_alloc_func(rb_klass, rb_allocate);
|
||||
|
||||
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
|
||||
rb_define_method(rb_klass, "cols", RUBY_METHOD_FUNC(rb_cols), 0);
|
||||
rb_define_alias(rb_klass, "columns", "cols");
|
||||
rb_define_method(rb_klass, "rows", RUBY_METHOD_FUNC(rb_rows), 0);
|
||||
rb_define_method(rb_klass, "anchor", RUBY_METHOD_FUNC(rb_anchor), 0);
|
||||
rb_define_method(rb_klass, "anchor_x", RUBY_METHOD_FUNC(rb_anchor_x), 0);
|
||||
rb_define_method(rb_klass, "anchor_y", RUBY_METHOD_FUNC(rb_anchor_y), 0);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_IPLCONVKERNEL
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ __NAMESPACE_BEGIN_IPLCONVKERNEL
|
|||
VALUE rb_class();
|
||||
VALUE rb_allocate(VALUE klass);
|
||||
|
||||
void define_ruby_class();
|
||||
void init_ruby_class();
|
||||
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_size(VALUE self);
|
||||
VALUE rb_cols(VALUE self);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue