mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
added type check to some CvMat methods (8)
This commit is contained in:
parent
c003ee81f0
commit
46227b7fa1
8 changed files with 133 additions and 112 deletions
|
@ -4749,16 +4749,14 @@ rb_match_template(int argc, VALUE *argv, VALUE self)
|
||||||
else
|
else
|
||||||
method_flag = CVMETHOD("MATCH_TEMPLATE_METHOD", method);
|
method_flag = CVMETHOD("MATCH_TEMPLATE_METHOD", method);
|
||||||
|
|
||||||
if (!(rb_obj_is_kind_of(templ, cCvMat::rb_class())))
|
CvArr* self_ptr = CVARR(self);
|
||||||
rb_raise(rb_eTypeError, "argument 1 (template) should be %s.", rb_class2name(cCvMat::rb_class()));
|
CvMat* templ_ptr = CVMAT_WITH_CHECK(templ);
|
||||||
if (cvGetElemType(CVARR(self)) != cvGetElemType(CVARR(templ)))
|
CvSize src_size = cvGetSize(self_ptr);
|
||||||
rb_raise(rb_eTypeError, "template should be same type of self.");
|
CvSize template_size = cvGetSize(templ_ptr);
|
||||||
CvSize src_size = cvGetSize(CVARR(self));
|
|
||||||
CvSize template_size = cvGetSize(CVARR(templ));
|
|
||||||
result = cCvMat::new_object(src_size.height - template_size.height + 1,
|
result = cCvMat::new_object(src_size.height - template_size.height + 1,
|
||||||
src_size.width - template_size.width + 1,
|
src_size.width - template_size.width + 1,
|
||||||
CV_32FC1);
|
CV_32FC1);
|
||||||
cvMatchTemplate(CVARR(self), CVARR(templ), CVARR(result), method_flag);
|
cvMatchTemplate(self_ptr, templ_ptr, CVARR(result), method_flag);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4875,7 +4873,8 @@ rb_cam_shift(VALUE self, VALUE window, VALUE criteria)
|
||||||
VALUE comp, box;
|
VALUE comp, box;
|
||||||
comp = cCvConnectedComp::new_object();
|
comp = cCvConnectedComp::new_object();
|
||||||
box = cCvBox2D::new_object();
|
box = cCvBox2D::new_object();
|
||||||
cvCamShift(CVARR(self), VALUE_TO_CVRECT(window), VALUE_TO_CVTERMCRITERIA(criteria), CVCONNECTEDCOMP(comp), CVBOX2D(box));
|
cvCamShift(CVARR(self), VALUE_TO_CVRECT(window), VALUE_TO_CVTERMCRITERIA(criteria),
|
||||||
|
CVCONNECTEDCOMP(comp), CVBOX2D(box));
|
||||||
return rb_ary_new3(2, comp, box);
|
return rb_ary_new3(2, comp, box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4989,18 +4988,19 @@ rb_optical_flow_hs(int argc, VALUE *argv, VALUE self)
|
||||||
int use_previous = 0;
|
int use_previous = 0;
|
||||||
rb_scan_args(argc, argv, "13", &prev, &velx, &vely, &options);
|
rb_scan_args(argc, argv, "13", &prev, &velx, &vely, &options);
|
||||||
options = OPTICAL_FLOW_HS_OPTION(options);
|
options = OPTICAL_FLOW_HS_OPTION(options);
|
||||||
if (!rb_obj_is_kind_of(prev, cCvMat::rb_class()))
|
CvMat *velx_ptr, *vely_ptr;
|
||||||
rb_raise(rb_eTypeError, "argument 1 (previous image) should be %s", rb_class2name(cCvMat::rb_class()));
|
|
||||||
if (NIL_P(velx) && NIL_P(vely)) {
|
if (NIL_P(velx) && NIL_P(vely)) {
|
||||||
velx = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
velx = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
||||||
vely = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
vely = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
||||||
} else {
|
velx_ptr = CVMAT(velx);
|
||||||
if (rb_obj_is_kind_of(velx, cCvMat::rb_class()) && rb_obj_is_kind_of(vely, cCvMat::rb_class()))
|
vely_ptr = CVMAT(vely);
|
||||||
use_previous = 1;
|
|
||||||
else
|
|
||||||
rb_raise(rb_eArgError, "Necessary to give both argument 2(previous velocity field x) and argument 3(previous velocity field y)");
|
|
||||||
}
|
}
|
||||||
cvCalcOpticalFlowHS(CVARR(prev), CVARR(self), use_previous, CVARR(velx), CVARR(vely),
|
else {
|
||||||
|
use_previous = 1;
|
||||||
|
velx_ptr = CVMAT_WITH_CHECK(velx);
|
||||||
|
vely_ptr = CVMAT_WITH_CHECK(vely);
|
||||||
|
}
|
||||||
|
cvCalcOpticalFlowHS(CVMAT_WITH_CHECK(prev), CVARR(self), use_previous, velx_ptr, vely_ptr,
|
||||||
HS_LAMBDA(options), HS_CRITERIA(options));
|
HS_LAMBDA(options), HS_CRITERIA(options));
|
||||||
return rb_ary_new3(2, velx, vely);
|
return rb_ary_new3(2, velx, vely);
|
||||||
}
|
}
|
||||||
|
@ -5019,11 +5019,10 @@ rb_optical_flow_lk(VALUE self, VALUE prev, VALUE win_size)
|
||||||
{
|
{
|
||||||
SUPPORT_8UC1_ONLY(self);
|
SUPPORT_8UC1_ONLY(self);
|
||||||
VALUE velx, vely;
|
VALUE velx, vely;
|
||||||
if (!rb_obj_is_kind_of(prev, cCvMat::rb_class()))
|
|
||||||
rb_raise(rb_eTypeError, "argument 1 (previous image) should be %s", rb_class2name(cCvMat::rb_class()));
|
|
||||||
velx = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
velx = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
||||||
vely = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
vely = cCvMat::new_object(cvGetSize(CVARR(self)), CV_MAKETYPE(CV_32F, 1));
|
||||||
cvCalcOpticalFlowLK(CVARR(prev), CVARR(self), VALUE_TO_CVSIZE(win_size), CVARR(velx), CVARR(vely));
|
cvCalcOpticalFlowLK(CVMAT_WITH_CHECK(prev), CVARR(self), VALUE_TO_CVSIZE(win_size),
|
||||||
|
CVARR(velx), CVARR(vely));
|
||||||
return rb_ary_new3(2, velx, vely);
|
return rb_ary_new3(2, velx, vely);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5059,26 +5058,29 @@ rb_optical_flow_bm(int argc, VALUE *argv, VALUE self)
|
||||||
int use_previous = 0;
|
int use_previous = 0;
|
||||||
rb_scan_args(argc, argv, "13", &prev, &velx, &vely, &options);
|
rb_scan_args(argc, argv, "13", &prev, &velx, &vely, &options);
|
||||||
options = OPTICAL_FLOW_BM_OPTION(options);
|
options = OPTICAL_FLOW_BM_OPTION(options);
|
||||||
|
CvArr* self_ptr = CVARR(self);
|
||||||
CvSize
|
CvSize
|
||||||
image_size = cvGetSize(CVARR(self)),
|
image_size = cvGetSize(self_ptr),
|
||||||
block_size = BM_BLOCK_SIZE(options),
|
block_size = BM_BLOCK_SIZE(options),
|
||||||
shift_size = BM_SHIFT_SIZE(options),
|
shift_size = BM_SHIFT_SIZE(options),
|
||||||
max_range = BM_MAX_RANGE(options),
|
max_range = BM_MAX_RANGE(options),
|
||||||
velocity_size = cvSize((image_size.width - block_size.width) / shift_size.width,
|
velocity_size = cvSize((image_size.width - block_size.width) / shift_size.width,
|
||||||
(image_size.height - block_size.height) / shift_size.height);
|
(image_size.height - block_size.height) / shift_size.height);
|
||||||
|
CvMat *velx_ptr, *vely_ptr;
|
||||||
if (NIL_P(velx) && NIL_P(vely)) {
|
if (NIL_P(velx) && NIL_P(vely)) {
|
||||||
velx = cCvMat::new_object(velocity_size, CV_MAKETYPE(CV_32F, 1));
|
velx = cCvMat::new_object(velocity_size, CV_MAKETYPE(CV_32F, 1));
|
||||||
vely = cCvMat::new_object(velocity_size, CV_MAKETYPE(CV_32F, 1));
|
vely = cCvMat::new_object(velocity_size, CV_MAKETYPE(CV_32F, 1));
|
||||||
|
velx_ptr = CVMAT(velx);
|
||||||
|
vely_ptr = CVMAT(vely);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (rb_obj_is_kind_of(velx, cCvMat::rb_class()) && rb_obj_is_kind_of(vely, cCvMat::rb_class()))
|
|
||||||
use_previous = 1;
|
use_previous = 1;
|
||||||
else
|
velx_ptr = CVMAT_WITH_CHECK(velx);
|
||||||
rb_raise(rb_eArgError, "Necessary to give both argument 2(previous velocity field x) and argument 3(previous velocity field y)");
|
vely_ptr = CVMAT_WITH_CHECK(vely);
|
||||||
}
|
}
|
||||||
cvCalcOpticalFlowBM(CVARR(prev), CVARR(self),
|
cvCalcOpticalFlowBM(CVMAT_WITH_CHECK(prev), self_ptr,
|
||||||
block_size, shift_size, max_range, use_previous,
|
block_size, shift_size, max_range, use_previous,
|
||||||
CVARR(velx), CVARR(vely));
|
velx_ptr, vely_ptr);
|
||||||
return rb_ary_new3(2, velx, vely);
|
return rb_ary_new3(2, velx, vely);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5281,7 +5283,7 @@ rb_compute_correspond_epilines(VALUE klass, VALUE points, VALUE which_image, VAL
|
||||||
rb_raise(rb_eArgError, "input points should 2xN, Nx2 or 3xN, Nx3 matrix(N >= 7).");
|
rb_raise(rb_eArgError, "input points should 2xN, Nx2 or 3xN, Nx3 matrix(N >= 7).");
|
||||||
|
|
||||||
correspondent_lines = cCvMat::new_object(n, 3, CV_MAT_DEPTH(points_ptr->type));
|
correspondent_lines = cCvMat::new_object(n, 3, CV_MAT_DEPTH(points_ptr->type));
|
||||||
cvComputeCorrespondEpilines(points_ptr, FIX2INT(which_image), CVMAT_WITH_CHECK(fundamental_matrix),
|
cvComputeCorrespondEpilines(points_ptr, NUM2INT(which_image), CVMAT_WITH_CHECK(fundamental_matrix),
|
||||||
CVMAT(correspondent_lines));
|
CVMAT(correspondent_lines));
|
||||||
return correspondent_lines;
|
return correspondent_lines;
|
||||||
}
|
}
|
||||||
|
@ -5302,35 +5304,10 @@ rb_extract_surf(int argc, VALUE *argv, VALUE self)
|
||||||
rb_scan_args(argc, argv, "12", &_params, &_mask, &_keypoints);
|
rb_scan_args(argc, argv, "12", &_params, &_mask, &_keypoints);
|
||||||
|
|
||||||
// Prepare arguments
|
// Prepare arguments
|
||||||
if (!rb_obj_is_kind_of(_params, cCvSURFParams::rb_class())) {
|
CvSURFParams params = *CVSURFPARAMS_WITH_CHECK(_params);
|
||||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
|
CvMat* mask = MASK(_mask);
|
||||||
rb_class2name(CLASS_OF(_params)), rb_class2name(cCvSURFParams::rb_class()));
|
CvSeq* keypoints = NIL_P(_keypoints) ? NULL : CVSEQ_WITH_CHECK(_keypoints);
|
||||||
}
|
|
||||||
CvSURFParams params = *CVSURFPARAMS(_params);
|
|
||||||
CvMat* mask;
|
|
||||||
if (NIL_P(_mask))
|
|
||||||
mask = NULL;
|
|
||||||
else {
|
|
||||||
if (!rb_obj_is_kind_of(_mask, cCvMat::rb_class())) {
|
|
||||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
||||||
rb_class2name(CLASS_OF(_mask)), rb_class2name(cCvMat::rb_class()));
|
|
||||||
}
|
|
||||||
mask = CVMAT(_mask);
|
|
||||||
}
|
|
||||||
CvSeq* keypoints;
|
|
||||||
if (NIL_P(_keypoints)) {
|
|
||||||
keypoints = NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!rb_obj_is_kind_of(_keypoints, cCvSeq::rb_class())) {
|
|
||||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
|
|
||||||
rb_class2name(CLASS_OF(_keypoints)), rb_class2name(cCvSeq::rb_class()));
|
|
||||||
}
|
|
||||||
keypoints = CVSEQ(_keypoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
int use_provided = (keypoints == NULL) ? 0 : 1;
|
int use_provided = (keypoints == NULL) ? 0 : 1;
|
||||||
|
|
||||||
VALUE storage = cCvMemStorage::new_object();
|
VALUE storage = cCvMemStorage::new_object();
|
||||||
CvSeq* descriptors = NULL;
|
CvSeq* descriptors = NULL;
|
||||||
|
|
||||||
|
@ -5343,11 +5320,10 @@ rb_extract_surf(int argc, VALUE *argv, VALUE self)
|
||||||
const int DIM_SIZE = (params.extended) ? 128 : 64;
|
const int DIM_SIZE = (params.extended) ? 128 : 64;
|
||||||
const int NUM_KEYPOINTS = keypoints->total;
|
const int NUM_KEYPOINTS = keypoints->total;
|
||||||
VALUE _descriptors = rb_ary_new2(NUM_KEYPOINTS);
|
VALUE _descriptors = rb_ary_new2(NUM_KEYPOINTS);
|
||||||
int m, n;
|
for (int m = 0; m < NUM_KEYPOINTS; ++m) {
|
||||||
for (m = 0; m < NUM_KEYPOINTS; ++m) {
|
|
||||||
VALUE elem = rb_ary_new2(DIM_SIZE);
|
VALUE elem = rb_ary_new2(DIM_SIZE);
|
||||||
float *descriptor = (float*)cvGetSeqElem(descriptors, m);
|
float *descriptor = (float*)cvGetSeqElem(descriptors, m);
|
||||||
for (n = 0; n < DIM_SIZE; ++n) {
|
for (int n = 0; n < DIM_SIZE; ++n) {
|
||||||
rb_ary_store(elem, n, rb_float_new(descriptor[n]));
|
rb_ary_store(elem, n, rb_float_new(descriptor[n]));
|
||||||
}
|
}
|
||||||
rb_ary_store(_descriptors, m, elem);
|
rb_ary_store(_descriptors, m, elem);
|
||||||
|
|
|
@ -299,12 +299,14 @@ MASK(VALUE object)
|
||||||
{
|
{
|
||||||
if (NIL_P(object))
|
if (NIL_P(object))
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (rb_obj_is_kind_of(object, cCvMat::rb_class()) &&
|
else {
|
||||||
CV_MAT_DEPTH(CVMAT(object)->type) == CV_8UC1 &&
|
CvMat* obj_ptr = CVMAT_WITH_CHECK(object);
|
||||||
CV_MAT_CN(CVMAT(object)->type) == 1)
|
if (CV_MAT_DEPTH(obj_ptr->type) == CV_8UC1 &&
|
||||||
return CVMAT(object);
|
CV_MAT_CN(obj_ptr->type) == 1)
|
||||||
|
return obj_ptr;
|
||||||
else
|
else
|
||||||
rb_raise(rb_eTypeError, "object is not a mask.");
|
rb_raise(rb_eTypeError, "Mask should be 8bit 1-channel matrix.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__NAMESPACE_END_OPENCV
|
__NAMESPACE_END_OPENCV
|
||||||
|
|
|
@ -62,6 +62,14 @@ CVSEQ(VALUE object)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CvSeq*
|
||||||
|
CVSEQ_WITH_CHECK(VALUE object)
|
||||||
|
{
|
||||||
|
if (!rb_obj_is_kind_of(object, cCvSeq::rb_class()))
|
||||||
|
raise_typeerror(object, cCvSeq::rb_class());
|
||||||
|
return CVSEQ(object);
|
||||||
|
}
|
||||||
|
|
||||||
__NAMESPACE_END_OPENCV
|
__NAMESPACE_END_OPENCV
|
||||||
|
|
||||||
#endif // RUBY_OPENCV_CVSEQ_H
|
#endif // RUBY_OPENCV_CVSEQ_H
|
||||||
|
|
|
@ -45,6 +45,14 @@ CVSURFPARAMS(VALUE object)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CvSURFParams*
|
||||||
|
CVSURFPARAMS_WITH_CHECK(VALUE object)
|
||||||
|
{
|
||||||
|
if (!rb_obj_is_kind_of(object, cCvSURFParams::rb_class()))
|
||||||
|
raise_typeerror(object, cCvSURFParams::rb_class());
|
||||||
|
return CVSURFPARAMS(object);
|
||||||
|
}
|
||||||
|
|
||||||
__NAMESPACE_END_OPENCV
|
__NAMESPACE_END_OPENCV
|
||||||
|
|
||||||
#endif // RUBY_OPENCV_CVSURFPARAMS_H
|
#endif // RUBY_OPENCV_CVSURFPARAMS_H
|
||||||
|
|
|
@ -261,16 +261,9 @@ CVMETHOD(const char *name, VALUE method, int ifnone = 0)
|
||||||
method = rb_str_intern(method);
|
method = rb_str_intern(method);
|
||||||
case T_SYMBOL:
|
case T_SYMBOL:
|
||||||
value = rb_hash_aref(rb_const_get(rb_module_opencv(), rb_intern(name)), method);
|
value = rb_hash_aref(rb_const_get(rb_module_opencv(), rb_intern(name)), method);
|
||||||
if (NIL_P(value)) {
|
return NIL_P(value) ? ifnone : FIX2INT(value);
|
||||||
rb_warn("invalid opencv method type (see OpenCV::%s)", name);
|
|
||||||
return ifnone;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return FIX2INT(value);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
|
raise_typeerror(method, rb_cSymbol);
|
||||||
rb_class2name(CLASS_OF(method)), rb_class2name(rb_cSymbol));
|
|
||||||
}
|
}
|
||||||
return ifnone;
|
return ifnone;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,26 +179,33 @@ CVPOINTS_FROM_POINT_SET(VALUE object, CvPoint **pointset)
|
||||||
VALUE storage;
|
VALUE storage;
|
||||||
CvSeq *seq = 0;
|
CvSeq *seq = 0;
|
||||||
CvPoint2D32f p32;
|
CvPoint2D32f p32;
|
||||||
if(rb_obj_is_kind_of(object, cCvSeq::rb_class())){
|
if (rb_obj_is_kind_of(object, cCvSeq::rb_class())) {
|
||||||
if(CV_IS_SEQ_POINT_SET(CVSEQ(object))){
|
if (CV_IS_SEQ_POINT_SET(CVSEQ(object))) {
|
||||||
*pointset = (CvPoint*)cvCvtSeqToArray(CVSEQ(object),
|
*pointset = (CvPoint*)cvCvtSeqToArray(CVSEQ(object),
|
||||||
rb_cvAlloc(CVSEQ(object)->total * CVSEQ(object)->elem_size));
|
rb_cvAlloc(CVSEQ(object)->total * CVSEQ(object)->elem_size));
|
||||||
return CVSEQ(object)->total;
|
return CVSEQ(object)->total;
|
||||||
}else{
|
}
|
||||||
rb_raise(rb_eTypeError, "sequence is not contain %s or %s.",
|
else {
|
||||||
|
rb_raise(rb_eTypeError, "sequence does not contain %s or %s.",
|
||||||
rb_class2name(cCvPoint::rb_class()), rb_class2name(cCvPoint2D32f::rb_class()));
|
rb_class2name(cCvPoint::rb_class()), rb_class2name(cCvPoint2D32f::rb_class()));
|
||||||
}
|
}
|
||||||
}else if(rb_obj_is_kind_of(object, cCvMat::rb_class())){
|
}
|
||||||
|
else if (rb_obj_is_kind_of(object, cCvMat::rb_class())) {
|
||||||
/* to do */
|
/* to do */
|
||||||
rb_raise(rb_eNotImpError, "CvMat to CvSeq conversion not implemented.");
|
rb_raise(rb_eNotImpError, "CvMat to CvSeq conversion not implemented.");
|
||||||
}else if(rb_obj_is_kind_of(object, rb_cArray)){
|
|
||||||
*pointset = (CvPoint*)rb_cvAlloc(RARRAY_LEN(object) * sizeof(CvPoint));
|
|
||||||
for(int i = 0; i < RARRAY_LEN(object); i++){
|
|
||||||
(*pointset)[i].x = NUM2INT(rb_funcall(rb_ary_entry(object, i), rb_intern("x"), 0));
|
|
||||||
(*pointset)[i].y = NUM2INT(rb_funcall(rb_ary_entry(object, i), rb_intern("y"), 0));
|
|
||||||
}
|
}
|
||||||
return RARRAY_LEN(object);
|
else if (rb_obj_is_kind_of(object, rb_cArray)) {
|
||||||
}else{
|
int len = RARRAY_LEN(object);
|
||||||
|
*pointset = (CvPoint*)rb_cvAlloc(len * sizeof(CvPoint));
|
||||||
|
ID id_x = rb_intern("x");
|
||||||
|
ID id_y = rb_intern("y");
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
(*pointset)[i].x = NUM2INT(rb_funcall(rb_ary_entry(object, i), id_x, 0));
|
||||||
|
(*pointset)[i].y = NUM2INT(rb_funcall(rb_ary_entry(object, i), id_y, 0));
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
else {
|
||||||
rb_raise(rb_eTypeError, "Can't convert CvSeq(PointSet).");
|
rb_raise(rb_eTypeError, "Can't convert CvSeq(PointSet).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2823,10 +2823,12 @@ class TestCvMat < OpenCVTestCase
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
CvMat.compute_correspond_epilines(DUMMY_OBJ, 1, f_mat)
|
CvMat.compute_correspond_epilines(DUMMY_OBJ, 1, f_mat)
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
CvMat.compute_correspond_epilines(mat1, DUMMY_OBJ, f_mat)
|
||||||
|
}
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
CvMat.compute_correspond_epilines(mat1, 1, DUMMY_OBJ)
|
CvMat.compute_correspond_epilines(mat1, 1, DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
CvMat.compute_correspond_epilines(mat1, DUMMY_OBJ, f_mat)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1841,6 +1841,14 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
# pt2 = CvPoint.new(pt1.x + templ.width, pt1.y + templ.height)
|
# pt2 = CvPoint.new(pt1.x + templ.width, pt1.y + templ.height)
|
||||||
# mat.rectangle!(pt1, pt2, :color => CvColor::Black, :thickness => 3)
|
# mat.rectangle!(pt1, pt2, :color => CvColor::Black, :thickness => 3)
|
||||||
# snap mat, templ, result
|
# snap mat, templ, result
|
||||||
|
|
||||||
|
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.match_template(DUMMY_OBJ)
|
||||||
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.match_template(templ, DUMMY_OBJ)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_match_shapes
|
def test_match_shapes
|
||||||
|
@ -1954,8 +1962,24 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
|
|
||||||
# raise error
|
# raise error
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
mat.snake_image(points, alpha, arr_beta, gamma, size, term_criteria)
|
mat.snake_image(DUMMY_OBJ, arr_alpha, arr_beta, arr_gamma, size, term_criteria)
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.snake_image(points, DUMMY_OBJ, arr_beta, arr_gamma, size, term_criteria)
|
||||||
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.snake_image(points, arr_alpha, DUMMY_OBJ, arr_gamma, size, term_criteria)
|
||||||
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.snake_image(points, arr_alpha, arr_beta, DUMMY_OBJ, size, term_criteria)
|
||||||
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.snake_image(points, arr_alpha, arr_beta, arr_gamma, DUMMY_OBJ, term_criteria)
|
||||||
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
mat.snake_image(points, arr_alpha, arr_beta, arr_gamma, size, DUMMY_OBJ)
|
||||||
|
}
|
||||||
|
mat.snake_image(points, arr_alpha, arr_beta, arr_gamma, size, term_criteria, DUMMY_OBJ)
|
||||||
|
|
||||||
assert_raise(ArgumentError) {
|
assert_raise(ArgumentError) {
|
||||||
mat.snake_image(points, arr_alpha[0 .. num_points / 2], arr_beta, arr_gamma, size, term_criteria)
|
mat.snake_image(points, arr_alpha[0 .. num_points / 2], arr_beta, arr_gamma, size, term_criteria)
|
||||||
|
@ -2007,19 +2031,16 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
assert_equal('da33e266aece70ed69dcf074acd8fd4e', hash_img(vely))
|
assert_equal('da33e266aece70ed69dcf074acd8fd4e', hash_img(vely))
|
||||||
|
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
curr.optical_flow_hs('foobar')
|
curr.optical_flow_hs(DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
assert_raise(ArgumentError) {
|
curr.optical_flow_hs(prev, DUMMY_OBJ, prev_vely)
|
||||||
curr.optical_flow_hs(prev, 'foo', prev_vely)
|
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
assert_raise(ArgumentError) {
|
curr.optical_flow_hs(prev, prev_velx, DUMMY_OBJ)
|
||||||
curr.optical_flow_hs(prev, prev_velx, 'bar')
|
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
assert_raise(ArgumentError) {
|
curr.optical_flow_hs(prev, prev_velx, prev_vely, DUMMY_OBJ)
|
||||||
curr.optical_flow_hs(prev, 'foo', 'bar')
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2049,7 +2070,10 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
assert_equal('e7524c292e95e374fdb588f0b516938e', hash_img(vely))
|
assert_equal('e7524c292e95e374fdb588f0b516938e', hash_img(vely))
|
||||||
|
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
curr.optical_flow_lk('foobar', CvSize.new(3, 3))
|
curr.optical_flow_lk(DUMMY_OBJ, CvSize.new(3, 3))
|
||||||
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
curr.optical_flow_lk(prev, DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2094,16 +2118,17 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
assert_equal('6ad6b7a5c935379c0df4b9ec5666f3de', hash_img(velx))
|
assert_equal('6ad6b7a5c935379c0df4b9ec5666f3de', hash_img(velx))
|
||||||
assert_equal('b317b0b9d4fdb0e5cd40beb0dd4143b4', hash_img(vely))
|
assert_equal('b317b0b9d4fdb0e5cd40beb0dd4143b4', hash_img(vely))
|
||||||
|
|
||||||
assert_raise(ArgumentError) {
|
assert_raise(TypeError) {
|
||||||
curr.optical_flow_bm(prev, 'foo', prev_vely)
|
curr.optical_flow_bm(DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
assert_raise(ArgumentError) {
|
curr.optical_flow_bm(prev, DUMMY_OBJ, prev_vely)
|
||||||
curr.optical_flow_bm(prev, prev_velx, 'bar')
|
|
||||||
}
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
assert_raise(ArgumentError) {
|
curr.optical_flow_bm(prev, prev_velx, DUMMY_OBJ)
|
||||||
curr.optical_flow_bm(prev, 'foo', 'bar')
|
}
|
||||||
|
assert_raise(TypeError) {
|
||||||
|
curr.optical_flow_bm(prev, prev_velx, prev_vely, DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2144,13 +2169,13 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
|
|
||||||
# raise exceptions because of invalid arguments
|
# raise exceptions because of invalid arguments
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
mat0.extract_surf(CvMat.new(1, 1, :cv8u))
|
mat0.extract_surf(DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
mat0.extract_surf(CvSURFParams.new(500), 'foobar')
|
mat0.extract_surf(CvSURFParams.new(500), DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
mat0.extract_surf(CvSURFParams.new(500), mask, mat0)
|
mat0.extract_surf(CvSURFParams.new(500), mask, DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
|
|
||||||
## Uncomment the following lines to show the result
|
## Uncomment the following lines to show the result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue