diff --git a/ext/opencv/cvmat.cpp b/ext/opencv/cvmat.cpp
index cf3f441..9a7f041 100644
--- a/ext/opencv/cvmat.cpp
+++ b/ext/opencv/cvmat.cpp
@@ -3945,24 +3945,23 @@ rb_resize(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * warp_affine(map_matrix[,interpolation = CV_INTER_LINEAR][,option = :fill_outliers][,fillval = 0]) -> cvmat
+ * warp_affine(map_matrix[,flags = CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS][,fillval = 0]) -> cvmat
*
* Applies affine transformation to the image.
*/
VALUE
rb_warp_affine(int argc, VALUE *argv, VALUE self)
{
- VALUE map_matrix, interpolation, option, fill_value;
+ VALUE map_matrix, flags_val, option, fill_value;
VALUE dest = Qnil;
- if (rb_scan_args(argc, argv, "13", &map_matrix, &interpolation, &option, &fill_value) < 4)
+ if (rb_scan_args(argc, argv, "13", &map_matrix, &flags_val, &option, &fill_value) < 4)
fill_value = INT2FIX(0);
CvArr* self_ptr = CVARR(self);
- int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
+ int flags = NIL_P(flags_val) ? (CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS) : NUM2INT(flags_val);
try {
dest = new_mat_kind_object(cvGetSize(self_ptr), self);
cvWarpAffine(self_ptr, CVARR(dest), CVMAT_WITH_CHECK(map_matrix),
- method | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIERS),
- VALUE_TO_CVSCALAR(fill_value));
+ flags, VALUE_TO_CVSCALAR(fill_value));
}
catch (cv::Exception& e) {
raise_cverror(e);
@@ -4050,24 +4049,23 @@ rb_rotation_matrix2D(VALUE self, VALUE center, VALUE angle, VALUE scale)
/*
* call-seq:
- * warp_perspective(map_matrix[,interpolation=CV_INTER_LINEAR][,option =:fill_outliers][,fillval=0])) -> cvmat
+ * warp_perspective(map_matrix[,flags = CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS][,fillval=0])) -> cvmat
*
* Applies perspective transformation to the image.
*/
VALUE
rb_warp_perspective(int argc, VALUE *argv, VALUE self)
{
- VALUE map_matrix, interpolation, option, fillval;
- if (rb_scan_args(argc, argv, "13", &map_matrix, &interpolation, &option, &fillval) < 4)
+ VALUE map_matrix, flags_val, option, fillval;
+ if (rb_scan_args(argc, argv, "13", &map_matrix, &flags_val, &option, &fillval) < 4)
fillval = INT2FIX(0);
CvArr* self_ptr = CVARR(self);
VALUE dest = Qnil;
- int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
+ int flags = NIL_P(flags_val) ? (CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS) : NUM2INT(flags_val);
try {
dest = new_mat_kind_object(cvGetSize(self_ptr), self);
cvWarpPerspective(self_ptr, CVARR(dest), CVMAT_WITH_CHECK(map_matrix),
- method | CVMETHOD("WARP_FLAG",option, CV_WARP_FILL_OUTLIERS),
- VALUE_TO_CVSCALAR(fillval));
+ flags, VALUE_TO_CVSCALAR(fillval));
}
catch (cv::Exception& e) {
raise_cverror(e);
@@ -4077,7 +4075,7 @@ rb_warp_perspective(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * remap(mapx,mapy[,interpolation=CV_INTER_LINEAR][,option=:fill_outliers][,fillval=0]) -> cvmat
+ * remap(mapx,mapy[,flags = CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS][,fillval=0]) -> cvmat
*
* Applies generic geometrical transformation to the image.
* Transforms source image using the specified map:
@@ -4088,17 +4086,16 @@ rb_warp_perspective(int argc, VALUE *argv, VALUE self)
VALUE
rb_remap(int argc, VALUE *argv, VALUE self)
{
- VALUE mapx, mapy, interpolation, option, fillval;
- if (rb_scan_args(argc, argv, "23", &mapx, &mapy, &interpolation, &option, &fillval) < 5)
+ VALUE mapx, mapy, flags_val, option, fillval;
+ if (rb_scan_args(argc, argv, "23", &mapx, &mapy, &flags_val, &option, &fillval) < 5)
fillval = INT2FIX(0);
CvArr* self_ptr = CVARR(self);
VALUE dest = Qnil;
- int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
+ int flags = NIL_P(flags_val) ? (CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS) : NUM2INT(flags_val);
try {
dest = new_mat_kind_object(cvGetSize(self_ptr), self);
cvRemap(self_ptr, CVARR(dest), CVARR_WITH_CHECK(mapx), CVARR_WITH_CHECK(mapy),
- method | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIERS),
- VALUE_TO_CVSCALAR(fillval));
+ flags, VALUE_TO_CVSCALAR(fillval));
}
catch (cv::Exception& e) {
raise_cverror(e);
diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp
index 9af6cab..643e17a 100644
--- a/ext/opencv/opencv.cpp
+++ b/ext/opencv/opencv.cpp
@@ -346,12 +346,6 @@ define_ruby_module()
REGISTER_CVMETHOD(inversion_method, "svd_sym", CV_SVD_SYM);
REGISTER_CVMETHOD(inversion_method, "svd_symmetric", CV_SVD_SYM);
- VALUE warp_flag = rb_hash_new();
- /* {:fill_outliers, :inverse_map}: Warp affine optional flags */
- rb_define_const(rb_module, "WARP_FLAG", warp_flag);
- REGISTER_CVMETHOD(warp_flag, "fill_outliers", CV_WARP_FILL_OUTLIERS);
- REGISTER_CVMETHOD(warp_flag, "inverse_map", CV_WARP_INVERSE_MAP);
-
VALUE homography_calc_method = rb_hash_new();
/* {:all, :ransac, :lmeds}: Methods used to computed homography matrix */
rb_define_const(rb_module, "HOMOGRAPHY_CALC_METHOD", homography_calc_method);
diff --git a/test/test_cvmat_imageprocessing.rb b/test/test_cvmat_imageprocessing.rb
index 16b213e..3844a29 100755
--- a/test/test_cvmat_imageprocessing.rb
+++ b/test/test_cvmat_imageprocessing.rb
@@ -424,14 +424,16 @@ class TestCvMat_imageprocessing < OpenCVTestCase
map_matrix[5] = CvScalar.new(66.08774)
mat1 = mat0.warp_affine(map_matrix)
- mat2 = mat0.warp_affine(map_matrix, CV_INTER_NN)
- mat3 = mat0.warp_affine(map_matrix, CV_INTER_LINEAR, :fill_outliers, CvColor::Yellow)
- mat4 = mat0.warp_affine(map_matrix, CV_INTER_LINEAR, :inverse_map)
-
- assert_equal('da3d7cdefabbaf84c4080ecd40d00897', hash_img(mat1))
- assert_equal('b4abcd12c4e1103c3de87bf9ad854936', hash_img(mat2))
- assert_equal('26f6b10e955125c91fd7e63a63cc06a3', hash_img(mat3))
- assert_equal('cc4eb5d8eb7cb2c0b76941bc38fb91b1', hash_img(mat4))
+ mat2 = mat0.warp_affine(map_matrix, CV_INTER_NN | CV_WARP_FILL_OUTLIERS)
+ mat3 = mat0.warp_affine(map_matrix, CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS, CvColor::Yellow)
+ mat4 = mat0.warp_affine(map_matrix, CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS | CV_WARP_INVERSE_MAP)
+
+ [mat1, mat2, mat3, mat4].each { |m|
+ assert_equal(mat0.cols, m.cols)
+ assert_equal(mat0.rows, m.rows)
+ assert_equal(mat0.depth, m.depth)
+ assert_equal(mat0.channel, m.channel)
+ }
assert_raise(TypeError) {
mat0.warp_affine(DUMMY_OBJ)
@@ -439,9 +441,9 @@ class TestCvMat_imageprocessing < OpenCVTestCase
assert_raise(TypeError) {
mat0.warp_affine(map_matrix, DUMMY_OBJ)
}
- # assert_raise(CvError) {
- # mat0.warp_affine(CvMat.new(3, 3))
- # }
+
+ # Uncomment the following lines to show the results
+ # snap mat0, mat1, mat2, mat3, mat4
end
def test_rotation_matrix2D
@@ -488,13 +490,15 @@ class TestCvMat_imageprocessing < OpenCVTestCase
mat1 = mat0.warp_perspective(map_matrix)
mat2 = mat0.warp_perspective(map_matrix, CV_INTER_NN)
- mat3 = mat0.warp_perspective(map_matrix, CV_INTER_LINEAR, :inverse_map)
- mat4 = mat0.warp_perspective(map_matrix, CV_INTER_LINEAR, :fill_outliers, CvColor::Yellow)
+ mat3 = mat0.warp_perspective(map_matrix, CV_INTER_LINEAR | CV_WARP_INVERSE_MAP)
+ mat4 = mat0.warp_perspective(map_matrix, CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS, CvColor::Yellow)
- assert_equal('bba3a5395f9dd9a400a0083ae74d8986', hash_img(mat1))
- assert_equal('a0cc4f329f459410293b75b417fc4f25', hash_img(mat2))
- assert_equal('3e34e6ed2404056bb72e86edf02610cb', hash_img(mat3))
- assert_equal('71bd12857d2e4ac0c919652c2963b4e1', hash_img(mat4))
+ [mat1, mat2, mat3, mat4].each { |m|
+ assert_equal(mat0.cols, m.cols)
+ assert_equal(mat0.rows, m.rows)
+ assert_equal(mat0.depth, m.depth)
+ assert_equal(mat0.channel, m.channel)
+ }
assert_raise(TypeError) {
mat0.warp_perspective(DUMMY_OBJ)
@@ -502,9 +506,9 @@ class TestCvMat_imageprocessing < OpenCVTestCase
assert_raise(TypeError) {
mat0.warp_perspective(map_matrix, DUMMY_OBJ)
}
- # assert_raise(CvError) {
- # mat0.warp_perspective(CvMat.new(2, 3))
- # }
+
+ # Uncomment the following line to show the results
+ # snap mat0, mat1, mat2, mat3, mat4
end
def test_remap
@@ -527,11 +531,14 @@ class TestCvMat_imageprocessing < OpenCVTestCase
mat1 = mat0.remap(matx, maty)
mat2 = mat0.remap(matx, maty, CV_INTER_NN)
- mat3 = mat0.remap(matx, maty, CV_INTER_LINEAR, :fill_outliers, CvColor::Yellow)
+ mat3 = mat0.remap(matx, maty, CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS, CvColor::Yellow)
- assert_equal('586716c0262a3e03a54b9fc6e671e5f7', hash_img(mat1))
- assert_equal('5461ecdee23d5e8a9099500d631c9f0f', hash_img(mat2))
- assert_equal('1f6b73925056298c566e8e727627d929', hash_img(mat3))
+ [mat1, mat2, mat3].each { |m|
+ assert_equal(mat0.cols, m.cols)
+ assert_equal(mat0.rows, m.rows)
+ assert_equal(mat0.depth, m.depth)
+ assert_equal(mat0.channel, m.channel)
+ }
assert_raise(TypeError) {
mat0.remap(DUMMY_OBJ, maty)
@@ -542,9 +549,9 @@ class TestCvMat_imageprocessing < OpenCVTestCase
assert_raise(TypeError) {
mat0.remap(matx, maty, DUMMY_OBJ)
}
- # assert_raise(CvError) {
- # mat0.remap(CvMat.new(3, 3, :cv8u), maty)
- # }
+
+ # Uncomment the following line to show the results
+ # snap mat0, mat1, mat2, mat3
end
def test_log_polar
diff --git a/test/test_opencv.rb b/test/test_opencv.rb
index 8757c48..d8e393b 100755
--- a/test/test_opencv.rb
+++ b/test/test_opencv.rb
@@ -164,16 +164,6 @@ class TestOpenCV < OpenCVTestCase
assert_equal(2, INVERSION_METHOD[:svd_sym])
assert_equal(2, INVERSION_METHOD[:svd_symmetric])
- # Interpolation methods
- assert_equal(0, INTERPOLATION_METHOD[:nn])
- assert_equal(1, INTERPOLATION_METHOD[:linear])
- assert_equal(2, INTERPOLATION_METHOD[:cubic])
- assert_equal(3, INTERPOLATION_METHOD[:area])
-
- # Warp affine optional flags
- assert_equal(8, WARP_FLAG[:fill_outliers])
- assert_equal(16, WARP_FLAG[:inverse_map])
-
# Homography calculation methods
assert_equal(0, HOMOGRAPHY_CALC_METHOD[:all])
assert_equal(4, HOMOGRAPHY_CALC_METHOD[:lmeds])