diff --git a/ext/opencv/cvmat.cpp b/ext/opencv/cvmat.cpp
index 40f1a23..cf3f441 100644
--- a/ext/opencv/cvmat.cpp
+++ b/ext/opencv/cvmat.cpp
@@ -3915,14 +3915,14 @@ rb_quadrangle_sub_pix(int argc, VALUE *argv, VALUE self)
*
* Resize image.
* interpolation is interpolation method:
- * * :nn
+ * * CV_INTER_NN
* nearest-neighbor interpolation.
- * * :linear
+ * * CV_INTER_LINEAR
* bilinear interpolation (used by default)
- * * :area
+ * * CV_INTER_AREA
* resampling using pixel area relation. It is preferred method for image decimation that give moire-free results.
* In case of zooming it is similar to NN method.
- * * :cubic
+ * * CV_INTER_CUBIC
* bicubic interpolation.
* Return self resized image that it fits exactly to size. If ROI is set, the method consideres the ROI as supported as usual.
*/
@@ -3932,8 +3932,10 @@ rb_resize(int argc, VALUE *argv, VALUE self)
VALUE size, interpolation;
rb_scan_args(argc, argv, "11", &size, &interpolation);
VALUE dest = new_mat_kind_object(VALUE_TO_CVSIZE(size), self);
+ int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
+
try {
- cvResize(CVARR(self), CVARR(dest), CVMETHOD("INTERPOLATION_METHOD", interpolation, CV_INTER_LINEAR));
+ cvResize(CVARR(self), CVARR(dest), method);
}
catch (cv::Exception& e) {
raise_cverror(e);
@@ -3943,7 +3945,7 @@ rb_resize(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * warp_affine(map_matrix[,interpolation = :linear][,option = :fill_outliers][,fillval = 0]) -> cvmat
+ * warp_affine(map_matrix[,interpolation = CV_INTER_LINEAR][,option = :fill_outliers][,fillval = 0]) -> cvmat
*
* Applies affine transformation to the image.
*/
@@ -3955,11 +3957,12 @@ rb_warp_affine(int argc, VALUE *argv, VALUE self)
if (rb_scan_args(argc, argv, "13", &map_matrix, &interpolation, &option, &fill_value) < 4)
fill_value = INT2FIX(0);
CvArr* self_ptr = CVARR(self);
+ int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
try {
dest = new_mat_kind_object(cvGetSize(self_ptr), self);
cvWarpAffine(self_ptr, CVARR(dest), CVMAT_WITH_CHECK(map_matrix),
- CVMETHOD("INTERPOLATION_METHOD", interpolation, CV_INTER_LINEAR)
- | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIERS), VALUE_TO_CVSCALAR(fill_value));
+ method | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIERS),
+ VALUE_TO_CVSCALAR(fill_value));
}
catch (cv::Exception& e) {
raise_cverror(e);
@@ -4047,7 +4050,7 @@ rb_rotation_matrix2D(VALUE self, VALUE center, VALUE angle, VALUE scale)
/*
* call-seq:
- * warp_perspective(map_matrix[,interpolation=:linear][,option =:fill_outliers][,fillval=0])) -> cvmat
+ * warp_perspective(map_matrix[,interpolation=CV_INTER_LINEAR][,option =:fill_outliers][,fillval=0])) -> cvmat
*
* Applies perspective transformation to the image.
*/
@@ -4059,11 +4062,11 @@ rb_warp_perspective(int argc, VALUE *argv, VALUE self)
fillval = INT2FIX(0);
CvArr* self_ptr = CVARR(self);
VALUE dest = Qnil;
+ int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
try {
dest = new_mat_kind_object(cvGetSize(self_ptr), self);
cvWarpPerspective(self_ptr, CVARR(dest), CVMAT_WITH_CHECK(map_matrix),
- CVMETHOD("INTERPOLATION_METHOD", interpolation, CV_INTER_LINEAR)
- | CVMETHOD("WARP_FLAG",option, CV_WARP_FILL_OUTLIERS),
+ method | CVMETHOD("WARP_FLAG",option, CV_WARP_FILL_OUTLIERS),
VALUE_TO_CVSCALAR(fillval));
}
catch (cv::Exception& e) {
@@ -4074,7 +4077,7 @@ rb_warp_perspective(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * remap(mapx,mapy[,interpolation=:linear][,option=:fill_outliers][,fillval=0]) -> cvmat
+ * remap(mapx,mapy[,interpolation=CV_INTER_LINEAR][,option=:fill_outliers][,fillval=0]) -> cvmat
*
* Applies generic geometrical transformation to the image.
* Transforms source image using the specified map:
@@ -4090,11 +4093,11 @@ rb_remap(int argc, VALUE *argv, VALUE self)
fillval = INT2FIX(0);
CvArr* self_ptr = CVARR(self);
VALUE dest = Qnil;
+ int method = NIL_P(interpolation) ? CV_INTER_LINEAR : NUM2INT(interpolation);
try {
dest = new_mat_kind_object(cvGetSize(self_ptr), self);
cvRemap(self_ptr, CVARR(dest), CVARR_WITH_CHECK(mapx), CVARR_WITH_CHECK(mapy),
- CVMETHOD("INTERPOLATION_METHOD", interpolation, CV_INTER_LINEAR)
- | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIERS),
+ method | CVMETHOD("WARP_FLAG", option, CV_WARP_FILL_OUTLIERS),
VALUE_TO_CVSCALAR(fillval));
}
catch (cv::Exception& e) {
diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp
index 944132d..d7d3863 100644
--- a/ext/opencv/opencv.cpp
+++ b/ext/opencv/opencv.cpp
@@ -294,7 +294,7 @@ define_ruby_module()
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));
@@ -345,14 +345,6 @@ define_ruby_module()
REGISTER_CVMETHOD(inversion_method, "svd_sym", CV_SVD_SYM);
REGISTER_CVMETHOD(inversion_method, "svd_symmetric", CV_SVD_SYM);
- VALUE interpolation_method = rb_hash_new();
- /* {:nn, :linear, :area, :cubic}: Interpolation method */
- rb_define_const(rb_module, "INTERPOLATION_METHOD", interpolation_method);
- REGISTER_CVMETHOD(interpolation_method, "nn", CV_INTER_NN);
- REGISTER_CVMETHOD(interpolation_method, "linear", CV_INTER_LINEAR);
- REGISTER_CVMETHOD(interpolation_method, "area", CV_INTER_AREA);
- REGISTER_CVMETHOD(interpolation_method, "cubic", CV_INTER_CUBIC);
-
VALUE warp_flag = rb_hash_new();
/* {:fill_outliers, :inverse_map}: Warp affine optional flags */
rb_define_const(rb_module, "WARP_FLAG", warp_flag);
diff --git a/test/test_cvmat_imageprocessing.rb b/test/test_cvmat_imageprocessing.rb
index 573c0a1..9d1266d 100755
--- a/test/test_cvmat_imageprocessing.rb
+++ b/test/test_cvmat_imageprocessing.rb
@@ -388,10 +388,10 @@ class TestCvMat_imageprocessing < OpenCVTestCase
size_512 = CvSize.new(512, 512)
size_128 = CvSize.new(128, 128)
mat1 = mat0.resize(size_512)
- mat2 = mat0.resize(size_512, :linear)
- mat3 = mat0.resize(size_512, :nn)
- mat4 = mat0.resize(size_128, :area)
- mat5 = mat0.resize(size_128, :cubic)
+ mat2 = mat0.resize(size_512, CV_INTER_LINEAR)
+ mat3 = mat0.resize(size_512, CV_INTER_NN)
+ mat4 = mat0.resize(size_128, CV_INTER_AREA)
+ mat5 = mat0.resize(size_128, CV_INTER_CUBIC)
mat6 = mat0.clone
assert_equal('b2203ccca2c17b042a90b79704c0f535', hash_img(mat1))
@@ -420,9 +420,9 @@ class TestCvMat_imageprocessing < OpenCVTestCase
map_matrix[5] = CvScalar.new(66.08774)
mat1 = mat0.warp_affine(map_matrix)
- mat2 = mat0.warp_affine(map_matrix, :nn)
- mat3 = mat0.warp_affine(map_matrix, :linear, :fill_outliers, CvColor::Yellow)
- mat4 = mat0.warp_affine(map_matrix, :linear, :inverse_map)
+ 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))
@@ -483,9 +483,9 @@ class TestCvMat_imageprocessing < OpenCVTestCase
map_matrix[8] = CvScalar.new(1.00000)
mat1 = mat0.warp_perspective(map_matrix)
- mat2 = mat0.warp_perspective(map_matrix, :nn)
- mat3 = mat0.warp_perspective(map_matrix, :linear, :inverse_map)
- mat4 = mat0.warp_perspective(map_matrix, :linear, :fill_outliers, CvColor::Yellow)
+ 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)
assert_equal('bba3a5395f9dd9a400a0083ae74d8986', hash_img(mat1))
assert_equal('a0cc4f329f459410293b75b417fc4f25', hash_img(mat2))
@@ -522,8 +522,8 @@ class TestCvMat_imageprocessing < OpenCVTestCase
}
mat1 = mat0.remap(matx, maty)
- mat2 = mat0.remap(matx, maty, :nn)
- mat3 = mat0.remap(matx, maty, :linear, :fill_outliers, CvColor::Yellow)
+ mat2 = mat0.remap(matx, maty, CV_INTER_NN)
+ mat3 = mat0.remap(matx, maty, CV_INTER_LINEAR, :fill_outliers, CvColor::Yellow)
assert_equal('586716c0262a3e03a54b9fc6e671e5f7', hash_img(mat1))
assert_equal('5461ecdee23d5e8a9099500d631c9f0f', hash_img(mat2))