mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
added CvMat#log_polar
This commit is contained in:
parent
09389f1eb9
commit
8d172aa35e
6 changed files with 49 additions and 14 deletions
|
@ -313,7 +313,7 @@ void define_ruby_class()
|
||||||
rb_define_method(rb_klass, "warp_perspective", RUBY_METHOD_FUNC(rb_warp_perspective), -1);
|
rb_define_method(rb_klass, "warp_perspective", RUBY_METHOD_FUNC(rb_warp_perspective), -1);
|
||||||
rb_define_singleton_method(rb_klass, "find_homography", RUBY_METHOD_FUNC(rb_find_homograpy), -1);
|
rb_define_singleton_method(rb_klass, "find_homography", RUBY_METHOD_FUNC(rb_find_homograpy), -1);
|
||||||
rb_define_method(rb_klass, "remap", RUBY_METHOD_FUNC(rb_remap), -1);
|
rb_define_method(rb_klass, "remap", RUBY_METHOD_FUNC(rb_remap), -1);
|
||||||
//rb_define_method(rb_klass, "log_polar", RUBY_METHOD_FUNC(rb_log_polar), -1);
|
rb_define_method(rb_klass, "log_polar", RUBY_METHOD_FUNC(rb_log_polar), -1);
|
||||||
|
|
||||||
rb_define_method(rb_klass, "erode", RUBY_METHOD_FUNC(rb_erode), -1);
|
rb_define_method(rb_klass, "erode", RUBY_METHOD_FUNC(rb_erode), -1);
|
||||||
rb_define_method(rb_klass, "erode!", RUBY_METHOD_FUNC(rb_erode_bang), -1);
|
rb_define_method(rb_klass, "erode!", RUBY_METHOD_FUNC(rb_erode_bang), -1);
|
||||||
|
@ -3894,23 +3894,24 @@ rb_remap(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* log_polar(<i>center, magnitude, </i>)
|
* log_polar(<i>size, center, magnitude[ ,flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS]</i>)
|
||||||
*
|
*
|
||||||
* Remaps image to log-polar space.
|
* Remaps image to log-polar space.
|
||||||
*/
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_log_polar(int argc, VALUE *argv, VALUE self)
|
rb_log_polar(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
/*
|
VALUE dst_size, center, m, flags;
|
||||||
VALUE size, center, m, flags, fillval, dest;
|
rb_scan_args(argc, argv, "31", &dst_size, ¢er, &m, &flags);
|
||||||
rb_scan_args(argc, argv, "3*", &size, ¢er, &m, &flags);
|
int _flags = NIL_P(flags) ? (CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS) : NUM2INT(flags);
|
||||||
dest = cCvMat::new_object();
|
VALUE dest = new_mat_kind_object(VALUE_TO_CVSIZE(dst_size), self);
|
||||||
cvLogPolar(CVARR(self), CVARR(dest),
|
try {
|
||||||
VALUE_TO_CVPOINT2D32F(center), NUM2DBL(m),
|
cvLogPolar(CVARR(self), CVARR(dest), VALUE_TO_CVPOINT2D32F(center), NUM2DBL(m), _flags);
|
||||||
CVMETHOD("INTERPOLATION_METHOD", interpolation, CV_INTER_LINEAR) | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIEARS), VALUE_TO_CVSCALAR(fillval));
|
}
|
||||||
|
catch (cv::Exception& e) {
|
||||||
|
raise_cverror(e);
|
||||||
|
}
|
||||||
return dest;
|
return dest;
|
||||||
*/
|
|
||||||
return Qnil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -178,7 +178,7 @@ VALUE rb_rotation_matrix2D(VALUE self, VALUE center, VALUE angle, VALUE scale);
|
||||||
VALUE rb_warp_perspective(int argc, VALUE *argv, VALUE self);
|
VALUE rb_warp_perspective(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_find_homograpy(int argc, VALUE *argv, VALUE self);
|
VALUE rb_find_homograpy(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_remap(int argc, VALUE *argv, VALUE self);
|
VALUE rb_remap(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_log_polar(int argc, VALUE *argv);
|
VALUE rb_log_polar(int argc, VALUE *argv, VALUE self);
|
||||||
|
|
||||||
VALUE rb_erode(int argc, VALUE *argv, VALUE self);
|
VALUE rb_erode(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_erode_bang(int argc, VALUE *argv, VALUE self);
|
VALUE rb_erode_bang(int argc, VALUE *argv, VALUE self);
|
||||||
|
|
|
@ -268,6 +268,16 @@ define_ruby_module()
|
||||||
/* Object detection mode */
|
/* Object detection mode */
|
||||||
rb_define_const(rb_module, "CV_HAAR_DO_CANNY_PRUNING", INT2FIX(CV_HAAR_DO_CANNY_PRUNING));
|
rb_define_const(rb_module, "CV_HAAR_DO_CANNY_PRUNING", INT2FIX(CV_HAAR_DO_CANNY_PRUNING));
|
||||||
|
|
||||||
|
/* Interpolation methods */
|
||||||
|
rb_define_const(rb_module, "CV_INTER_NN", INT2FIX(CV_INTER_NN));
|
||||||
|
rb_define_const(rb_module, "CV_INTER_LINEAR", INT2FIX(CV_INTER_LINEAR));
|
||||||
|
rb_define_const(rb_module, "CV_INTER_AREA", INT2FIX(CV_INTER_AREA));
|
||||||
|
rb_define_const(rb_module, "CV_INTER_CUBIC", INT2FIX(CV_INTER_CUBIC));
|
||||||
|
|
||||||
|
/* Warp affine optional flags */
|
||||||
|
rb_define_const(rb_module, "CV_WARP_FILL_OUTLIERS", INT2FIX(CV_WARP_FILL_OUTLIERS));
|
||||||
|
rb_define_const(rb_module, "CV_WARP_INVERSE_MAP", INT2FIX(CV_WARP_INVERSE_MAP));
|
||||||
|
|
||||||
VALUE inversion_method = rb_hash_new();
|
VALUE inversion_method = rb_hash_new();
|
||||||
/* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */
|
/* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */
|
||||||
rb_define_const(rb_module, "INVERSION_METHOD", inversion_method);
|
rb_define_const(rb_module, "INVERSION_METHOD", inversion_method);
|
||||||
|
|
|
@ -9,6 +9,7 @@ class OpenCVTestCase < Test::Unit::TestCase
|
||||||
SAMPLE_DIR = File.expand_path(File.dirname(__FILE__)) + '/samples/'
|
SAMPLE_DIR = File.expand_path(File.dirname(__FILE__)) + '/samples/'
|
||||||
FILENAME_CAT = SAMPLE_DIR + 'cat.jpg'
|
FILENAME_CAT = SAMPLE_DIR + 'cat.jpg'
|
||||||
FILENAME_LENA256x256 = SAMPLE_DIR + 'lena-256x256.jpg'
|
FILENAME_LENA256x256 = SAMPLE_DIR + 'lena-256x256.jpg'
|
||||||
|
FILENAME_FRUITS = SAMPLE_DIR + 'fruits.jpg'
|
||||||
HAARCASCADE_FRONTALFACE_ALT = SAMPLE_DIR + 'haarcascade_frontalface_alt.xml.gz'
|
HAARCASCADE_FRONTALFACE_ALT = SAMPLE_DIR + 'haarcascade_frontalface_alt.xml.gz'
|
||||||
AVI_SAMPLE = SAMPLE_DIR + 'movie_sample.avi'
|
AVI_SAMPLE = SAMPLE_DIR + 'movie_sample.avi'
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,20 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_log_polar
|
def test_log_polar
|
||||||
flunk('FIXME: CvMat#log_polar is not implemented yet.')
|
mat0 = CvMat.load(FILENAME_FRUITS, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH)
|
||||||
|
|
||||||
|
mat1 = mat0.log_polar(CvSize.new(255, 255), CvPoint2D32f.new(mat0.width / 2, mat0.height / 2), 40)
|
||||||
|
assert_equal('d0425614b2f6e63ab2b6ef6637b4efcb', hash_img(mat1))
|
||||||
|
mat1 = mat0.log_polar(CvSize.new(255, 255), CvPoint2D32f.new(mat0.width / 2, mat0.height / 2), 40,
|
||||||
|
CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS)
|
||||||
|
assert_equal('d0425614b2f6e63ab2b6ef6637b4efcb', hash_img(mat1))
|
||||||
|
|
||||||
|
mat2 = mat1.log_polar(mat0.size, CvPoint2D32f.new(mat0.width / 2, mat0.height / 2), 40,
|
||||||
|
CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS | CV_WARP_INVERSE_MAP)
|
||||||
|
assert_equal('52587e593fec1b0383731be53147e8cd', hash_img(mat2))
|
||||||
|
|
||||||
|
# Uncomment the following line to show the results
|
||||||
|
# snap mat0, mat1, mat2
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_erode
|
def test_erode
|
||||||
|
|
|
@ -109,6 +109,16 @@ class TestOpenCV < OpenCVTestCase
|
||||||
|
|
||||||
# Object detection mode
|
# Object detection mode
|
||||||
assert_equal(1, CV_HAAR_DO_CANNY_PRUNING)
|
assert_equal(1, CV_HAAR_DO_CANNY_PRUNING)
|
||||||
|
|
||||||
|
# Interpolation methods
|
||||||
|
assert_equal(0, CV_INTER_NN)
|
||||||
|
assert_equal(1, CV_INTER_LINEAR)
|
||||||
|
assert_equal(2, CV_INTER_CUBIC)
|
||||||
|
assert_equal(3, CV_INTER_AREA)
|
||||||
|
|
||||||
|
# Warp affine optional flags
|
||||||
|
assert_equal(8, CV_WARP_FILL_OUTLIERS)
|
||||||
|
assert_equal(16, CV_WARP_INVERSE_MAP)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_symbols
|
def test_symbols
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue