/* * call-seq: * CvCapture.open(<i>[dev = -1]</i>) * * Reading video stream from the specified file or camera device. * If <i>dev</i> is string (i.e "stream.avi"), reading video stream from file. * If <i>dev</i> is number or symbol(include CvCapture::INTERFACE), * reading video stream from camera. * Currently two camera interfaces can be used on Windows: * * Video for Windows(VFW) * * Matrox Imaging Library(MIL) * and two on Linux * * V4L * * FireWire(IEEE1394). * If there is only one camera or it does not matter what camera to use <i>nil</i> may be passed. */ VALUE rb_open(int argc, VALUE *argv, VALUE self) { VALUE device, i; rb_scan_args(argc, argv, "01", &device); CvCapture *capture = 0; switch (TYPE(device)) { case T_STRING: capture = cvCaptureFromFile(StringValueCStr(device)); break; case T_FIXNUM: capture = cvCaptureFromCAM(FIX2INT(device)); break; case T_SYMBOL: i = rb_hash_aref(rb_const_get(rb_class(), rb_intern("INTERFACE")), device); if (NIL_P(i)) rb_raise(rb_eArgError, "undefined interface."); capture = cvCaptureFromCAM(NUM2INT(i)); break; case T_NIL: capture = cvCaptureFromCAM(CV_CAP_ANY); break; } if (!capture) rb_raise(rb_eStandardError, "Invalid capture format."); return Data_Wrap_Struct(rb_klass, 0, free, capture); }
VALUE new_object(CvArr *arr, int is_binary = 0) { VALUE object = rb_allocate(rb_class()); cvMoments(arr, CVMOMENTS(object), is_binary); return object; }
/* * call-seq: * CvCapture.open(<i>[dev = -1]</i>) * * Reading video stream from the specified file or camera device. * If <i>dev</i> is string (i.e "stream.avi"), reading video stream from file. * If <i>dev</i> is number or symbol(include CvCapture::INTERFACE), * reading video stream from camera. * Currently two camera interfaces can be used on Windows: * * Video for Windows(VFW) * * Matrox Imaging Library(MIL) * and two on Linux * * V4L * * FireWire(IEEE1394). * If there is only one camera or it does not matter what camera to use <i>nil</i> may be passed. */ VALUE rb_open(int argc, VALUE *argv, VALUE self) { VALUE device; rb_scan_args(argc, argv, "01", &device); CvCapture *capture = 0; try { switch (TYPE(device)) { case T_STRING: capture = cvCaptureFromFile(StringValueCStr(device)); break; case T_FIXNUM: capture = cvCaptureFromCAM(FIX2INT(device)); break; case T_SYMBOL: { VALUE cap_index = rb_hash_lookup(rb_const_get(rb_class(), rb_intern("INTERFACE")), device); if (NIL_P(cap_index)) rb_raise(rb_eArgError, "undefined interface."); capture = cvCaptureFromCAM(NUM2INT(cap_index)); break; } case T_NIL: capture = cvCaptureFromCAM(CV_CAP_ANY); break; } } catch (cv::Exception& e) { raise_cverror(e); } if (!capture) rb_raise(rb_eStandardError, "Invalid capture format."); return Data_Wrap_Struct(rb_klass, 0, cvcapture_free, capture); }
VALUE new_object(int event, int x, int y, int flags) { VALUE object = rb_allocate(rb_class()); MouseEvent *mouseevent = MOUSEEVENT(object); mouseevent->point.x = x; mouseevent->point.y = y; mouseevent->event = event; mouseevent->flags = flags; return object; }