mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
removed some unnecessary CvMat methods
Removed methods are: CvMat#rb_morphology_* CvMat#rb_copy_make_border_* CvMat#rb_hough_lines_* CvMat#rb_hough_circles_* CvMat#rb_inpaint_* CvMat#rb_match_shapes_* CvMat#rb_threshold_* CvMat#rb_find_fundamental_mat_* CvMat#rb_smooth_* CvMat#rb_slice_width CvMat#rb_slice_height CvMat#rb_mix_channels
This commit is contained in:
parent
46227b7fa1
commit
7add8ec805
7 changed files with 39 additions and 1472 deletions
|
@ -12,7 +12,7 @@ gray = image.BGR2GRAY
|
|||
|
||||
result = image.clone
|
||||
original_window.show image
|
||||
detect = gray.hough_circles_gradient(2.0, 10, 200, 50)
|
||||
detect = gray.hough_circles(CV_HOUGH_GRADIENT, 2.0, 10, 200, 50)
|
||||
puts detect.size
|
||||
detect.each{|circle|
|
||||
puts "#{circle.center.x},#{circle.center.y} - #{circle.radius}"
|
||||
|
|
|
@ -11,7 +11,7 @@ iwindow = GUI::Window.new "inpaint"
|
|||
|
||||
image = IplImage::load "inpaint.png"
|
||||
b, g, r = image.split
|
||||
original_mask = r.threshold_binary_inverse(0x00, 0xFF) & b.threshold_binary_inverse(0x00, 0xFF)
|
||||
original_mask = r.threshold(0x00, 0xFF, CV_THRESH_BINARY_INV) & b.threshold(0x00, 0xFF, CV_THRESH_BINARY_INV)
|
||||
mask = original_mask.copy
|
||||
|
||||
num_dilate = 3
|
||||
|
|
|
@ -33,7 +33,7 @@ window.on_mouse{|mouse|
|
|||
end
|
||||
points = image.snake_image(points, 1.0, 0.5, 1.5, CvSize.new(3, 3), 100)
|
||||
display = image.GRAY2BGR
|
||||
display.poly_line! points, :color => CvColor::Red, :is_closed => true
|
||||
display.poly_line!(points, :color => CvColor::Red, :is_closed => true)
|
||||
window.show display
|
||||
end
|
||||
}
|
||||
|
|
|
@ -187,8 +187,6 @@ void define_ruby_class()
|
|||
rb_define_method(rb_klass, "to_CvMat", RUBY_METHOD_FUNC(rb_to_CvMat), 0);
|
||||
rb_define_method(rb_klass, "sub_rect", RUBY_METHOD_FUNC(rb_sub_rect), -2);
|
||||
rb_define_alias(rb_klass, "subrect", "sub_rect");
|
||||
rb_define_method(rb_klass, "slice_width", RUBY_METHOD_FUNC(rb_slice_width), 1);
|
||||
rb_define_method(rb_klass, "slice_height", RUBY_METHOD_FUNC(rb_slice_height), 1);
|
||||
rb_define_method(rb_klass, "row", RUBY_METHOD_FUNC(rb_row), -2);
|
||||
rb_define_method(rb_klass, "col", RUBY_METHOD_FUNC(rb_col), -2);
|
||||
rb_define_alias(rb_klass, "column", "col");
|
||||
|
@ -330,28 +328,11 @@ void define_ruby_class()
|
|||
rb_define_method(rb_klass, "dilate", RUBY_METHOD_FUNC(rb_dilate), -1);
|
||||
rb_define_method(rb_klass, "dilate!", RUBY_METHOD_FUNC(rb_dilate_bang), -1);
|
||||
rb_define_method(rb_klass, "morphology", RUBY_METHOD_FUNC(rb_morphology), -1);
|
||||
rb_define_method(rb_klass, "morphology_open", RUBY_METHOD_FUNC(rb_morphology_open), -1);
|
||||
rb_define_method(rb_klass, "morphology_close", RUBY_METHOD_FUNC(rb_morphology_close), -1);
|
||||
rb_define_method(rb_klass, "morphology_gradient", RUBY_METHOD_FUNC(rb_morphology_gradient), -1);
|
||||
rb_define_method(rb_klass, "morphology_tophat", RUBY_METHOD_FUNC(rb_morphology_tophat), -1);
|
||||
rb_define_method(rb_klass, "morphology_blackhat", RUBY_METHOD_FUNC(rb_morphology_blackhat), -1);
|
||||
|
||||
rb_define_method(rb_klass, "smooth", RUBY_METHOD_FUNC(rb_smooth), -1);
|
||||
rb_define_method(rb_klass, "smooth_blur_no_scale", RUBY_METHOD_FUNC(rb_smooth_blur_no_scale), -1);
|
||||
rb_define_method(rb_klass, "smooth_blur", RUBY_METHOD_FUNC(rb_smooth_blur), -1);
|
||||
rb_define_method(rb_klass, "smooth_gaussian", RUBY_METHOD_FUNC(rb_smooth_gaussian), -1);
|
||||
rb_define_method(rb_klass, "smooth_median", RUBY_METHOD_FUNC(rb_smooth_median), -1);
|
||||
rb_define_method(rb_klass, "smooth_bilateral", RUBY_METHOD_FUNC(rb_smooth_bilateral), -1);
|
||||
rb_define_method(rb_klass, "filter2d", RUBY_METHOD_FUNC(rb_filter2d), -1);
|
||||
rb_define_method(rb_klass, "copy_make_border_constant", RUBY_METHOD_FUNC(rb_copy_make_border_constant), -1);
|
||||
rb_define_method(rb_klass, "copy_make_border_replicate", RUBY_METHOD_FUNC(rb_copy_make_border_replicate), -1);
|
||||
rb_define_method(rb_klass, "integral", RUBY_METHOD_FUNC(rb_integral), -1);
|
||||
rb_define_method(rb_klass, "threshold", RUBY_METHOD_FUNC(rb_threshold), -1);
|
||||
rb_define_method(rb_klass, "threshold_binary", RUBY_METHOD_FUNC(rb_threshold_binary), -1);
|
||||
rb_define_method(rb_klass, "threshold_binary_inverse", RUBY_METHOD_FUNC(rb_threshold_binary_inverse), -1);
|
||||
rb_define_method(rb_klass, "threshold_trunc", RUBY_METHOD_FUNC(rb_threshold_trunc), -1);
|
||||
rb_define_method(rb_klass, "threshold_to_zero", RUBY_METHOD_FUNC(rb_threshold_to_zero), -1);
|
||||
rb_define_method(rb_klass, "threshold_to_zero_inverse", RUBY_METHOD_FUNC(rb_threshold_to_zero_inverse), -1);
|
||||
|
||||
rb_define_method(rb_klass, "pyr_down", RUBY_METHOD_FUNC(rb_pyr_down), -1);
|
||||
rb_define_method(rb_klass, "pyr_up", RUBY_METHOD_FUNC(rb_pyr_up), -1);
|
||||
|
@ -367,23 +348,13 @@ void define_ruby_class()
|
|||
rb_define_method(rb_klass, "moments", RUBY_METHOD_FUNC(rb_moments), -1);
|
||||
|
||||
rb_define_method(rb_klass, "hough_lines", RUBY_METHOD_FUNC(rb_hough_lines), -1);
|
||||
rb_define_method(rb_klass, "hough_lines_standard", RUBY_METHOD_FUNC(rb_hough_lines_standard), 3);
|
||||
rb_define_method(rb_klass, "hough_lines_probabilistic", RUBY_METHOD_FUNC(rb_hough_lines_probabilistic), 5);
|
||||
rb_define_method(rb_klass, "hough_lines_multi_scale", RUBY_METHOD_FUNC(rb_hough_lines_multi_scale), 5);
|
||||
rb_define_method(rb_klass, "hough_circles", RUBY_METHOD_FUNC(rb_hough_circles), -1);
|
||||
rb_define_method(rb_klass, "hough_circles_gradient", RUBY_METHOD_FUNC(rb_hough_circles_gradient), -1);
|
||||
//rb_define_method(rb_klass, "dist_transform", RUBY_METHOD_FUNC(rb_dist_transform), -1);
|
||||
|
||||
rb_define_method(rb_klass, "inpaint", RUBY_METHOD_FUNC(rb_inpaint), 3);
|
||||
rb_define_method(rb_klass, "inpaint_ns", RUBY_METHOD_FUNC(rb_inpaint_ns), 2);
|
||||
rb_define_method(rb_klass, "inpaint_telea", RUBY_METHOD_FUNC(rb_inpaint_telea), 2);
|
||||
|
||||
rb_define_method(rb_klass, "equalize_hist", RUBY_METHOD_FUNC(rb_equalize_hist), 0);
|
||||
rb_define_method(rb_klass, "match_template", RUBY_METHOD_FUNC(rb_match_template), -1);
|
||||
rb_define_method(rb_klass, "match_shapes", RUBY_METHOD_FUNC(rb_match_shapes), -1);
|
||||
rb_define_method(rb_klass, "match_shapes_i1", RUBY_METHOD_FUNC(rb_match_shapes_i1), -1);
|
||||
rb_define_method(rb_klass, "match_shapes_i2", RUBY_METHOD_FUNC(rb_match_shapes_i2), -1);
|
||||
rb_define_method(rb_klass, "match_shapes_i3", RUBY_METHOD_FUNC(rb_match_shapes_i3), -1);
|
||||
|
||||
rb_define_method(rb_klass, "mean_shift", RUBY_METHOD_FUNC(rb_mean_shift), 2);
|
||||
rb_define_method(rb_klass, "cam_shift", RUBY_METHOD_FUNC(rb_cam_shift), 2);
|
||||
|
@ -393,14 +364,6 @@ void define_ruby_class()
|
|||
rb_define_method(rb_klass, "optical_flow_lk", RUBY_METHOD_FUNC(rb_optical_flow_lk), 2);
|
||||
rb_define_method(rb_klass, "optical_flow_bm", RUBY_METHOD_FUNC(rb_optical_flow_bm), -1);
|
||||
|
||||
rb_define_singleton_method(rb_klass, "find_fundamental_mat_7point",
|
||||
RUBY_METHOD_FUNC(rb_find_fundamental_mat_7point), 2);
|
||||
rb_define_singleton_method(rb_klass, "find_fundamental_mat_8point",
|
||||
RUBY_METHOD_FUNC(rb_find_fundamental_mat_8point), 2);
|
||||
rb_define_singleton_method(rb_klass, "find_fundamental_mat_ransac",
|
||||
RUBY_METHOD_FUNC(rb_find_fundamental_mat_ransac), -1);
|
||||
rb_define_singleton_method(rb_klass, "find_fundamental_mat_lmeds",
|
||||
RUBY_METHOD_FUNC(rb_find_fundamental_mat_lmeds), -1);
|
||||
rb_define_singleton_method(rb_klass, "find_fundamental_mat",
|
||||
RUBY_METHOD_FUNC(rb_find_fundamental_mat), -1);
|
||||
rb_define_singleton_method(rb_klass, "compute_correspond_epilines",
|
||||
|
@ -948,65 +911,6 @@ rb_sub_rect(VALUE self, VALUE args)
|
|||
self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* slice_width(<i>n</i>)
|
||||
*
|
||||
* The matrix is divided into <i>n</i> piece by the width.
|
||||
* If it cannot be just divided, warning is displayed.
|
||||
*
|
||||
* e.g.
|
||||
* m = OpenCV::CvMat.new(10, 10) #=> size 10x10 matrix
|
||||
* ml, mr = m.slice_width(2) #=> 5x10 and 5x10 matrix
|
||||
*
|
||||
* ml, mm, mr = m.slice_width(3)#=> 3x10 3x10 3x10 matrix
|
||||
* warning : width does not div correctly.
|
||||
*/
|
||||
VALUE
|
||||
rb_slice_width(VALUE self, VALUE num)
|
||||
{
|
||||
int n = NUM2INT(num);
|
||||
if (n < 1)
|
||||
rb_raise(rb_eArgError, "number of piece should be > 0");
|
||||
CvSize size = cvGetSize(CVARR(self));
|
||||
if (size.width % n != 0)
|
||||
rb_warn("width does not div correctly.");
|
||||
int div_x = size.width / n;
|
||||
VALUE ary = rb_ary_new2(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
CvRect rect = { div_x * i, 0, div_x, size.height };
|
||||
rb_ary_push(ary, DEPEND_OBJECT(rb_klass, cvGetSubRect(CVARR(self), RB_CVALLOC(CvMat), rect), self));
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* slice_height(<i>n</i>)
|
||||
*
|
||||
* The matrix is divided into <i>n</i> piece by the height.
|
||||
* If it cannot be just divided, warning is displayed.
|
||||
*
|
||||
* see also #slice_width.
|
||||
*/
|
||||
VALUE
|
||||
rb_slice_height(VALUE self, VALUE num)
|
||||
{
|
||||
int n = NUM2INT(num);
|
||||
if (n < 1)
|
||||
rb_raise(rb_eArgError, "number of piece should be > 0");
|
||||
CvSize size = cvGetSize(CVARR(self));
|
||||
if (size.height % n != 0)
|
||||
rb_warn("height does not div correctly.");
|
||||
int div_y = size.height / n;
|
||||
VALUE ary = rb_ary_new2(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
CvRect rect = { 0, div_y * i, size.width, div_y };
|
||||
rb_ary_push(ary, DEPEND_OBJECT(rb_klass, cvGetSubRect(CVARR(self), RB_CVALLOC(CvMat), rect), self));
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* row(<i>n</i>) -> Return row
|
||||
|
@ -1604,19 +1508,6 @@ rb_merge(VALUE klass, VALUE args)
|
|||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMat.mix_channels(srcs,dests,from_to = {1 => 1, 2 => 2, 3 => 3, 4 => 4}) -> dests
|
||||
*/
|
||||
VALUE
|
||||
rb_mix_channels(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE srcs, dests, from_to;
|
||||
rb_scan_args(argc, argv, "21", &srcs, &dests, &from_to);
|
||||
/* not yet */
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* rand_shuffle([seed = nil][,iter_factor = 1]) -> cvmat
|
||||
|
@ -3661,117 +3552,6 @@ rb_morphology(int argc, VALUE *argv, VALUE self)
|
|||
return rb_morphology_internal(element, iteration, CVMETHOD("MORPHOLOGICAL_OPERATION", operation, -1), self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* morpholohy_open(<i>[element = nil][,iteration = 1]</i>) -> cvmat
|
||||
*
|
||||
* Performs advanced morphological transformations "Opening".
|
||||
* dilate(erode(src,element),element)
|
||||
*/
|
||||
VALUE
|
||||
rb_morphology_open(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE element, iteration;
|
||||
rb_scan_args(argc, argv, "02", &element, &iteration);
|
||||
return rb_morphology_internal(element, iteration, CV_MOP_OPEN, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* morpholohy_close(<i>[element = nil][,iteration = 1]</i>) -> cvmat
|
||||
*
|
||||
* Performs advanced morphological transformations "Closing".
|
||||
* erode(dilate(src,element),element)
|
||||
*/
|
||||
VALUE
|
||||
rb_morphology_close(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE element, iteration;
|
||||
rb_scan_args(argc, argv, "02", &element, &iteration);
|
||||
return rb_morphology_internal(element, iteration, CV_MOP_CLOSE, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* morpholohy_gradient(<i>[element = nil][,iteration = 1]</i>) -> cvmat
|
||||
*
|
||||
* Performs advanced morphological transformations "Morphological gradient".
|
||||
* dilate(src,element)-erode(src,element)
|
||||
*/
|
||||
VALUE
|
||||
rb_morphology_gradient(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE element, iteration;
|
||||
rb_scan_args(argc, argv, "02", &element, &iteration);
|
||||
return rb_morphology_internal(element, iteration, CV_MOP_GRADIENT, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* morpholohy_tophat(<i>[element = nil][,iteration = 1]</i>) -> cvmat
|
||||
*
|
||||
* Performs advanced morphological transformations "tophat".
|
||||
* src-open(src,element)
|
||||
*/
|
||||
VALUE
|
||||
rb_morphology_tophat(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE element, iteration;
|
||||
rb_scan_args(argc, argv, "02", &element, &iteration);
|
||||
return rb_morphology_internal(element, iteration, CV_MOP_TOPHAT, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* morpholohy_blackhat(<i>[element = nil][,iteration = 1]</i>) -> cvmat
|
||||
*
|
||||
* Performs advanced morphological transformations "blackhat".
|
||||
* close(src,element)-src
|
||||
*/
|
||||
VALUE
|
||||
rb_morphology_blackhat(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE element, iteration, dest;
|
||||
rb_scan_args(argc, argv, "02", &element, &iteration);
|
||||
return rb_morphology_internal(element, iteration, CV_MOP_BLACKHAT, self);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_smooth(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE smoothtype, p1, p2, p3, p4;
|
||||
rb_scan_args(argc, argv, "14", &smoothtype, &p1, &p2, &p3, &p4);
|
||||
int _smoothtype = CVMETHOD("SMOOTHING_TYPE", smoothtype, -1);
|
||||
|
||||
VALUE (*smooth_func)(int c, VALUE* v, VALUE s);
|
||||
argc--;
|
||||
switch (_smoothtype) {
|
||||
case CV_BLUR_NO_SCALE:
|
||||
smooth_func = rb_smooth_blur_no_scale;
|
||||
argc = (argc > 2) ? 2 : argc;
|
||||
break;
|
||||
case CV_BLUR:
|
||||
smooth_func = rb_smooth_blur;
|
||||
argc = (argc > 2) ? 2 : argc;
|
||||
break;
|
||||
case CV_GAUSSIAN:
|
||||
smooth_func = rb_smooth_gaussian;
|
||||
break;
|
||||
case CV_MEDIAN:
|
||||
smooth_func = rb_smooth_median;
|
||||
argc = (argc > 1) ? 1 : argc;
|
||||
break;
|
||||
case CV_BILATERAL:
|
||||
smooth_func = rb_smooth_bilateral;
|
||||
argc = (argc > 2) ? 2 : argc;
|
||||
break;
|
||||
default:
|
||||
smooth_func = rb_smooth_gaussian;
|
||||
break;
|
||||
}
|
||||
return (*smooth_func)(argc, argv + 1, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* smooth_blur_no_scale(<i>[p1 = 3, p2 = 3]</i>) -> cvmat
|
||||
|
@ -3886,6 +3666,42 @@ rb_smooth_bilateral(int argc, VALUE *argv, VALUE self)
|
|||
return dest;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_smooth(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE smoothtype, p1, p2, p3, p4;
|
||||
rb_scan_args(argc, argv, "14", &smoothtype, &p1, &p2, &p3, &p4);
|
||||
int _smoothtype = CVMETHOD("SMOOTHING_TYPE", smoothtype, -1);
|
||||
|
||||
VALUE (*smooth_func)(int c, VALUE* v, VALUE s);
|
||||
argc--;
|
||||
switch (_smoothtype) {
|
||||
case CV_BLUR_NO_SCALE:
|
||||
smooth_func = rb_smooth_blur_no_scale;
|
||||
argc = (argc > 2) ? 2 : argc;
|
||||
break;
|
||||
case CV_BLUR:
|
||||
smooth_func = rb_smooth_blur;
|
||||
argc = (argc > 2) ? 2 : argc;
|
||||
break;
|
||||
case CV_GAUSSIAN:
|
||||
smooth_func = rb_smooth_gaussian;
|
||||
break;
|
||||
case CV_MEDIAN:
|
||||
smooth_func = rb_smooth_median;
|
||||
argc = (argc > 1) ? 1 : argc;
|
||||
break;
|
||||
case CV_BILATERAL:
|
||||
smooth_func = rb_smooth_bilateral;
|
||||
argc = (argc > 2) ? 2 : argc;
|
||||
break;
|
||||
default:
|
||||
smooth_func = rb_smooth_gaussian;
|
||||
break;
|
||||
}
|
||||
return (*smooth_func)(argc, argv + 1, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* filter2d(<i>kernel[,anchor]</i>) -> cvmat
|
||||
|
@ -3907,42 +3723,6 @@ rb_filter2d(int argc, VALUE *argv, VALUE self)
|
|||
return _dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* copy_make_border_constant(<i>size, offset[,value = CvScalar.new(0)]</i>)
|
||||
*
|
||||
* Copies image and makes border around it.
|
||||
* Border is filled with the fixed value, passed as last parameter of the function.
|
||||
*/
|
||||
VALUE
|
||||
rb_copy_make_border_constant(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE size, offset, value, dest;
|
||||
rb_scan_args(argc, argv, "21", &size, &offset, &value);
|
||||
dest = new_mat_kind_object(VALUE_TO_CVSIZE(size), self);
|
||||
cvCopyMakeBorder(CVARR(self), CVARR(dest), VALUE_TO_CVPOINT(offset), IPL_BORDER_CONSTANT,
|
||||
NIL_P(value) ? cvScalar(0) : VALUE_TO_CVSCALAR(value));
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* copy_make_border_replicate(<i>size, offset</i>)
|
||||
*
|
||||
* Copies image and makes border around it.
|
||||
* The pixels from the top and bottom rows,
|
||||
* the left-most and right-most columns are replicated to fill the border.
|
||||
*/
|
||||
VALUE
|
||||
rb_copy_make_border_replicate(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE size, offset, dest;
|
||||
rb_scan_args(argc, argv, "20", &size, &offset);
|
||||
dest = new_mat_kind_object(VALUE_TO_CVSIZE(size), self);
|
||||
cvCopyMakeBorder(CVARR(self), CVARR(dest), VALUE_TO_CVPOINT(offset), IPL_BORDER_REPLICATE);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* integral(<i>need_sqsum = false, need_tilted_sum = false</i>) -> [cvmat, cvmat or nil, cvmat or nil]
|
||||
|
@ -4017,91 +3797,6 @@ rb_threshold(int argc, VALUE *argv, VALUE self)
|
|||
return rb_threshold_internal(type, threshold, max_value, use_otsu, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* threshold_binary(<i>threshold, max_value[,use_otsu = false]</i>)
|
||||
*
|
||||
* Applies fixed-level threshold to array elements.
|
||||
*
|
||||
* dst(x,y) = max_value, if src(x,y)>threshold
|
||||
* 0, otherwise
|
||||
*/
|
||||
VALUE
|
||||
rb_threshold_binary(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE threshold, max_value, use_otsu;
|
||||
rb_scan_args(argc, argv, "21", &threshold, &max_value, &use_otsu);
|
||||
return rb_threshold_internal(CV_THRESH_BINARY, threshold, max_value, use_otsu, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* threshold_binary_inverse(<i>threshold, max_value[,use_otsu = false]</i>)
|
||||
*
|
||||
* Applies fixed-level threshold to array elements.
|
||||
*
|
||||
* dst(x,y) = 0, if src(x,y)>threshold
|
||||
* max_value, otherwise
|
||||
*/
|
||||
VALUE
|
||||
rb_threshold_binary_inverse(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE threshold, max_value, use_otsu;
|
||||
rb_scan_args(argc, argv, "21", &threshold, &max_value, &use_otsu);
|
||||
return rb_threshold_internal(CV_THRESH_BINARY_INV, threshold, max_value, use_otsu, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* threshold_trunc(<i>threshold[,use_otsu = false]</i>)
|
||||
*
|
||||
* Applies fixed-level threshold to array elements.
|
||||
*
|
||||
* dst(x,y) = threshold, if src(x,y)>threshold
|
||||
* src(x,y), otherwise
|
||||
*/
|
||||
VALUE
|
||||
rb_threshold_trunc(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE threshold, use_otsu;
|
||||
rb_scan_args(argc, argv, "11", &threshold, &use_otsu);
|
||||
return rb_threshold_internal(CV_THRESH_TRUNC, threshold, INT2NUM(0), use_otsu, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* threshold_to_zero(<i>threshold[,use_otsu = false]</i>)
|
||||
*
|
||||
* Applies fixed-level threshold to array elements.
|
||||
*
|
||||
* dst(x,y) = src(x,y), if src(x,y)>threshold
|
||||
* 0, otherwise
|
||||
*/
|
||||
VALUE
|
||||
rb_threshold_to_zero(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE threshold, use_otsu;
|
||||
rb_scan_args(argc, argv, "11", &threshold, &use_otsu);
|
||||
return rb_threshold_internal(CV_THRESH_TOZERO, threshold, INT2NUM(0), use_otsu, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* threshold_to_zero_inverse(<i>threshold[,use_otsu = false]</i>)
|
||||
*
|
||||
* Applies fixed-level threshold to array elements.
|
||||
*
|
||||
* dst(x,y) = 0, if src(x,y)>threshold
|
||||
* src(x,y), otherwise
|
||||
*/
|
||||
VALUE
|
||||
rb_threshold_to_zero_inverse(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE threshold, use_otsu;
|
||||
rb_scan_args(argc, argv, "11", &threshold, &use_otsu);
|
||||
return rb_threshold_internal(CV_THRESH_TOZERO_INV, threshold, INT2NUM(0), use_otsu, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* pyr_down(<i>[filter = :gaussian_5x5]</i>) -> cvmat
|
||||
|
@ -4513,70 +4208,6 @@ rb_hough_lines(int argc, VALUE *argv, VALUE self)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hough_lines_standard(<i>rho, theta, threshold</i>) -> cvseq(include CvLine)
|
||||
*
|
||||
* Finds lines in binary image using standard(classical) Hough transform.
|
||||
* * rho - Distance resolution in pixel-related units.
|
||||
* * theta - Angle resolution measured in radians.
|
||||
* * threshold - Threshold parameter. A line is returned by the function if the corresponding accumulator value is greater than threshold.
|
||||
*/
|
||||
VALUE
|
||||
rb_hough_lines_standard(VALUE self, VALUE rho, VALUE theta, VALUE threshold)
|
||||
{
|
||||
SUPPORT_8UC1_ONLY(self);
|
||||
VALUE storage = cCvMemStorage::new_object();
|
||||
CvSeq *seq = cvHoughLines2(CVARR(copy(self)), CVMEMSTORAGE(storage),
|
||||
CV_HOUGH_STANDARD, NUM2DBL(rho), NUM2DBL(theta), NUM2INT(threshold));
|
||||
return cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvLine::rb_class(), storage);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hough_lines_probabilistic(<i>rho, theta, threshold, min_length, max_gap</i>) -> cvseq(include CvTwoPoints)
|
||||
*
|
||||
* Finds lines in binary image using probabilistic Hough transform.
|
||||
* * rho - Distance resolution in pixel-related units.
|
||||
* * theta - Angle resolution measured in radians.
|
||||
* * threshold - Threshold parameter. A line is returned by the function if the corresponding accumulator value is greater than threshold.
|
||||
* * min_length - The minimum line length.
|
||||
* * max_gap - The maximum gap between line segments lieing on the same line to treat them as the single line segment (i.e. to join them).
|
||||
*/
|
||||
VALUE
|
||||
rb_hough_lines_probabilistic(VALUE self, VALUE rho, VALUE theta, VALUE threshold, VALUE p1, VALUE p2)
|
||||
{
|
||||
SUPPORT_8UC1_ONLY(self);
|
||||
VALUE storage = cCvMemStorage::new_object();
|
||||
CvSeq *seq = cvHoughLines2(CVARR(copy(self)), CVMEMSTORAGE(storage),
|
||||
CV_HOUGH_PROBABILISTIC, NUM2DBL(rho), NUM2DBL(theta), NUM2INT(threshold),
|
||||
NUM2DBL(p1), NUM2DBL(p2));
|
||||
return cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvTwoPoints::rb_class(), storage);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hough_lines_multi_scale(<i>rho, theta, threshold, div_rho, div_theta</i>) -> cvseq(include CvLine)
|
||||
*
|
||||
* Finds lines in binary image using multi-scale variant of classical Hough transform.
|
||||
* * rho - Distance resolution in pixel-related units.
|
||||
* * theta - Angle resolution measured in radians.
|
||||
* * threshold - Threshold parameter. A line is returned by the function if the corresponding accumulator value is greater than threshold.
|
||||
* * div_rho = divisor for distance resolution rho.
|
||||
* * div_theta = divisor for angle resolution theta.
|
||||
*/
|
||||
VALUE
|
||||
rb_hough_lines_multi_scale(VALUE self, VALUE rho, VALUE theta, VALUE threshold, VALUE p1, VALUE p2)
|
||||
{
|
||||
SUPPORT_8UC1_ONLY(self);
|
||||
VALUE storage = cCvMemStorage::new_object();
|
||||
CvSeq *seq = cvHoughLines2(CVARR(copy(self)), CVMEMSTORAGE(storage),
|
||||
CV_HOUGH_MULTI_SCALE, NUM2DBL(rho), NUM2DBL(theta), NUM2INT(threshold),
|
||||
NUM2DBL(p1), NUM2DBL(p2));
|
||||
return cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvLine::rb_class(), storage);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hough_circles(<i>method, dp, min_dist, param1, param2, min_radius = 0, max_radius = max(width,height)</i>) -> cvseq(include CvCircle32f)
|
||||
|
@ -4602,26 +4233,6 @@ rb_hough_circles(int argc, VALUE *argv, VALUE self)
|
|||
return cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvCircle32f::rb_class(), storage);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* hough_circles_gradient(<i>dp, min_dist, threshold_canny, threshold_accumulate, min_radius = 0, max_radius = max(width,height)</i>) -> cvseq(include CvCircle32f)
|
||||
*
|
||||
* Finds circles in grayscale image using Hough transform.
|
||||
*/
|
||||
VALUE
|
||||
rb_hough_circles_gradient(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
SUPPORT_8UC1_ONLY(self);
|
||||
VALUE dp, min_dist, threshold_canny, threshold_accumulate, min_radius, max_radius, storage;
|
||||
rb_scan_args(argc, argv, "42", &dp, &min_dist, &threshold_canny, &threshold_accumulate, &min_radius, &max_radius);
|
||||
storage = cCvMemStorage::new_object();
|
||||
CvSeq *seq = cvHoughCircles(CVARR(self), CVMEMSTORAGE(storage),
|
||||
CV_HOUGH_GRADIENT, NUM2DBL(dp), NUM2DBL(min_dist),
|
||||
NUM2DBL(threshold_canny), NUM2DBL(threshold_accumulate),
|
||||
IF_INT(min_radius, 0), IF_INT(max_radius, 0));
|
||||
return cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvCircle32f::rb_class(), storage);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* inpaint(<i>inpaint_method, mask, radius</i>) -> cvmat
|
||||
|
@ -4644,47 +4255,6 @@ rb_inpaint(VALUE self, VALUE inpaint_method, VALUE mask, VALUE radius)
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* inpaint_ns(<i>mask, radius</i>) -> cvmat
|
||||
*
|
||||
* Inpaints the selected region in the image by Navier-Stokes based method.
|
||||
* The radius of circlular neighborhood of each point inpainted that is considered by the algorithm.
|
||||
*/
|
||||
VALUE
|
||||
rb_inpaint_ns(VALUE self, VALUE mask, VALUE radius)
|
||||
{
|
||||
SUPPORT_8U_ONLY(self);
|
||||
SUPPORT_C1C3_ONLY(self);
|
||||
VALUE dest;
|
||||
if (!(rb_obj_is_kind_of(mask, cCvMat::rb_class())) || cvGetElemType(CVARR(mask)) != CV_8UC1)
|
||||
rb_raise(rb_eTypeError, "argument 1 (mask) should be mask image.");
|
||||
dest = new_mat_kind_object(cvGetSize(CVARR(self)), self);
|
||||
cvInpaint(CVARR(self), CVARR(mask), CVARR(dest), NUM2DBL(radius), CV_INPAINT_NS);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* inpaint_telea(<i>mask, radius</i>) -> cvmat
|
||||
*
|
||||
* Inpaints the selected region in the image by The method by Alexandru Telea's method.
|
||||
* The radius of circlular neighborhood of each point inpainted that is considered by the algorithm.
|
||||
*/
|
||||
VALUE
|
||||
rb_inpaint_telea(VALUE self, VALUE mask, VALUE radius)
|
||||
{
|
||||
SUPPORT_8U_ONLY(self);
|
||||
SUPPORT_C1C3_ONLY(self);
|
||||
VALUE dest;
|
||||
if (!(rb_obj_is_kind_of(mask, cCvMat::rb_class())) || cvGetElemType(CVARR(mask)) != CV_8UC1)
|
||||
rb_raise(rb_eTypeError, "argument 1 (mask) should be mask image.");
|
||||
dest = new_mat_kind_object(cvGetSize(CVARR(self)), self);
|
||||
cvInpaint(CVARR(self), CVARR(mask), CVARR(dest), NUM2DBL(radius), CV_INPAINT_TELEA);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* equalize_hist - cvmat
|
||||
|
@ -4786,63 +4356,6 @@ rb_match_shapes(int argc, VALUE *argv, VALUE self)
|
|||
return rb_float_new(cvMatchShapes(CVARR(self), CVARR(object), method_flag));
|
||||
}
|
||||
|
||||
inline VALUE
|
||||
rb_match_shapes_internal(int argc, VALUE *argv, VALUE self, int method)
|
||||
{
|
||||
VALUE object;
|
||||
rb_scan_args(argc, argv, "10", &object);
|
||||
if (!(rb_obj_is_kind_of(object, cCvMat::rb_class()) || rb_obj_is_kind_of(object, cCvContour::rb_class())))
|
||||
rb_raise(rb_eTypeError, "argument 1 (shape) should be %s or %s",
|
||||
rb_class2name(cCvMat::rb_class()), rb_class2name(cCvContour::rb_class()));
|
||||
return rb_float_new(cvMatchShapes(CVARR(self), CVARR(object), method));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* match_shapes_i1(<i>object</i>) -> float
|
||||
*
|
||||
* Compares two shapes(self and object). <i>object</i> should be CvMat or CvContour.
|
||||
*
|
||||
* A - object1, B - object2:
|
||||
* I1(A,B)=sumi=1..7abs(1/mAi - 1/mBi)
|
||||
*/
|
||||
VALUE
|
||||
rb_match_shapes_i1(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
return rb_match_shapes_internal(argc, argv, self, CV_CONTOURS_MATCH_I1);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* match_shapes_i2(<i>object</i>) -> float
|
||||
*
|
||||
* Compares two shapes(self and object). <i>object</i> should be CvMat or CvContour.
|
||||
*
|
||||
* A - object1, B - object2:
|
||||
* I2(A,B)=sumi=1..7abs(mAi - mBi)
|
||||
*/
|
||||
VALUE
|
||||
rb_match_shapes_i2(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
return rb_match_shapes_internal(argc, argv, self, CV_CONTOURS_MATCH_I2);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* match_shapes_i3(<i>object</i>) -> float
|
||||
*
|
||||
* Compares two shapes(self and object). <i>object</i> should be CvMat or CvContour.
|
||||
*
|
||||
* A - object1, B - object2:
|
||||
* I3(A,B)=sumi=1..7abs(mAi - mBi)/abs(mAi)
|
||||
*/
|
||||
VALUE
|
||||
rb_match_shapes_i3(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
return rb_match_shapes_internal(argc, argv, self, CV_CONTOURS_MATCH_I3);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* mean_shift(window, criteria) -> comp
|
||||
|
@ -5084,123 +4597,6 @@ rb_optical_flow_bm(int argc, VALUE *argv, VALUE self)
|
|||
return rb_ary_new3(2, velx, vely);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMat.find_fundamental_mat_7point(<i>points1, points2</i>) -> fundamental_matrix(cvmat) or nil
|
||||
*
|
||||
* Calculates fundamental matrix from corresponding points, use for 7-point algorism. Return fundamental matrix(9x3).
|
||||
* <i>points1</i> and <i>points2</i> should be 2x7 or 3x7 single-channel, or 1x7 multi-channel matrix.
|
||||
*
|
||||
* note: 9x3 fundamental matrix means 3x3 three fundamental matrices.
|
||||
*/
|
||||
VALUE
|
||||
rb_find_fundamental_mat_7point(VALUE klass, VALUE points1, VALUE points2)
|
||||
{
|
||||
CvMat* points1_ptr = CVMAT_WITH_CHECK(points1);
|
||||
VALUE fundamental_matrix = cCvMat::new_object(9, 3, CV_MAT_DEPTH(points1_ptr->type));
|
||||
int num = cvFindFundamentalMat(points1_ptr, CVMAT_WITH_CHECK(points2), CVMAT(fundamental_matrix),
|
||||
CV_FM_7POINT, 0, 0, NULL);
|
||||
return (num == 0) ? Qnil : fundamental_matrix;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMat.find_fundamental_mat_8point(<i>points1, points2</i>) -> fundamental_matrix(cvmat) or nil
|
||||
*
|
||||
* Calculates fundamental matrix from corresponding points, use for 8-point algorism.
|
||||
* <i>points1</i> and <i>points2</i> should be 2x8 or 3x8 single-channel, or 1x8 multi-channel matrix.
|
||||
*
|
||||
*/
|
||||
VALUE
|
||||
rb_find_fundamental_mat_8point(VALUE klass, VALUE points1, VALUE points2)
|
||||
{
|
||||
CvMat* points1_ptr = CVMAT_WITH_CHECK(points1);
|
||||
VALUE fundamental_matrix = cCvMat::new_object(3, 3, CV_MAT_DEPTH(points1_ptr->type));
|
||||
int num = cvFindFundamentalMat(points1_ptr, CVMAT_WITH_CHECK(points2), CVMAT(fundamental_matrix),
|
||||
CV_FM_8POINT, 0, 0, NULL);
|
||||
return (num == 0) ? Qnil : fundamental_matrix;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMat.find_fundamental_mat_ransac(<i>points1, points2[,options = {}]</i>) -> fundamental_matrix(cvmat) or nil
|
||||
*
|
||||
* Calculates fundamental matrix from corresponding points, use for RANSAC algorism.
|
||||
* <i>points1</i> and <i>points2</i> should be 2xN, Nx2, 3xN or Nx3 1-channel, or 1xN or Nx1 multi-channel matrix (N >= 8).
|
||||
* <i>option</i> should be Hash include these keys.
|
||||
* :with_status (true or false)
|
||||
* If set true, return fundamental_matrix and status. [fundamental_matrix, status]
|
||||
* Otherwise return fundamental matrix only(default).
|
||||
* :maximum_distance
|
||||
* The maximum distance from point to epipolar line in pixels, beyond which the point is considered an outlier
|
||||
* and is not used for computing the final fundamental matrix. Usually it is set to 0.5 or 1.0.
|
||||
* :desirable_level
|
||||
* It denotes the desirable level of confidence that the matrix is correct.
|
||||
*
|
||||
* note: <i>option</i>'s default value is CvMat::FIND_FUNDAMENTAL_MAT_OPTION.
|
||||
*/
|
||||
VALUE
|
||||
rb_find_fundamental_mat_ransac(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
VALUE points1, points2, option, fundamental_matrix, status;
|
||||
int num = 0;
|
||||
rb_scan_args(argc, argv, "21", &points1, &points2, &option);
|
||||
option = FIND_FUNDAMENTAL_MAT_OPTION(option);
|
||||
CvMat *points1_ptr = CVMAT_WITH_CHECK(points1);
|
||||
fundamental_matrix = cCvMat::new_object(3, 3, CV_MAT_DEPTH(points1_ptr->type));
|
||||
if (FFM_WITH_STATUS(option)) {
|
||||
int status_len = (points1_ptr->rows > points1_ptr->cols) ? points1_ptr->rows : points1_ptr->cols;
|
||||
status = cCvMat::new_object(1, status_len, CV_8UC1);
|
||||
num = cvFindFundamentalMat(CVMAT(points1), CVMAT_WITH_CHECK(points2), CVMAT(fundamental_matrix), CV_FM_RANSAC,
|
||||
FFM_MAXIMUM_DISTANCE(option), FFM_DESIRABLE_LEVEL(option), CVMAT(status));
|
||||
return num == 0 ? Qnil : rb_ary_new3(2, fundamental_matrix, status);
|
||||
}
|
||||
else {
|
||||
num = cvFindFundamentalMat(points1_ptr, CVMAT_WITH_CHECK(points2), CVMAT(fundamental_matrix), CV_FM_RANSAC,
|
||||
FFM_MAXIMUM_DISTANCE(option), FFM_DESIRABLE_LEVEL(option), NULL);
|
||||
return num == 0 ? Qnil : fundamental_matrix;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMat.find_fundamental_mat_lmeds(<i>points1, points2[,options = {}]</i>) -> fundamental_matrix(cvmat) or nil
|
||||
*
|
||||
* Calculates fundamental matrix from corresponding points, use for LMedS algorism.
|
||||
* <i>points1</i> and <i>points2</i> should be 2xN, Nx2, 3xN or Nx3 1-channel, or 1xN or Nx1 multi-channel matrix (N >= 8).
|
||||
* <i>option</i> should be Hash include these keys.
|
||||
* :with_status (true or false)
|
||||
* If set true, return fundamental_matrix and status. [fundamental_matrix, status]
|
||||
* Otherwise return fundamental matrix only(default).
|
||||
* :desirable_level
|
||||
* It denotes the desirable level of confidence that the matrix is correct.
|
||||
*
|
||||
* note: <i>option</i>'s default value is CvMat::FIND_FUNDAMENTAL_MAT_OPTION.
|
||||
*/
|
||||
VALUE
|
||||
rb_find_fundamental_mat_lmeds(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
VALUE points1, points2, option, fundamental_matrix, status;
|
||||
int num = 0;
|
||||
rb_scan_args(argc, argv, "21", &points1, &points2, &option);
|
||||
option = FIND_FUNDAMENTAL_MAT_OPTION(option);
|
||||
CvMat *points1_ptr = CVMAT_WITH_CHECK(points1);
|
||||
fundamental_matrix = cCvMat::new_object(3, 3, CV_MAT_DEPTH(points1_ptr->type));
|
||||
if(FFM_WITH_STATUS(option)){
|
||||
int status_len = (points1_ptr->rows > points1_ptr->cols) ? points1_ptr->rows : points1_ptr->cols;
|
||||
status = cCvMat::new_object(1, status_len, CV_8UC1);
|
||||
num = cvFindFundamentalMat(points1_ptr, CVMAT_WITH_CHECK(points2), CVMAT(fundamental_matrix), CV_FM_LMEDS,
|
||||
0, FFM_DESIRABLE_LEVEL(option), CVMAT(status));
|
||||
return num == 0 ? Qnil : rb_ary_new3(2, fundamental_matrix, status);
|
||||
}
|
||||
else{
|
||||
num = cvFindFundamentalMat(points1_ptr, CVMAT_WITH_CHECK(points2), CVMAT(fundamental_matrix), CV_FM_LMEDS,
|
||||
0, FFM_DESIRABLE_LEVEL(option), NULL);
|
||||
return num == 0 ? Qnil : fundamental_matrix;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* CvMat.find_fundamental_mat(<i>points1, points2[,options = {}]</i>) -> fundamental_matrix(cvmat) or nil
|
||||
|
|
|
@ -56,8 +56,6 @@ VALUE rb_square_q(VALUE self);
|
|||
VALUE rb_to_CvMat(VALUE self);
|
||||
VALUE rb_to_IplImage(VALUE self);
|
||||
VALUE rb_sub_rect(VALUE self, VALUE args);
|
||||
VALUE rb_slice_width(VALUE self, VALUE num);
|
||||
VALUE rb_slice_height(VALUE self, VALUE num);
|
||||
VALUE rb_row(VALUE self, VALUE args);
|
||||
VALUE rb_col(VALUE self, VALUE args);
|
||||
VALUE rb_each_row(VALUE self);
|
||||
|
@ -84,7 +82,6 @@ VALUE rb_flip(int argc, VALUE *argv, VALUE self);
|
|||
VALUE rb_flip_bang(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_split(VALUE self);
|
||||
VALUE rb_merge(VALUE klass, VALUE args);
|
||||
VALUE rb_mix_channels(int argc, VALUE *argv, VALUE klass);
|
||||
VALUE rb_rand_shuffle(int argc, VALUE *argv, VALUE klass);
|
||||
VALUE rb_rand_shuffle_bang(int argc, VALUE *argv, VALUE klass);
|
||||
|
||||
|
@ -191,28 +188,11 @@ VALUE rb_erode_bang(int argc, VALUE *argv, VALUE self);
|
|||
VALUE rb_dilate(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_dilate_bang(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_morphology(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_morphology_open(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_morphology_close(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_morphology_gradient(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_morphology_tophat(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_morphology_blackhat(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
VALUE rb_smooth(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_smooth_blur_no_scale(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_smooth_blur(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_smooth_gaussian(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_smooth_median(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_smooth_bilateral(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_filter2d(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_copy_make_border_constant(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_copy_make_border_replicate(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_integral(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_threshold(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_threshold_binary(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_threshold_binary_inverse(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_threshold_trunc(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_threshold_to_zero(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_threshold_to_zero_inverse(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_adaptive_threshold(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
VALUE rb_pyr_down(int argc, VALUE *argv, VALUE self);
|
||||
|
@ -229,23 +209,14 @@ VALUE rb_watershed(VALUE self, VALUE markers);
|
|||
VALUE rb_moments(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
VALUE rb_hough_lines(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_hough_lines_standard(VALUE self, VALUE rho, VALUE theta, VALUE threshold);
|
||||
VALUE rb_hough_lines_probabilistic(VALUE self, VALUE rho, VALUE theta, VALUE threshold, VALUE p1, VALUE p2);
|
||||
VALUE rb_hough_lines_multi_scale(VALUE self, VALUE rho, VALUE theta, VALUE threshold, VALUE p1, VALUE p2);
|
||||
VALUE rb_hough_circles(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_hough_circles_gradient(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_dist_transform(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_inpaint(VALUE self, VALUE inpaint_method, VALUE mask, VALUE radius);
|
||||
VALUE rb_inpaint_ns(VALUE self, VALUE mask, VALUE radius);
|
||||
VALUE rb_inpaint_telea(VALUE self, VALUE mask, VALUE radius);
|
||||
|
||||
VALUE rb_equalize_hist(VALUE self);
|
||||
/* Matching*/
|
||||
VALUE rb_match_template(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_shapes(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_shapes_i1(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_shapes_i2(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_shapes_i3(int argc, VALUE *argv, VALUE self);
|
||||
// VALUE rb_calc_emd(int argc, VALUE *argv, VALUE self);
|
||||
/* Object Tracking */
|
||||
VALUE rb_mean_shift(VALUE self, VALUE window, VALUE criteria);
|
||||
|
@ -258,10 +229,6 @@ VALUE rb_optical_flow_bm(int argc, VALUE *argv, VALUE self);
|
|||
VALUE rb_optical_flow_pyr_lk(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
/* Epipolar Geometory */
|
||||
VALUE rb_find_fundamental_mat_7point(VALUE klass, VALUE points1, VALUE points2);
|
||||
VALUE rb_find_fundamental_mat_8point(VALUE klass, VALUE points1, VALUE points2);
|
||||
VALUE rb_find_fundamental_mat_ransac(int argc, VALUE *argv, VALUE klass);
|
||||
VALUE rb_find_fundamental_mat_lmeds(int argc, VALUE *argv, VALUE klass);
|
||||
VALUE rb_find_fundamental_mat(int argc, VALUE *argv, VALUE klass);
|
||||
VALUE rb_compute_correspond_epilines(VALUE klass, VALUE points, VALUE which_image, VALUE fundamental_matrix);
|
||||
|
||||
|
|
|
@ -320,56 +320,6 @@ class TestCvMat < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_slice_width
|
||||
m1 = create_cvmat(10, 40, :cv32f, 1)
|
||||
ml, mr = m1.slice_width(2)
|
||||
[ml, mr].each { |m|
|
||||
assert_equal(10, m.height)
|
||||
assert_equal(20, m.width)
|
||||
assert_equal(:cv32f, m.depth)
|
||||
assert_equal(1, m.channel)
|
||||
}
|
||||
|
||||
ml.height.times { |j|
|
||||
ml.width.times { |i|
|
||||
assert_cvscalar_equal(m1[j, i], ml[j, i])
|
||||
assert_cvscalar_equal(m1[j, (m1.width / 2) + i], mr[j, i])
|
||||
}
|
||||
}
|
||||
|
||||
assert_raise(ArgumentError) {
|
||||
m1.slice_width(0)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
m1.slice_width(DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_slice_height
|
||||
m1 = create_cvmat(10, 20, :cv32f, 1)
|
||||
mt, mb = m1.slice_height(2)
|
||||
[mt, mb].each { |m|
|
||||
assert_equal(5, m.height)
|
||||
assert_equal(20, m.width)
|
||||
assert_equal(:cv32f, m.depth)
|
||||
assert_equal(1, m.channel)
|
||||
}
|
||||
|
||||
mt.height.times { |j|
|
||||
mt.width.times { |i|
|
||||
assert_cvscalar_equal(m1[j, i], mt[j, i])
|
||||
assert_cvscalar_equal(m1[(m1.height / 2) + j, i], mb[j, i])
|
||||
}
|
||||
}
|
||||
|
||||
assert_raise(ArgumentError) {
|
||||
m1.slice_height(0)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
m1.slice_height(DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_row
|
||||
m1 = create_cvmat(10, 20)
|
||||
|
||||
|
@ -909,10 +859,6 @@ class TestCvMat < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_mix_channels
|
||||
flunk('FIXME: CvMat.mix_channels is not implemented yet.')
|
||||
end
|
||||
|
||||
def test_rand_shuffle
|
||||
m0 = create_cvmat(2, 3)
|
||||
m1 = m0.clone
|
||||
|
@ -2247,275 +2193,6 @@ class TestCvMat < OpenCVTestCase
|
|||
CvMat.find_homography(src, dst, :ransac, 5, DUMMY_OBJ)
|
||||
end
|
||||
|
||||
def test_find_fundamental_mat_7point
|
||||
points1 = [[488.362, 169.911],
|
||||
[449.488, 174.44],
|
||||
[408.565, 179.669],
|
||||
[364.512, 184.56],
|
||||
[491.483, 122.366],
|
||||
[451.512, 126.56],
|
||||
[409.502, 130.342]]
|
||||
points2 = [[526.605, 213.332],
|
||||
[470.485, 207.632],
|
||||
[417.5, 201.0],
|
||||
[367.485, 195.632],
|
||||
[530.673, 156.417],
|
||||
[473.749, 151.39],
|
||||
[419.503, 146.656]]
|
||||
|
||||
mat1 = CvMat.new(7, 2, :cv64f, 1)
|
||||
mat2 = CvMat.new(7, 2, :cv64f, 1)
|
||||
|
||||
points1.each_with_index { |pt, i|
|
||||
mat1[i, 0] = CvScalar.new(pt[0])
|
||||
mat1[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
points2.each_with_index { |pt, i|
|
||||
mat2[i, 0] = CvScalar.new(pt[0])
|
||||
mat2[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
|
||||
f_mat = CvMat.find_fundamental_mat_7point(mat1, mat2)
|
||||
|
||||
assert_equal(9, f_mat.rows)
|
||||
assert_equal(3, f_mat.cols)
|
||||
|
||||
expected = [0.000009, 0.000029, -0.010343,
|
||||
-0.000033, 0.000000, 0.014590,
|
||||
0.004415, -0.013420, 1.000000,
|
||||
0.000000, 0.000001, -0.000223,
|
||||
-0.000001, 0.000036, -0.005309,
|
||||
-0.000097, -0.006463, 1.000000,
|
||||
0.000002, 0.000005, -0.001621,
|
||||
-0.000005, 0.000031, -0.002559,
|
||||
0.000527, -0.007424, 1.000000]
|
||||
expected.each_with_index { |val, i|
|
||||
assert_in_delta(val, f_mat[i][0], 1.0e-5)
|
||||
}
|
||||
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_7point(DUMMY_OBJ, mat2)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_7point(mat1, DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_find_fundamental_mat_8point
|
||||
points1 = [[488.362, 169.911],
|
||||
[449.488, 174.44],
|
||||
[408.565, 179.669],
|
||||
[364.512, 184.56],
|
||||
[491.483, 122.366],
|
||||
[451.512, 126.56],
|
||||
[409.502, 130.342],
|
||||
[365.5, 134]]
|
||||
points2 = [[526.605, 213.332],
|
||||
[470.485, 207.632],
|
||||
[417.5, 201.0],
|
||||
[367.485, 195.632],
|
||||
[530.673, 156.417],
|
||||
[473.749, 151.39],
|
||||
[419.503, 146.656],
|
||||
[368.669, 142.565]]
|
||||
|
||||
mat1 = CvMat.new(8, 2, :cv64f, 1)
|
||||
mat2 = CvMat.new(8, 2, :cv64f, 1)
|
||||
|
||||
points1.each_with_index { |pt, i|
|
||||
mat1[i, 0] = CvScalar.new(pt[0])
|
||||
mat1[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
points2.each_with_index { |pt, i|
|
||||
mat2[i, 0] = CvScalar.new(pt[0])
|
||||
mat2[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
|
||||
f_mat = CvMat.find_fundamental_mat_8point(mat1, mat2)
|
||||
|
||||
assert_equal(3, f_mat.rows)
|
||||
assert_equal(3, f_mat.cols)
|
||||
|
||||
expected = [0.000001, 0.000004, -0.001127,
|
||||
-0.000005, 0.000038, -0.003778,
|
||||
0.000819, -0.008325, 1.000000]
|
||||
expected.each_with_index { |val, i|
|
||||
assert_in_delta(val, f_mat[i][0], 1.0e-5)
|
||||
}
|
||||
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_8point(DUMMY_OBJ, mat2)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_8point(mat1, DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_find_fundamental_mat_ransac
|
||||
points1 = [[488.362, 169.911],
|
||||
[449.488, 174.44],
|
||||
[408.565, 179.669],
|
||||
[364.512, 184.56],
|
||||
[491.483, 122.366],
|
||||
[451.512, 126.56],
|
||||
[409.502, 130.342],
|
||||
[365.5, 134.0],
|
||||
[494.335, 74.544],
|
||||
[453.5, 76.5],
|
||||
[411.646, 79.5901],
|
||||
[366.498, 81.6577],
|
||||
[453.5, 76.5],
|
||||
[411.646, 79.5901],
|
||||
[366.498, 81.6577]]
|
||||
points2 = [[526.605, 213.332],
|
||||
[470.485, 207.632],
|
||||
[417.5, 201.0],
|
||||
[367.485, 195.632],
|
||||
[530.673, 156.417],
|
||||
[473.749, 151.39],
|
||||
[419.503, 146.656],
|
||||
[368.669, 142.565],
|
||||
[534.632, 97.5152],
|
||||
[475.84, 94.6777],
|
||||
[421.16, 90.3223],
|
||||
[368.5, 87.5],
|
||||
[475.84, 94.6777],
|
||||
[421.16, 90.3223],
|
||||
[368.5, 87.5]]
|
||||
|
||||
mat1 = CvMat.new(points1.size, 2, :cv64f, 1)
|
||||
mat2 = CvMat.new(points2.size, 2, :cv64f, 1)
|
||||
|
||||
points1.each_with_index { |pt, i|
|
||||
mat1[i, 0] = CvScalar.new(pt[0])
|
||||
mat1[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
points2.each_with_index { |pt, i|
|
||||
mat2[i, 0] = CvScalar.new(pt[0])
|
||||
mat2[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
|
||||
# default
|
||||
[CvMat.find_fundamental_mat_ransac(mat1, mat2, :with_status => false,
|
||||
:maximum_distance => 1.0, :desirable_level => 0.99),
|
||||
CvMat.find_fundamental_mat_ransac(mat1, mat2)].each { |f_mat|
|
||||
assert_equal(3, f_mat.rows)
|
||||
assert_equal(3, f_mat.cols)
|
||||
expected = [0.000010, 0.000039, -0.011141,
|
||||
-0.000045, -0.000001, 0.019631,
|
||||
0.004873, -0.017604, 1.000000]
|
||||
expected.each_with_index { |val, i|
|
||||
assert_in_delta(val, f_mat[i][0], 1.0e-5)
|
||||
}
|
||||
}
|
||||
|
||||
# with options
|
||||
f_mat, status = CvMat.find_fundamental_mat_ransac(mat1, mat2, :with_status => true,
|
||||
:maximum_distance => 2.0, :desirable_level => 0.8)
|
||||
assert_equal(3, f_mat.rows)
|
||||
assert_equal(3, f_mat.cols)
|
||||
assert_equal(1, status.rows)
|
||||
assert_equal(points1.size, status.cols)
|
||||
|
||||
expected_f_mat = [0.000009, 0.000030, -0.010692,
|
||||
-0.000039, 0.000000, 0.020567,
|
||||
0.004779, -0.018064, 1.000000]
|
||||
expected_f_mat.each_with_index { |val, i|
|
||||
assert_in_delta(val, f_mat[i][0], 1.0e-5)
|
||||
}
|
||||
expected_status = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
||||
expected_status.each_with_index { |val, i|
|
||||
assert_in_delta(val, status[i][0], 1.0e-5)
|
||||
}
|
||||
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_ransac(DUMMY_OBJ, mat2)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_ransac(mat1, DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_find_fundamental_mat_lmeds
|
||||
points1 = [[488.362, 169.911],
|
||||
[449.488, 174.44],
|
||||
[408.565, 179.669],
|
||||
[364.512, 184.56],
|
||||
[491.483, 122.366],
|
||||
[451.512, 126.56],
|
||||
[409.502, 130.342],
|
||||
[365.5, 134.0],
|
||||
[494.335, 74.544],
|
||||
[453.5, 76.5],
|
||||
[411.646, 79.5901],
|
||||
[366.498, 81.6577]]
|
||||
points2 = [[526.605, 213.332],
|
||||
[470.485, 207.632],
|
||||
[417.5, 201.0],
|
||||
[367.485, 195.632],
|
||||
[530.673, 156.417],
|
||||
[473.749, 151.39],
|
||||
[419.503, 146.656],
|
||||
[368.669, 142.565],
|
||||
[534.632, 97.5152],
|
||||
[475.84, 94.6777],
|
||||
[421.16, 90.3223],
|
||||
[368.5, 87.5]]
|
||||
|
||||
mat1 = CvMat.new(points1.size, 2, :cv64f, 1)
|
||||
mat2 = CvMat.new(points2.size, 2, :cv64f, 1)
|
||||
|
||||
points1.each_with_index { |pt, i|
|
||||
mat1[i, 0] = CvScalar.new(pt[0])
|
||||
mat1[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
points2.each_with_index { |pt, i|
|
||||
mat2[i, 0] = CvScalar.new(pt[0])
|
||||
mat2[i, 1] = CvScalar.new(pt[1])
|
||||
}
|
||||
|
||||
# default
|
||||
[CvMat.find_fundamental_mat_lmeds(mat1, mat2, :with_status => false,
|
||||
:maximum_distance => 1.0, :desirable_level => 0.99),
|
||||
CvMat.find_fundamental_mat_lmeds(mat1, mat2)].each { |f_mat|
|
||||
assert_equal(3, f_mat.rows)
|
||||
assert_equal(3, f_mat.cols)
|
||||
expected = [0.000032, 0.000882, -0.012426,
|
||||
-0.000854, 0.000091, 0.210136,
|
||||
0.001034, -0.2405784, 1.000000]
|
||||
expected.each_with_index { |val, i|
|
||||
assert_in_delta(val, f_mat[i][0], 1.0e-5)
|
||||
}
|
||||
}
|
||||
|
||||
# with options
|
||||
f_mat, status = CvMat.find_fundamental_mat_lmeds(mat1, mat2, :with_status => true,
|
||||
:desirable_level => 0.8)
|
||||
assert_equal(3, f_mat.rows)
|
||||
assert_equal(3, f_mat.cols)
|
||||
assert_equal(1, status.rows)
|
||||
assert_equal(points1.size, status.cols)
|
||||
|
||||
expected_f_mat = [0.000009, 0.000101, -0.009396,
|
||||
-0.000113, -0.000002, 0.049380,
|
||||
0.003335, -0.045132, 1.000000]
|
||||
expected_f_mat.each_with_index { |val, i|
|
||||
assert_in_delta(val, f_mat[i][0], 1.0e-5)
|
||||
}
|
||||
expected_status = [1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1 ]
|
||||
|
||||
expected_status.each_with_index { |val, i|
|
||||
assert_in_delta(val, status[i][0], 1.0e-5)
|
||||
}
|
||||
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_lmeds(DUMMY_OBJ, mat2)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
CvMat.find_fundamental_mat_lmeds(mat1, DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_find_fundamental_mat
|
||||
points1 = [[488.362, 169.911],
|
||||
[449.488, 174.44],
|
||||
|
|
|
@ -623,109 +623,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_morphology_open
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if i >= 8 and i < 56 and j >= 8 and j < 56 and (i + j) % 15 != 0
|
||||
CvScalar.new(255)
|
||||
else
|
||||
CvScalar.new(0)
|
||||
end
|
||||
}
|
||||
|
||||
mat1 = mat0.morphology_open
|
||||
mat2 = mat0.morphology_open(nil, 2)
|
||||
kernel = IplConvKernel.new(5, 5, 2, 2, :cross)
|
||||
mat3 = mat0.morphology_open(kernel)
|
||||
|
||||
assert_equal('165c36ad069db33735f0d4c2823f43b7', hash_img(mat1))
|
||||
assert_equal('e5af47b2827ed20450222321c1678ed3', hash_img(mat2))
|
||||
assert_equal('63ccb07cb93efb1563657f51e3d89252', hash_img(mat3))
|
||||
end
|
||||
|
||||
def test_morphology_close
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if i >= 8 and i < 56 and j >= 8 and j < 56 and (i + j) % 15 != 0
|
||||
CvScalar.new(255)
|
||||
else
|
||||
CvScalar.new(0)
|
||||
end
|
||||
}
|
||||
|
||||
mat1 = mat0.morphology_close
|
||||
mat2 = mat0.morphology_close(nil, 2)
|
||||
kernel = IplConvKernel.new(5, 5, 2, 2, :cross)
|
||||
mat3 = mat0.morphology_close(kernel)
|
||||
mat4 = mat0.morphology(CV_MOP_CLOSE, kernel)
|
||||
|
||||
assert_equal('752914aae1cff07a2b3ce528b6ac3332', hash_img(mat1))
|
||||
assert_equal('0908b8f98999a198e8a1fbc743de52e5', hash_img(mat2))
|
||||
assert_equal('831c513d6ed86bce3f15c697de4a72f8', hash_img(mat3))
|
||||
assert_equal('831c513d6ed86bce3f15c697de4a72f8', hash_img(mat4))
|
||||
end
|
||||
|
||||
def test_morphology_gradient
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if i >= 8 and i < 56 and j >= 8 and j < 56 and (i + j) % 15 != 0
|
||||
CvScalar.new(255)
|
||||
else
|
||||
CvScalar.new(0)
|
||||
end
|
||||
}
|
||||
|
||||
mat1 = mat0.morphology_gradient
|
||||
mat2 = mat0.morphology_gradient(nil, 2)
|
||||
kernel = IplConvKernel.new(5, 5, 2, 2, :cross)
|
||||
mat3 = mat0.morphology_gradient(kernel)
|
||||
mat4 = mat0.morphology(CV_MOP_GRADIENT, kernel)
|
||||
|
||||
assert_equal('e15d131ae29a58237f8d9a89669c3a47', hash_img(mat1))
|
||||
assert_equal('31d158672f699f961c59908e0bd72d5c', hash_img(mat2))
|
||||
assert_equal('1e8007c211d6f464cf8584e8e83b3c35', hash_img(mat3))
|
||||
assert_equal('1e8007c211d6f464cf8584e8e83b3c35', hash_img(mat4))
|
||||
end
|
||||
|
||||
def test_morphology_tophat
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if i >= 8 and i < 56 and j >= 8 and j < 56 and (i + j) % 15 != 0
|
||||
CvScalar.new(255)
|
||||
else
|
||||
CvScalar.new(0)
|
||||
end
|
||||
}
|
||||
|
||||
mat1 = mat0.morphology_tophat
|
||||
mat2 = mat0.morphology_tophat(nil, 2)
|
||||
kernel = IplConvKernel.new(5, 5, 2, 2, :cross)
|
||||
mat3 = mat0.morphology_tophat(kernel)
|
||||
mat4 = mat0.morphology(CV_MOP_TOPHAT, kernel)
|
||||
|
||||
assert_equal('26f89a4f449ec8328499960acbfd44f2', hash_img(mat1))
|
||||
assert_equal('102833c2e96eaa706eea5854d2aeaf5a', hash_img(mat2))
|
||||
assert_equal('1760c5b63a52df37069164fe3e901aa4', hash_img(mat3))
|
||||
assert_equal('1760c5b63a52df37069164fe3e901aa4', hash_img(mat4))
|
||||
end
|
||||
|
||||
def test_morphology_blackhat
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if i >= 8 and i < 56 and j >= 8 and j < 56 and (i + j) % 15 != 0
|
||||
CvScalar.new(255)
|
||||
else
|
||||
CvScalar.new(0)
|
||||
end
|
||||
}
|
||||
|
||||
mat1 = mat0.morphology_blackhat
|
||||
mat2 = mat0.morphology_blackhat(nil, 2)
|
||||
kernel = IplConvKernel.new(5, 5, 2, 2, :cross)
|
||||
mat3 = mat0.morphology_blackhat(kernel)
|
||||
mat4 = mat0.morphology(CV_MOP_BLACKHAT, kernel)
|
||||
|
||||
assert_equal('3773d2802aad82c91ea8e14a324e5fc3', hash_img(mat1))
|
||||
assert_equal('3fc6bc283fa952e1fd566944d94b3e9a', hash_img(mat2))
|
||||
assert_equal('18b1d51637b912a38133341ee006c6ff', hash_img(mat3))
|
||||
assert_equal('18b1d51637b912a38133341ee006c6ff', hash_img(mat4))
|
||||
end
|
||||
|
||||
def test_smooth
|
||||
mat0 = CvMat.load(FILENAME_LENA32x32, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
|
@ -879,123 +776,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
flunk('FIXME: Cases of CvMat#smooth(CV_BILATERAL) are not tested yet.')
|
||||
end
|
||||
|
||||
def test_smooth_blur_no_scale
|
||||
mat0 = CvMat.load(FILENAME_LENA32x32, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
mat1 = mat0.smooth_blur_no_scale
|
||||
mat2 = mat0.smooth_blur_no_scale(3, 3)
|
||||
mat3 = mat0.smooth_blur_no_scale(7, 7)
|
||||
mat4 = CvMat.new(32, 32, :cv32f, 1).smooth_blur_no_scale
|
||||
|
||||
[mat1, mat2, mat3].each { |m|
|
||||
assert_equal(1, m.channel)
|
||||
assert_equal(:cv16u, m.depth)
|
||||
}
|
||||
assert_equal(1, mat4.channel)
|
||||
assert_equal(:cv32f, mat4.depth)
|
||||
|
||||
assert_equal('3c9074c87b65117798f48e41a17b2f30', hash_img(mat1))
|
||||
assert_equal('3c9074c87b65117798f48e41a17b2f30', hash_img(mat2))
|
||||
assert_equal('9c549aa406a425a65b036c2f9a2689e0', hash_img(mat3))
|
||||
end
|
||||
|
||||
def test_smooth_blur
|
||||
mat0 = CvMat.load(FILENAME_LENA32x32, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
mat1 = mat0.smooth_blur
|
||||
mat2 = mat0.smooth_blur(3, 3)
|
||||
mat3 = mat0.smooth_blur(7, 7)
|
||||
mat4 = CvMat.new(32, 32, :cv16u, 1).smooth_blur
|
||||
mat5 = CvMat.new(32, 32, :cv32f, 1).smooth_blur
|
||||
mat6 = CvMat.new(32, 32, :cv8u, 3).smooth_blur
|
||||
|
||||
[mat1, mat2, mat3].each { |m|
|
||||
assert_equal(1, m.channel)
|
||||
assert_equal(:cv8u, m.depth)
|
||||
}
|
||||
assert_equal(1, mat4.channel)
|
||||
assert_equal(:cv16u, mat4.depth)
|
||||
assert_equal(1, mat5.channel)
|
||||
assert_equal(:cv32f, mat5.depth)
|
||||
assert_equal(3, mat6.channel)
|
||||
assert_equal(:cv8u, mat6.depth)
|
||||
|
||||
assert_equal('f2473b5b964ae8950f6a7fa5cde4c67a', hash_img(mat1))
|
||||
assert_equal('f2473b5b964ae8950f6a7fa5cde4c67a', hash_img(mat2))
|
||||
assert_equal('d7bb344fc0f6ec0da4b9754d319e4e4a', hash_img(mat3))
|
||||
end
|
||||
|
||||
def test_smooth_gaussian
|
||||
mat0 = CvMat.load(FILENAME_LENA32x32, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
mat1 = mat0.smooth_gaussian
|
||||
mat2 = mat0.smooth_gaussian(3, 3)
|
||||
mat3 = mat0.smooth_gaussian(3, 3, 3)
|
||||
mat4 = mat0.smooth_gaussian(3, 3, 3, 3)
|
||||
mat5 = mat0.smooth_gaussian(7, 7, 5, 3)
|
||||
|
||||
mat6 = CvMat.new(32, 32, :cv16u, 1).smooth_gaussian
|
||||
mat7 = CvMat.new(32, 32, :cv32f, 1).smooth_gaussian
|
||||
mat8 = CvMat.new(32, 32, :cv8u, 3).smooth_gaussian
|
||||
|
||||
[mat1, mat2, mat3, mat4, mat5].each { |m|
|
||||
assert_equal(1, m.channel)
|
||||
assert_equal(:cv8u, m.depth)
|
||||
}
|
||||
assert_equal(1, mat6.channel)
|
||||
assert_equal(:cv16u, mat6.depth)
|
||||
assert_equal(1, mat7.channel)
|
||||
assert_equal(:cv32f, mat7.depth)
|
||||
assert_equal(3, mat8.channel)
|
||||
assert_equal(:cv8u, mat8.depth)
|
||||
|
||||
assert_equal('580c88f3e0e317a5770be3f28f31eda2', hash_img(mat1))
|
||||
assert_equal('580c88f3e0e317a5770be3f28f31eda2', hash_img(mat2))
|
||||
assert_equal('a1ffaa14522719e37d75eec18ff8b309', hash_img(mat3))
|
||||
assert_equal('a1ffaa14522719e37d75eec18ff8b309', hash_img(mat4))
|
||||
assert_equal('f7f8b4eff3240ffc8f259ce975936d92', hash_img(mat5))
|
||||
end
|
||||
|
||||
def test_smooth_median
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if (i + j) % 15 != 0
|
||||
CvScalar.new(255)
|
||||
else
|
||||
CvScalar.new(0)
|
||||
end
|
||||
}
|
||||
(-1..1).each { |dy|
|
||||
(-1..1).each { |dx|
|
||||
mat0[32 + dy, 32 + dx] = CvScalar.new(0)
|
||||
}
|
||||
}
|
||||
|
||||
mat1 = mat0.smooth_median
|
||||
mat2 = mat0.smooth_median(3)
|
||||
mat3 = mat0.smooth_median(7)
|
||||
mat4 = CvMat.new(64, 64, :cv8u, 3).smooth_median
|
||||
|
||||
assert_equal('7343a41c542e034db356636c06134961', hash_img(mat1))
|
||||
assert_equal('7343a41c542e034db356636c06134961', hash_img(mat2))
|
||||
assert_equal('6ae59e64850377ee5470c854761551ea', hash_img(mat3))
|
||||
end
|
||||
|
||||
def test_smooth_bilateral
|
||||
flunk('FIXME: CvMat#smooth_bilateral is not tested yet.')
|
||||
mat0 = create_cvmat(64, 64, :cv8u, 1) { |j, i, c|
|
||||
if i > 32
|
||||
(i + j) % 15 != 0 ? CvScalar.new(32) : CvScalar.new(224)
|
||||
else
|
||||
(i + j) % 15 != 0 ? CvScalar.new(224) : CvScalar.new(32)
|
||||
end
|
||||
}
|
||||
|
||||
mat1 = mat0.smooth_bilateral
|
||||
mat2 = mat0.smooth_bilateral(3, 3)
|
||||
mat3 = mat0.smooth_bilateral(7, 7)
|
||||
mat4 = CvMat.new(64, 64, :cv8u, 3).smooth_bilateral
|
||||
end
|
||||
|
||||
def test_filter2d
|
||||
mat0 = CvMat.load(FILENAME_LENA256x256, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
kernel = CvMat.new(3, 3, :cv32f, 1)
|
||||
|
@ -1022,37 +802,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_copy_make_border_constant
|
||||
mat0 = create_cvmat(32, 32, :cv8u, 1) { CvScalar.new(128) }
|
||||
mat1 = mat0.copy_make_border_constant(CvSize.new(64, 48), CvPoint.new(16, 8), 255)
|
||||
|
||||
assert_equal('5e231f8ca051b8f93e4aaa42d193d095', hash_img(mat1))
|
||||
|
||||
assert_raise(TypeError) {
|
||||
mat0.copy_make_border_constant(DUMMY_OBJ, CvPoint.new(16, 8))
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
mat0.copy_make_border_constant(CvSize.new(64, 48), DUMMY_OBJ)
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
mat0.copy_make_border_constant(CvSize.new(64, 48), CvPoint.new(16, 8), DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_copy_make_border_replicate
|
||||
mat0 = CvMat.load(FILENAME_LENA256x256, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
mat1 = mat0.copy_make_border_replicate(CvSize.new(300, 300), CvPoint.new(30, 30))
|
||||
|
||||
assert_equal('ecc7e69d110f9934fa31f8ec85b30275', hash_img(mat1))
|
||||
|
||||
assert_raise(TypeError) {
|
||||
mat0.copy_make_border_replicate(DUMMY_OBJ, CvPoint.new(16, 8))
|
||||
}
|
||||
assert_raise(TypeError) {
|
||||
mat0.copy_make_border_replicate(CvSize.new(64, 48), DUMMY_OBJ)
|
||||
}
|
||||
end
|
||||
|
||||
def test_integral
|
||||
mat0 = create_cvmat(3, 3, :cv8u, 1) { |j, i, n| CvScalar.new(n) }
|
||||
|
||||
|
@ -1195,91 +944,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
mat0.threshold(1, 2, :binary, DUMMY_OBJ)
|
||||
end
|
||||
|
||||
def test_threshold_binary
|
||||
mat0 = create_cvmat(3, 3, :cv8u, 1) { |j, i, n| CvScalar.new(n) }
|
||||
mat1 = mat0.threshold_binary(4, 7)
|
||||
expected = [0, 0, 0,
|
||||
0, 0, 7,
|
||||
7, 7, 7]
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
|
||||
mat2, thresh2 = mat0.threshold_binary(5, 7, true)
|
||||
assert_in_delta(4, thresh2, 0.001)
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
end
|
||||
|
||||
def test_threshold_binary_inverse
|
||||
mat0 = create_cvmat(3, 3, :cv8u, 1) { |j, i, n| CvScalar.new(n) }
|
||||
mat1 = mat0.threshold_binary_inverse(4, 7)
|
||||
expected = [7, 7, 7,
|
||||
7, 7, 0,
|
||||
0, 0, 0]
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
|
||||
mat2, thresh2 = mat0.threshold_binary_inverse(5, 7, true)
|
||||
assert_in_delta(4, thresh2, 0.001)
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
end
|
||||
|
||||
def test_threshold_trunc
|
||||
mat0 = create_cvmat(3, 3, :cv8u, 1) { |j, i, n| CvScalar.new(n) }
|
||||
mat1 = mat0.threshold_trunc(4)
|
||||
expected = [0, 1, 2,
|
||||
3, 4, 4,
|
||||
4, 4, 4]
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
|
||||
mat2, thresh2 = mat0.threshold_trunc(5, true)
|
||||
assert_in_delta(4, thresh2, 0.001)
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
end
|
||||
|
||||
def test_threshold_to_zero
|
||||
mat0 = create_cvmat(3, 3, :cv8u, 1) { |j, i, n| CvScalar.new(n) }
|
||||
mat1 = mat0.threshold_to_zero(4)
|
||||
expected = [0, 0, 0,
|
||||
0, 0, 5,
|
||||
6, 7, 8]
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
|
||||
mat2, thresh2 = mat0.threshold_to_zero(5, true)
|
||||
assert_in_delta(4, thresh2, 0.001)
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
end
|
||||
|
||||
def test_threshold_to_zero_inverse
|
||||
mat0 = create_cvmat(3, 3, :cv8u, 1) { |j, i, n| CvScalar.new(n) }
|
||||
mat1 = mat0.threshold_to_zero_inverse(4)
|
||||
expected = [0, 1, 2,
|
||||
3, 4, 0,
|
||||
0, 0, 0]
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
|
||||
mat2, thresh2 = mat0.threshold_to_zero_inverse(5, true)
|
||||
assert_in_delta(4, thresh2, 0.001)
|
||||
expected.each_with_index { |x, i|
|
||||
assert_equal(x, mat1[i][0])
|
||||
}
|
||||
end
|
||||
|
||||
def test_pyr_down
|
||||
mat0 = CvMat.load(FILENAME_LENA256x256, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
mat1 = mat0.pyr_down
|
||||
|
@ -1594,77 +1258,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_hough_lines_standard
|
||||
mat0 = CvMat.load(FILENAME_LINES, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
# make a binary image
|
||||
mat = CvMat.new(mat0.rows, mat0.cols, :cv8u, 1)
|
||||
(mat0.rows * mat0.cols).times { |i|
|
||||
mat[i] = (mat0[i][0] <= 100) ? CvScalar.new(0) : CvScalar.new(255);
|
||||
}
|
||||
seq = mat.hough_lines_standard(1, Math::PI / 180, 65)
|
||||
assert_equal(4, seq.size)
|
||||
|
||||
# Uncomment the following lines to show the result
|
||||
# seq.each { |line|
|
||||
# cos = Math::cos(line.theta)
|
||||
# sin = Math::sin(line.theta)
|
||||
# x0 = line.rho * cos
|
||||
# y0 = line.rho * sin
|
||||
# pt1 = CvPoint.new
|
||||
# pt2 = CvPoint.new
|
||||
# pt1.x = x0 + mat.width * 10 * (-sin)
|
||||
# pt1.y = y0 + mat.height * 10 * (cos)
|
||||
# pt2.x = x0 - mat.width * 10 * (-sin)
|
||||
# pt2.y = y0 - mat.height * 10 * (cos)
|
||||
# mat0.line!(pt1, pt2, :color => CvColor::Red, :thickness => 1, :line_type => :aa)
|
||||
# }
|
||||
# snap mat0
|
||||
end
|
||||
|
||||
def test_hough_lines_probabilistic
|
||||
mat0 = CvMat.load(FILENAME_LINES, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
# make a binary image
|
||||
mat = CvMat.new(mat0.rows, mat0.cols, :cv8u, 1)
|
||||
(mat0.rows * mat0.cols).times { |i|
|
||||
mat[i] = (mat0[i][0] <= 100) ? CvScalar.new(0) : CvScalar.new(255);
|
||||
}
|
||||
seq = mat.hough_lines_probabilistic(1, Math::PI / 180, 40, 30, 10)
|
||||
assert_equal(4, seq.size)
|
||||
|
||||
# Uncomment the following lines to show the result
|
||||
# seq.each { |points|
|
||||
# mat0.line!(*points, :color => CvColor::Red, :thickness => 1, :line_type => :aa)
|
||||
# }
|
||||
# snap mat0
|
||||
end
|
||||
|
||||
def test_hough_lines_multi_scale
|
||||
mat0 = CvMat.load(FILENAME_LINES, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
# make a binary image
|
||||
mat = CvMat.new(mat0.rows, mat0.cols, :cv8u, 1)
|
||||
(mat0.rows * mat0.cols).times { |i|
|
||||
mat[i] = (mat0[i][0] <= 100) ? CvScalar.new(0) : CvScalar.new(255);
|
||||
}
|
||||
seq = mat.hough_lines_multi_scale(1, Math::PI / 180, 40, 2, 3)
|
||||
assert_equal(9, seq.size)
|
||||
|
||||
# Uncomment the following lines to show the result
|
||||
# seq.each { |line|
|
||||
# cos = Math::cos(line.theta)
|
||||
# sin = Math::sin(line.theta)
|
||||
# x0 = line.rho * cos
|
||||
# y0 = line.rho * sin
|
||||
# pt1 = CvPoint.new
|
||||
# pt2 = CvPoint.new
|
||||
# pt1.x = x0 + mat.width * 10 * (-sin)
|
||||
# pt1.y = y0 + mat.height * 10 * (cos)
|
||||
# pt2.x = x0 - mat.width * 10 * (-sin)
|
||||
# pt2.y = y0 - mat.height * 10 * (cos)
|
||||
# mat0.line!(pt1, pt2, :color => CvColor::Red, :thickness => 1, :line_type => :aa)
|
||||
# }
|
||||
# snap mat0
|
||||
end
|
||||
|
||||
def test_hough_circles
|
||||
mat0 = CvMat.load(FILENAME_LINES, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
# make a binary image
|
||||
|
@ -1713,27 +1306,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_hough_circles_gradient
|
||||
mat0 = CvMat.load(FILENAME_LINES, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
# make a binary image
|
||||
mat = CvMat.new(mat0.rows, mat0.cols, :cv8u, 1)
|
||||
(mat0.rows * mat0.cols).times { |i|
|
||||
mat[i] = (mat0[i][0] <= 100) ? CvScalar.new(0) : CvScalar.new(255);
|
||||
}
|
||||
|
||||
[mat.hough_circles_gradient(1.5, 40, 100, 50, 10, 50),
|
||||
mat.hough_circles_gradient(1.5, 40, 100, 50)].each { |seq|
|
||||
assert_equal(2, seq.size)
|
||||
}
|
||||
|
||||
# Uncomment the following lines to show the result
|
||||
# seq = mat.hough_circles_gradient(1.5, 40, 100, 50, 10, 50)
|
||||
# seq.each { |circle|
|
||||
# mat0.circle!(circle.center, circle.radius, :color => CvColor::Red, :thickness => 2)
|
||||
# }
|
||||
# snap mat0
|
||||
end
|
||||
|
||||
def test_inpaint
|
||||
mat = CvMat.load(FILENAME_LENA_INPAINT, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
mask = CvMat.load(FILENAME_INPAINT_MASK, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
@ -1766,24 +1338,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_inpaint_ns
|
||||
mat = CvMat.load(FILENAME_LENA_INPAINT, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
mask = CvMat.load(FILENAME_INPAINT_MASK, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
result = mat.inpaint_ns(mask, 10)
|
||||
assert_equal('d3df4dda8642c83512fb417ffa5e1457', hash_img(result))
|
||||
# Uncomment the following lines to show the result
|
||||
# snap mat, result
|
||||
end
|
||||
|
||||
def test_inpaint_telea
|
||||
mat = CvMat.load(FILENAME_LENA_INPAINT, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||
mask = CvMat.load(FILENAME_INPAINT_MASK, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
result = mat.inpaint_telea(mask, 10)
|
||||
assert_equal('d45bec22d03067578703f2ec68567167', hash_img(result))
|
||||
# Uncomment the following lines to show the result
|
||||
# snap mat, result
|
||||
end
|
||||
|
||||
def test_equalize_hist
|
||||
mat = CvMat.load(FILENAME_LENA256x256, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
result = mat.equalize_hist
|
||||
|
@ -1872,33 +1426,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_match_shapes_i1
|
||||
mat_cv = CvMat.load(FILENAME_STR_CV, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
mat_ov = CvMat.load(FILENAME_STR_OV, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
mat_cv_rotated = CvMat.load(FILENAME_STR_CV_ROTATED, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
assert_in_delta(0, mat_cv.match_shapes_i1(mat_cv_rotated), 0.00001)
|
||||
assert_in_delta(0.0010649, mat_cv.match_shapes_i1(mat_ov), 0.00001)
|
||||
end
|
||||
|
||||
def test_match_shapes_i2
|
||||
mat_cv = CvMat.load(FILENAME_STR_CV, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
mat_ov = CvMat.load(FILENAME_STR_OV, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
mat_cv_rotated = CvMat.load(FILENAME_STR_CV_ROTATED, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
assert_in_delta(0, mat_cv.match_shapes_i2(mat_cv_rotated), 0.00001)
|
||||
assert_in_delta(0.0104650, mat_cv.match_shapes_i2(mat_ov), 0.00001)
|
||||
end
|
||||
|
||||
def test_match_shapes_i3
|
||||
mat_cv = CvMat.load(FILENAME_STR_CV, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
mat_ov = CvMat.load(FILENAME_STR_OV, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
mat_cv_rotated = CvMat.load(FILENAME_STR_CV_ROTATED, CV_LOAD_IMAGE_GRAYSCALE)
|
||||
|
||||
assert_in_delta(0, mat_cv.match_shapes_i3(mat_cv_rotated), 0.00001)
|
||||
assert_in_delta(0.0033327, mat_cv.match_shapes_i3(mat_ov), 0.00001)
|
||||
end
|
||||
|
||||
def test_mean_shift
|
||||
flunk('FIXME: CvMat#mean_shift is not tested yet.')
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue