mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
fixed a bug of opencv.cpp, and added some tests
This commit is contained in:
parent
04bb08414b
commit
4c123ec324
2 changed files with 75 additions and 4 deletions
|
@ -196,7 +196,7 @@ define_ruby_module()
|
|||
/* {:fill_outliers, :inverse_map}: Warp affine optional flags */
|
||||
rb_define_const(rb_module, "WARP_FLAG", warp_flag);
|
||||
RESIST_CVMETHOD(warp_flag, "fill_outliers", CV_WARP_FILL_OUTLIERS);
|
||||
RESIST_CVMETHOD(warp_flag, "inverse_map", CV_WARP_INVERSE_MAP);
|
||||
RESIST_CVMETHOD(warp_flag, "inverse_map", CV_WARP_INVERSE_MAP);
|
||||
|
||||
VALUE depth = rb_hash_new();
|
||||
/* {:cv8u, :cv8s, :cv16u, :cv16s, :cv32s, :cv32f, :cv64f}: Depth of each pixel. */
|
||||
|
@ -212,8 +212,8 @@ define_ruby_module()
|
|||
VALUE connectivity = rb_hash_new();
|
||||
/* {:aa(:anti_alias)}: Determined by the closeness of pixel values */
|
||||
rb_define_const(rb_module, "CONNECTIVITY", connectivity);
|
||||
RESIST_CVMETHOD(depth, "aa", CV_AA);
|
||||
RESIST_CVMETHOD(depth, "anti_alias", CV_AA);
|
||||
RESIST_CVMETHOD(connectivity, "aa", CV_AA);
|
||||
RESIST_CVMETHOD(connectivity, "anti_alias", CV_AA);
|
||||
|
||||
VALUE retrieval_mode = rb_hash_new();
|
||||
/* {:external, :list, :ccomp, :tree}: Retrieval mode */
|
||||
|
@ -473,7 +473,7 @@ extern "C"{
|
|||
|
||||
#ifdef HAVE_ML_H
|
||||
/* feature support.
|
||||
mOpenCV::mMachineLearning::define_ruby_module();
|
||||
mOpenCV::mMachineLearning::define_ruby_module();
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -7,6 +7,77 @@ require File.expand_path(File.dirname(__FILE__)) + '/helper'
|
|||
include OpenCV
|
||||
|
||||
class TestOpenCV < OpenCVTestCase
|
||||
def test_constants
|
||||
# Depths
|
||||
assert_equal(0, CV_8U)
|
||||
assert_equal(1, CV_8S)
|
||||
assert_equal(2, CV_16U)
|
||||
assert_equal(3, CV_16S)
|
||||
assert_equal(4, CV_32S)
|
||||
assert_equal(5, CV_32F)
|
||||
assert_equal(6, CV_64F)
|
||||
end
|
||||
|
||||
def test_symbols
|
||||
# Depths
|
||||
assert_equal(0, DEPTH[:cv8u])
|
||||
assert_equal(1, DEPTH[:cv8s])
|
||||
assert_equal(2, DEPTH[:cv16u])
|
||||
assert_equal(3, DEPTH[:cv16s])
|
||||
assert_equal(4, DEPTH[:cv32s])
|
||||
assert_equal(5, DEPTH[:cv32f])
|
||||
assert_equal(6, DEPTH[:cv64f])
|
||||
|
||||
# Inversion methods
|
||||
assert_equal(0, INVERSION_METHOD[:lu])
|
||||
assert_equal(1, INVERSION_METHOD[:svd])
|
||||
assert_equal(2, INVERSION_METHOD[:svd_sym])
|
||||
assert_equal(2, INVERSION_METHOD[:svd_symmetric])
|
||||
|
||||
# Flags for DFT and DCT
|
||||
assert_equal(0, DXT_FLAG[:forward])
|
||||
assert_equal(1, DXT_FLAG[:inverse])
|
||||
assert_equal(2, DXT_FLAG[:scale])
|
||||
assert_equal(4, DXT_FLAG[:rows])
|
||||
|
||||
# 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])
|
||||
|
||||
# Anti aliasing flags
|
||||
assert_equal(16, CONNECTIVITY[:aa])
|
||||
assert_equal(16, CONNECTIVITY[:anti_alias])
|
||||
|
||||
# Retrieval modes
|
||||
assert_equal(0, RETRIEVAL_MODE[:external])
|
||||
assert_equal(1, RETRIEVAL_MODE[:list])
|
||||
assert_equal(2, RETRIEVAL_MODE[:ccomp])
|
||||
assert_equal(3, RETRIEVAL_MODE[:tree])
|
||||
|
||||
# Approximation methods
|
||||
assert_equal(0, APPROX_CHAIN_METHOD[:code])
|
||||
assert_equal(1, APPROX_CHAIN_METHOD[:approx_none])
|
||||
assert_equal(2, APPROX_CHAIN_METHOD[:approx_simple])
|
||||
assert_equal(3, APPROX_CHAIN_METHOD[:approx_tc89_l1])
|
||||
assert_equal(4, APPROX_CHAIN_METHOD[:approx_tc89_kcos])
|
||||
|
||||
# Approximation methods (polygon)
|
||||
assert_equal(0, APPROX_POLY_METHOD[:dp])
|
||||
|
||||
# Match template methods
|
||||
assert_equal(0, MATCH_TEMPLATE_METHOD[:sqdiff])
|
||||
assert_equal(1, MATCH_TEMPLATE_METHOD[:sqdiff_normed])
|
||||
assert_equal(2, MATCH_TEMPLATE_METHOD[:ccorr])
|
||||
assert_equal(3, MATCH_TEMPLATE_METHOD[:ccorr_normed])
|
||||
assert_equal(4, MATCH_TEMPLATE_METHOD[:ccoeff])
|
||||
assert_equal(5, MATCH_TEMPLATE_METHOD[:ccoeff_normed])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue