mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
refactored some functions to get options
This commit is contained in:
parent
1d1244de0c
commit
cd3cd06829
10 changed files with 98 additions and 63 deletions
|
@ -17,11 +17,11 @@
|
||||||
__NAMESPACE_BEGIN_OPENCV
|
__NAMESPACE_BEGIN_OPENCV
|
||||||
__NAMESPACE_BEGIN_CVCHAIN
|
__NAMESPACE_BEGIN_CVCHAIN
|
||||||
|
|
||||||
#define APPROX_CHAIN_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("APPROX_CHAIN_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("APPROX_CHAIN_OPTION")), rb_intern("merge"), 1, op)
|
#define APPROX_CHAIN_OPTION(op) rb_get_option_table(rb_klass, "APPROX_CHAIN_OPTION", op)
|
||||||
#define APPROX_CHAIN_METHOD(op) CVMETHOD("APPROX_CHAIN_METHOD", rb_hash_aref(op, ID2SYM(rb_intern("method"))), CV_CHAIN_APPROX_SIMPLE)
|
#define APPROX_CHAIN_METHOD(op) CVMETHOD("APPROX_CHAIN_METHOD", LOOKUP_CVMETHOD(op, "method"), CV_CHAIN_APPROX_SIMPLE)
|
||||||
#define APPROX_CHAIN_PARAMETER(op) NUM2INT(rb_hash_aref(op, ID2SYM(rb_intern("parameter"))))
|
#define APPROX_CHAIN_PARAMETER(op) NUM2INT(LOOKUP_CVMETHOD(op, "parameter"))
|
||||||
#define APPROX_CHAIN_MINIMAL_PARAMETER(op) NUM2INT(rb_hash_aref(op, ID2SYM(rb_intern("minimal_parameter"))))
|
#define APPROX_CHAIN_MINIMAL_PARAMETER(op) NUM2INT(LOOKUP_CVMETHOD(op, "minimal_parameter"))
|
||||||
#define APPROX_CHAIN_RECURSIVE(op) ({VALUE _recursive = rb_hash_aref(op, ID2SYM(rb_intern("recursive"))); NIL_P(_recursive) ? 0 : _recursive == Qfalse ? 0 : 1;})
|
#define APPROX_CHAIN_RECURSIVE(op) TRUE_OR_FALSE(LOOKUP_CVMETHOD(op, "recursive"))
|
||||||
|
|
||||||
VALUE rb_klass;
|
VALUE rb_klass;
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
__NAMESPACE_BEGIN_OPENCV
|
__NAMESPACE_BEGIN_OPENCV
|
||||||
__NAMESPACE_BEGIN_CVCONTOUR
|
__NAMESPACE_BEGIN_CVCONTOUR
|
||||||
|
|
||||||
#define APPROX_POLY_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("APPROX_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("APPROX_OPTION")), rb_intern("merge"), 1, op)
|
#define APPROX_POLY_OPTION(op) rb_get_option_table(rb_klass, "APPROX_OPTION", op)
|
||||||
#define APPROX_POLY_METHOD(op) CVMETHOD("APPROX_POLY_METHOD", rb_hash_aref(op, ID2SYM(rb_intern("method"))), CV_POLY_APPROX_DP)
|
#define APPROX_POLY_METHOD(op) CVMETHOD("APPROX_POLY_METHOD", LOOKUP_CVMETHOD(op, "method"), CV_POLY_APPROX_DP)
|
||||||
#define APPROX_POLY_ACCURACY(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("accuracy"))))
|
#define APPROX_POLY_ACCURACY(op) NUM2DBL(LOOKUP_CVMETHOD(op, "accuracy"))
|
||||||
#define APPROX_POLY_RECURSIVE(op) ({VALUE _recursive = rb_hash_aref(op, ID2SYM(rb_intern("recursive"))); NIL_P(_recursive) ? 0 : _recursive == Qfalse ? 0 : 1;})
|
#define APPROX_POLY_RECURSIVE(op) TRUE_OR_FALSE(LOOKUP_CVMETHOD(op, "recursive"))
|
||||||
|
|
||||||
VALUE rb_allocate(VALUE klass);
|
VALUE rb_allocate(VALUE klass);
|
||||||
void cvcontour_free(void *ptr);
|
void cvcontour_free(void *ptr);
|
||||||
|
|
|
@ -20,6 +20,19 @@ __NAMESPACE_BEGIN_CVFONT
|
||||||
|
|
||||||
VALUE rb_klass;
|
VALUE rb_klass;
|
||||||
|
|
||||||
|
int
|
||||||
|
rb_font_option_line_type(VALUE font_option)
|
||||||
|
{
|
||||||
|
VALUE line_type = LOOKUP_CVMETHOD(font_option, "line_type");
|
||||||
|
if (FIXNUM_P(line_type)) {
|
||||||
|
return FIX2INT(line_type);
|
||||||
|
}
|
||||||
|
else if (line_type == ID2SYM(rb_intern("aa"))) {
|
||||||
|
return CV_AA;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_class()
|
rb_class()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,14 +18,13 @@
|
||||||
__NAMESPACE_BEGIN_OPENCV
|
__NAMESPACE_BEGIN_OPENCV
|
||||||
__NAMESPACE_BEGIN_CVFONT
|
__NAMESPACE_BEGIN_CVFONT
|
||||||
|
|
||||||
#define FONT_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("FONT_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("FONT_OPTION")), rb_intern("merge"), 1, font_option)
|
#define FONT_OPTION(op) rb_get_option_table(rb_klass, "FONT_OPTION", op)
|
||||||
#define FO_ITALIC(op) ({VALUE _italic = rb_hash_aref(op, ID2SYM(rb_intern("italic"))); NIL_P(_italic) ? 0 : _italic == Qfalse ? 0 : CV_FONT_ITALIC;})
|
#define FO_ITALIC(op) TRUE_OR_FALSE(LOOKUP_CVMETHOD(op, "italic"))
|
||||||
#define FO_HSCALE(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("hscale"))))
|
#define FO_HSCALE(op) NUM2DBL(LOOKUP_CVMETHOD(op, "hscale"))
|
||||||
#define FO_VSCALE(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("vscale"))))
|
#define FO_VSCALE(op) NUM2DBL(LOOKUP_CVMETHOD(op, "vscale"))
|
||||||
#define FO_SHEAR(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("shear"))))
|
#define FO_SHEAR(op) NUM2DBL(LOOKUP_CVMETHOD(op, "shear"))
|
||||||
#define FO_THICKNESS(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("thickness"))))
|
#define FO_THICKNESS(op) NUM2INT(LOOKUP_CVMETHOD(op, "thickness"))
|
||||||
#define FO_LINE_TYPE(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("line_type"))))
|
#define FO_LINE_TYPE(op) rb_font_option_line_type(op)
|
||||||
|
|
||||||
|
|
||||||
VALUE rb_class();
|
VALUE rb_class();
|
||||||
|
|
||||||
|
|
|
@ -45,46 +45,59 @@
|
||||||
__NAMESPACE_BEGIN_OPENCV
|
__NAMESPACE_BEGIN_OPENCV
|
||||||
__NAMESPACE_BEGIN_CVMAT
|
__NAMESPACE_BEGIN_CVMAT
|
||||||
|
|
||||||
#define DRAWING_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("DRAWING_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("DRAWING_OPTION")), rb_intern("merge"), 1, op)
|
#define DRAWING_OPTION(opt) rb_get_option_table(rb_klass, "DRAWING_OPTION", opt)
|
||||||
#define DO_COLOR(op) VALUE_TO_CVSCALAR(rb_hash_aref(op, ID2SYM(rb_intern("color"))))
|
#define DO_COLOR(opt) VALUE_TO_CVSCALAR(LOOKUP_CVMETHOD(opt, "color"))
|
||||||
#define DO_THICKNESS(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("thickness"))))
|
#define DO_THICKNESS(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "thickness"))
|
||||||
#define DO_LINE_TYPE(op) (FIXNUM_P(op) ? FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("line_type")))) : CV_AA) // Quick fix
|
#define DO_LINE_TYPE(opt) rb_drawing_option_line_type(opt)
|
||||||
#define DO_SHIFT(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("shift"))))
|
#define DO_SHIFT(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "shift"))
|
||||||
#define DO_IS_CLOSED(op) ({VALUE _is_closed = rb_hash_aref(op, ID2SYM(rb_intern("is_closed"))); NIL_P(_is_closed) ? 0 : _is_closed == Qfalse ? 0 : 1;})
|
#define DO_IS_CLOSED(opt) TRUE_OR_FALSE(LOOKUP_CVMETHOD(opt, "is_closed"))
|
||||||
|
|
||||||
#define GOOD_FEATURES_TO_TRACK_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("GOOD_FEATURES_TO_TRACK_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("GOOD_FEATURES_TO_TRACK_OPTION")), rb_intern("merge"), 1, op)
|
#define GOOD_FEATURES_TO_TRACK_OPTION(opt) rb_get_option_table(rb_klass, "GOOD_FEATURES_TO_TRACK_OPTION", opt)
|
||||||
#define GF_MAX(op) NUM2INT(rb_hash_aref(op, ID2SYM(rb_intern("max"))))
|
#define GF_MAX(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "max"))
|
||||||
#define GF_MASK(op) MASK(rb_hash_aref(op, ID2SYM(rb_intern("mask"))))
|
#define GF_MASK(opt) MASK(LOOKUP_CVMETHOD(opt, "mask"))
|
||||||
#define GF_BLOCK_SIZE(op) NUM2INT(rb_hash_aref(op, ID2SYM(rb_intern("block_size"))))
|
#define GF_BLOCK_SIZE(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "block_size"))
|
||||||
#define GF_USE_HARRIS(op) TRUE_OR_FALSE(rb_hash_aref(op, ID2SYM(rb_intern("use_harris"))), 0)
|
#define GF_USE_HARRIS(opt) TRUE_OR_FALSE(LOOKUP_CVMETHOD(opt, "use_harris"))
|
||||||
#define GF_K(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("k"))))
|
#define GF_K(opt) NUM2DBL(LOOKUP_CVMETHOD(opt, "k"))
|
||||||
|
|
||||||
#define FLOOD_FILL_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("FLOOD_FILL_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("FLOOD_FILL_OPTION")), rb_intern("merge"), 1, op)
|
#define FLOOD_FILL_OPTION(opt) rb_get_option_table(rb_klass, "FLOOD_FILL_OPTION", opt)
|
||||||
#define FF_CONNECTIVITY(op) NUM2INT(rb_hash_aref(op, ID2SYM(rb_intern("connectivity"))))
|
#define FF_CONNECTIVITY(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "connectivity"))
|
||||||
#define FF_FIXED_RANGE(op) TRUE_OR_FALSE(rb_hash_aref(op, ID2SYM(rb_intern("fixed_range"))), 0)
|
#define FF_FIXED_RANGE(opt) TRUE_OR_FALSE(LOOKUP_CVMETHOD(opt, "fixed_range"))
|
||||||
#define FF_MASK_ONLY(op) TRUE_OR_FALSE(rb_hash_aref(op, ID2SYM(rb_intern("mask_only"))), 0)
|
#define FF_MASK_ONLY(opt) TRUE_OR_FALSE(LOOKUP_CVMETHOD(opt, "mask_only"))
|
||||||
|
|
||||||
#define FIND_CONTOURS_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("FIND_CONTOURS_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("FIND_CONTOURS_OPTION")), rb_intern("merge"), 1, op)
|
#define FIND_CONTOURS_OPTION(opt) rb_get_option_table(rb_klass, "FIND_CONTOURS_OPTION", opt)
|
||||||
#define FC_MODE(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("mode"))))
|
#define FC_MODE(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "mode"))
|
||||||
#define FC_METHOD(op) FIX2INT(rb_hash_aref(op, ID2SYM(rb_intern("method"))))
|
#define FC_METHOD(opt) NUM2INT(LOOKUP_CVMETHOD(opt, "method"))
|
||||||
#define FC_OFFSET(op)VALUE_TO_CVPOINT(rb_hash_aref(op, ID2SYM(rb_intern("offset"))))
|
#define FC_OFFSET(opt) VALUE_TO_CVPOINT(LOOKUP_CVMETHOD(opt, "offset"))
|
||||||
|
|
||||||
#define OPTICAL_FLOW_HS_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("OPTICAL_FLOW_HS_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("OPTICAL_FLOW_HS_OPTION")), rb_intern("merge"), 1, op)
|
#define OPTICAL_FLOW_HS_OPTION(opt) rb_get_option_table(rb_klass, "OPTICAL_FLOW_HS_OPTION", opt)
|
||||||
#define HS_LAMBDA(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("lambda"))))
|
#define HS_LAMBDA(opt) NUM2DBL(LOOKUP_CVMETHOD(opt, "lambda"))
|
||||||
#define HS_CRITERIA(op) VALUE_TO_CVTERMCRITERIA(rb_hash_aref(op, ID2SYM(rb_intern("criteria"))))
|
#define HS_CRITERIA(opt) VALUE_TO_CVTERMCRITERIA(LOOKUP_CVMETHOD(opt, "criteria"))
|
||||||
|
|
||||||
#define OPTICAL_FLOW_BM_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("OPTICAL_FLOW_BM_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("OPTICAL_FLOW_BM_OPTION")), rb_intern("merge"), 1, op)
|
#define OPTICAL_FLOW_BM_OPTION(opt) rb_get_option_table(rb_klass, "OPTICAL_FLOW_BM_OPTION", opt)
|
||||||
#define BM_BLOCK_SIZE(op) VALUE_TO_CVSIZE(rb_hash_aref(op, ID2SYM(rb_intern("block_size"))))
|
#define BM_BLOCK_SIZE(opt) VALUE_TO_CVSIZE(LOOKUP_CVMETHOD(opt, "block_size"))
|
||||||
#define BM_SHIFT_SIZE(op) VALUE_TO_CVSIZE(rb_hash_aref(op, ID2SYM(rb_intern("shift_size"))))
|
#define BM_SHIFT_SIZE(opt) VALUE_TO_CVSIZE(LOOKUP_CVMETHOD(opt, "shift_size"))
|
||||||
#define BM_MAX_RANGE(op) VALUE_TO_CVSIZE(rb_hash_aref(op, ID2SYM(rb_intern("max_range"))))
|
#define BM_MAX_RANGE(opt) VALUE_TO_CVSIZE(LOOKUP_CVMETHOD(opt, "max_range"))
|
||||||
|
|
||||||
#define FIND_FUNDAMENTAL_MAT_OPTION(op) NIL_P(op) ? rb_const_get(rb_class(), rb_intern("FIND_FUNDAMENTAL_MAT_OPTION")) : rb_funcall(rb_const_get(rb_class(), rb_intern("FIND_FUNDAMENTAL_MAT_OPTION")), rb_intern("merge"), 1, op)
|
#define FIND_FUNDAMENTAL_MAT_OPTION(opt) rb_get_option_table(rb_klass, "FIND_FUNDAMENTAL_MAT_OPTION", opt)
|
||||||
#define FFM_WITH_STATUS(op) TRUE_OR_FALSE(rb_hash_aref(op, ID2SYM(rb_intern("with_status"))), 0)
|
#define FFM_WITH_STATUS(opt) TRUE_OR_FALSE(LOOKUP_CVMETHOD(opt, "with_status"))
|
||||||
#define FFM_MAXIMUM_DISTANCE(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("maximum_distance"))))
|
#define FFM_MAXIMUM_DISTANCE(opt) NUM2DBL(LOOKUP_CVMETHOD(opt, "maximum_distance"))
|
||||||
#define FFM_DESIRABLE_LEVEL(op) NUM2DBL(rb_hash_aref(op, ID2SYM(rb_intern("desirable_level"))))
|
#define FFM_DESIRABLE_LEVEL(opt) NUM2DBL(LOOKUP_CVMETHOD(opt, "desirable_level"))
|
||||||
|
|
||||||
VALUE rb_klass;
|
VALUE rb_klass;
|
||||||
|
|
||||||
|
int
|
||||||
|
rb_drawing_option_line_type(VALUE drawing_option)
|
||||||
|
{
|
||||||
|
VALUE line_type = LOOKUP_CVMETHOD(drawing_option, "line_type");
|
||||||
|
if (FIXNUM_P(line_type)) {
|
||||||
|
return FIX2INT(line_type);
|
||||||
|
}
|
||||||
|
else if (line_type == ID2SYM(rb_intern("aa"))) {
|
||||||
|
return CV_AA;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_class()
|
rb_class()
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,3 +170,13 @@ rb_cvCreateMemStorage(int block_size)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_get_option_table(VALUE klass, const char* table_name, VALUE option)
|
||||||
|
{
|
||||||
|
VALUE table = rb_const_get(klass, rb_intern(table_name));
|
||||||
|
if (NIL_P(option))
|
||||||
|
return table;
|
||||||
|
else
|
||||||
|
return rb_funcall(table, rb_intern("merge"), 1, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,5 @@ CvMat* rb_cvCreateMat(int height, int width, int type);
|
||||||
IplImage* rb_cvCreateImage(CvSize size, int depth, int channels);
|
IplImage* rb_cvCreateImage(CvSize size, int depth, int channels);
|
||||||
IplConvKernel* rb_cvCreateStructuringElementEx(int cols, int rows, int anchorX, int anchorY, int shape, int *values);
|
IplConvKernel* rb_cvCreateStructuringElementEx(int cols, int rows, int anchorX, int anchorY, int shape, int *values);
|
||||||
CvMemStorage* rb_cvCreateMemStorage(int block_size);
|
CvMemStorage* rb_cvCreateMemStorage(int block_size);
|
||||||
|
VALUE rb_get_option_table(VALUE klass, const char* table_name, VALUE option);
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ CVMETHOD(const char *name, VALUE method, int ifnone = 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
TRUE_OR_FALSE(VALUE object, int ifnone)
|
TRUE_OR_FALSE(VALUE object, int ifnone = 0)
|
||||||
{
|
{
|
||||||
int value = ifnone;
|
int value = ifnone;
|
||||||
switch (TYPE(object)) {
|
switch (TYPE(object)) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ class TestCvFont < OpenCVTestCase
|
||||||
assert_equal(0, font.shear)
|
assert_equal(0, font.shear)
|
||||||
assert_equal(1, font.thickness)
|
assert_equal(1, font.thickness)
|
||||||
assert_equal(8, font.line_type)
|
assert_equal(8, font.line_type)
|
||||||
assert(!font.italic)
|
assert_false(font.italic)
|
||||||
|
|
||||||
font = CvFont.new(:plain, :hscale => 2.5, :vscale => 3.5,
|
font = CvFont.new(:plain, :hscale => 2.5, :vscale => 3.5,
|
||||||
:shear => 0.5, :thickness => 3, :line_type => 2, :italic => false)
|
:shear => 0.5, :thickness => 3, :line_type => 2, :italic => false)
|
||||||
|
@ -44,7 +44,7 @@ class TestCvFont < OpenCVTestCase
|
||||||
assert_equal(0.5, font.shear)
|
assert_equal(0.5, font.shear)
|
||||||
assert_equal(3, font.thickness)
|
assert_equal(3, font.thickness)
|
||||||
assert_equal(2, font.line_type)
|
assert_equal(2, font.line_type)
|
||||||
assert(!font.italic)
|
assert_false(font.italic)
|
||||||
|
|
||||||
font = CvFont.new(:simplex, :italic => true)
|
font = CvFont.new(:simplex, :italic => true)
|
||||||
assert_equal(16, font.face)
|
assert_equal(16, font.face)
|
||||||
|
|
|
@ -116,8 +116,8 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
mat2 = mat0.pre_corner_detect(3)
|
mat2 = mat0.pre_corner_detect(3)
|
||||||
mat3 = mat0.pre_corner_detect(5)
|
mat3 = mat0.pre_corner_detect(5)
|
||||||
|
|
||||||
assert_equal('fe7c8a1d07a3dd0fb6a02d6a6de0fe9f', hash_img(mat1))
|
assert_equal('1ec909dfa2e497c7f454e39aefd764f5', hash_img(mat1))
|
||||||
assert_equal('fe7c8a1d07a3dd0fb6a02d6a6de0fe9f', hash_img(mat2))
|
assert_equal('1ec909dfa2e497c7f454e39aefd764f5', hash_img(mat2))
|
||||||
assert_equal('42e7443ffd389d15343d3c6bdc42f553', hash_img(mat3))
|
assert_equal('42e7443ffd389d15343d3c6bdc42f553', hash_img(mat3))
|
||||||
|
|
||||||
# Uncomment the following lines to show the images
|
# Uncomment the following lines to show the images
|
||||||
|
@ -166,11 +166,10 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
mat3 = mat0.corner_harris(3, 3, 0.04)
|
mat3 = mat0.corner_harris(3, 3, 0.04)
|
||||||
mat4 = mat0.corner_harris(3, 7, 0.01)
|
mat4 = mat0.corner_harris(3, 7, 0.01)
|
||||||
|
|
||||||
assert_equal('6ceb54b54cc98a72de7cb75649fb0a12', hash_img(mat1))
|
assert_equal('fbb4e04c86f906c83fe17fd148675f90', hash_img(mat1))
|
||||||
assert_equal('6ceb54b54cc98a72de7cb75649fb0a12', hash_img(mat2))
|
assert_equal('fbb4e04c86f906c83fe17fd148675f90', hash_img(mat2))
|
||||||
assert_equal('6ceb54b54cc98a72de7cb75649fb0a12', hash_img(mat3))
|
assert_equal('fbb4e04c86f906c83fe17fd148675f90', hash_img(mat3))
|
||||||
# assert_equal('4e703deb9a418bbf37e3283f4a7d4d32', hash_img(mat4))
|
assert_equal('6515d75f6223806f077cebc7b3927a13', hash_img(mat4))
|
||||||
assert_equal('d689b19c786c5693da7282ab9fdb7921', hash_img(mat4))
|
|
||||||
|
|
||||||
# Uncomment the following lines to show the images
|
# Uncomment the following lines to show the images
|
||||||
# snap(['original', mat0], ['corner_harris(3)', mat1], ['corner_harris(3,3)', mat2],
|
# snap(['original', mat0], ['corner_harris(3)', mat1], ['corner_harris(3,3)', mat2],
|
||||||
|
@ -342,7 +341,7 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
assert_equal('b2203ccca2c17b042a90b79704c0f535', hash_img(mat1))
|
assert_equal('b2203ccca2c17b042a90b79704c0f535', hash_img(mat1))
|
||||||
assert_equal('b2203ccca2c17b042a90b79704c0f535', hash_img(mat2))
|
assert_equal('b2203ccca2c17b042a90b79704c0f535', hash_img(mat2))
|
||||||
assert_equal('ba8f2dee2329aaa6309de4770fc8fa55', hash_img(mat3))
|
assert_equal('ba8f2dee2329aaa6309de4770fc8fa55', hash_img(mat3))
|
||||||
assert_equal('8a28a2748b0cfc87205d65c625187867', hash_img(mat4))
|
assert_equal('10cf18adaa8548101cc230206624133a', hash_img(mat4))
|
||||||
assert_equal('de5c30fcd9e817aa282ab05388de995b', hash_img(mat5))
|
assert_equal('de5c30fcd9e817aa282ab05388de995b', hash_img(mat5))
|
||||||
|
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
|
@ -1752,12 +1751,12 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
velx, vely = curr.optical_flow_lk(prev, CvSize.new(3, 3))
|
velx, vely = curr.optical_flow_lk(prev, CvSize.new(3, 3))
|
||||||
assert_equal('bea0c4c2b4b89ed1bb5e9ef5b68b8759', hash_img(velx))
|
assert_equal('13333362f0daf6ad732006bd2a32e177', hash_img(velx))
|
||||||
assert_equal('aa643584d4eb175ab48896ff44646e06', hash_img(vely))
|
assert_equal('45dc42034ab606dd61e34a5adc6a1c1b', hash_img(vely))
|
||||||
|
|
||||||
velx, vely = curr.optical_flow_lk(prev, CvSize.new(5, 5))
|
velx, vely = curr.optical_flow_lk(prev, CvSize.new(5, 5))
|
||||||
assert_equal('00d5889a8e62f7c5fc695ba3556cc374', hash_img(velx))
|
assert_equal('d83c57805f9c074d0ad33a7522a75952', hash_img(velx))
|
||||||
assert_equal('e7524c292e95e374fdb588f0b516938e', hash_img(vely))
|
assert_equal('df8fb2010b00d89090e7d9653781a68d', hash_img(vely))
|
||||||
|
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
curr.optical_flow_lk(DUMMY_OBJ, CvSize.new(3, 3))
|
curr.optical_flow_lk(DUMMY_OBJ, CvSize.new(3, 3))
|
||||||
|
|
Loading…
Reference in a new issue