mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
modified some functions
This commit is contained in:
parent
76289fa9ea
commit
ecca9a0d66
2 changed files with 10 additions and 6 deletions
|
@ -468,7 +468,7 @@ rb_load_imageM(int argc, VALUE *argv, VALUE self)
|
|||
Check_Type(filename, T_STRING);
|
||||
|
||||
int _iscolor;
|
||||
if (TYPE(iscolor) == T_NIL) {
|
||||
if (NIL_P(iscolor)) {
|
||||
_iscolor = CV_LOAD_IMAGE_COLOR;
|
||||
}
|
||||
else {
|
||||
|
@ -552,9 +552,11 @@ rb_inside_q(VALUE self, VALUE object)
|
|||
if (cCvRect::rb_compatible_q(cCvRect::rb_class(), object)) {
|
||||
int width = NUM2INT(rb_funcall(object, rb_intern("width"), 0));
|
||||
int height = NUM2INT(rb_funcall(object, rb_intern("height"), 0));
|
||||
return x >= 0 && y >= 0 && x < mat->width && x + width < mat->width && y < mat->height && y + height < mat->height ? Qtrue : Qfalse;
|
||||
} else {
|
||||
return x >= 0 && y >= 0 && x < mat->width && y < mat->height ? Qtrue : Qfalse;
|
||||
return (x >= 0) && (y >= 0) && (x < mat->width) && ((x + width) < mat->width)
|
||||
&& (y < mat->height) && ((y + height) < mat->height) ? Qtrue : Qfalse;
|
||||
}
|
||||
else {
|
||||
return (x >= 0) && (y >= 0) && (x < mat->width) && (y < mat->height) ? Qtrue : Qfalse;
|
||||
}
|
||||
}
|
||||
rb_raise(rb_eArgError, "argument 1 should have method \"x\", \"y\"");
|
||||
|
@ -623,7 +625,8 @@ rb_height(VALUE self)
|
|||
VALUE
|
||||
rb_depth(VALUE self)
|
||||
{
|
||||
return rb_hash_aref(rb_funcall(rb_const_get(rb_module_opencv(), rb_intern("DEPTH")), rb_intern("invert"), 0), INT2FIX(CV_MAT_DEPTH(CVMAT(self)->type)));
|
||||
return rb_hash_aref(rb_funcall(rb_const_get(rb_module_opencv(), rb_intern("DEPTH")), rb_intern("invert"), 0),
|
||||
INT2FIX(CV_MAT_DEPTH(CVMAT(self)->type)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -113,7 +113,8 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
if (rb_compatible_q(rb_klass, obj)) {
|
||||
CVPOINT(self)->x = NUM2INT(rb_funcall(rb_funcall(obj, rb_intern("x"), 0), rb_intern("to_i"), 0));
|
||||
CVPOINT(self)->y = NUM2INT(rb_funcall(rb_funcall(obj, rb_intern("y"), 0), rb_intern("to_i"), 0));
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "object is not compatible %s.", rb_class2name(rb_klass));
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue