mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
added error handling to some methods (2)
Added error handlings to the methods of following classes or modules -CvPoint2D32f -CvPoint3D32f -CvRect -CvScalar -CvSeq -CvSize -CvSize2D32f -CvSlice -CvSURFParams -CvSURFPoint -CvTermCriteria -CvTwoPoints -CvUtils -CvVideoWriter -GUI -IplConvKernel -IplImage -MouseEvent -OpenCV -Trackbar -Window
This commit is contained in:
parent
ea55e0d42e
commit
b3016fc68c
31 changed files with 407 additions and 245 deletions
|
@ -103,23 +103,19 @@ rb_allocate(VALUE klass)
|
|||
VALUE
|
||||
rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE obj, x, y;
|
||||
CvSize2D32f *self_ptr = CVSIZE2D32F(self);
|
||||
switch(argc){
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
obj = argv[0];
|
||||
if(rb_compatible_q(rb_klass, obj)){
|
||||
CVSIZE2D32F(self)->width = NUM2DBL(rb_funcall(rb_funcall(obj, rb_intern("width"), 0), rb_intern("to_f"), 0));
|
||||
CVSIZE2D32F(self)->height = NUM2DBL(rb_funcall(rb_funcall(obj, rb_intern("height"), 0), rb_intern("to_f"), 0));
|
||||
}else{
|
||||
rb_raise(rb_eArgError, "object is not compatible %s.", rb_class2name(rb_klass));
|
||||
}
|
||||
case 1: {
|
||||
CvSize2D32f size = VALUE_TO_CVSIZE2D32F(argv[0]);
|
||||
self_ptr->width = size.width;
|
||||
self_ptr->height = size.height;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
x = argv[0], y = argv[1];
|
||||
CVSIZE2D32F(self)->width = NUM2DBL(x);
|
||||
CVSIZE2D32F(self)->height = NUM2DBL(y);
|
||||
self_ptr->width = NUM2DBL(argv[0]);
|
||||
self_ptr->height = NUM2DBL(argv[1]);
|
||||
break;
|
||||
default:
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue