mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
added some methods to CvCapture to set some properties
This commit is contained in:
parent
6b2d038024
commit
bff95e942a
3 changed files with 231 additions and 108 deletions
|
@ -40,7 +40,8 @@ define_ruby_class()
|
|||
rb_klass = rb_define_class_under(opencv, "CvCapture", rb_cData);
|
||||
|
||||
VALUE video_interface = rb_hash_new();
|
||||
/* {:any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394, :stereo, :tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime}: video source */
|
||||
/* {:any, :mil, :vfw, :v4l, :v4l2, :fireware, :ieee1394, :dc1394, :cmu1394, :stereo,
|
||||
:tyzx, :tyzx_left, :tyzx_right, :tyzx_color, :tyzx_z, :qt, :qtuicktime}: video source */
|
||||
rb_define_const(rb_klass, "INTERFACE", video_interface);
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("any")), INT2FIX(CV_CAP_ANY));
|
||||
rb_hash_aset(video_interface, ID2SYM(rb_intern("mil")), INT2FIX(CV_CAP_MIL));
|
||||
|
@ -65,30 +66,37 @@ define_ruby_class()
|
|||
rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
|
||||
rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
|
||||
rb_define_method(rb_klass, "query", RUBY_METHOD_FUNC(rb_query), 0);
|
||||
rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_millisecond), 0);
|
||||
rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_frames), 0);
|
||||
rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_avi_ratio), 0);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_fps), 0);
|
||||
rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_fourcc), 0);
|
||||
rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_frame_count), 0);
|
||||
rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_format), 0);
|
||||
rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_mode), 0);
|
||||
rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_brightness), 0);
|
||||
rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_contrast), 0);
|
||||
rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_saturation), 0);
|
||||
rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_hue), 0);
|
||||
rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_gain), 0);
|
||||
rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_exposure), 0);
|
||||
rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_convert_rgb), 0);
|
||||
rb_define_method(rb_klass, "white_balance", RUBY_METHOD_FUNC(rb_white_balance), 0);
|
||||
rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_rectification), 0);
|
||||
rb_define_method(rb_klass, "millisecond", RUBY_METHOD_FUNC(rb_get_millisecond), 0);
|
||||
rb_define_method(rb_klass, "millisecond=", RUBY_METHOD_FUNC(rb_set_millisecond), 1);
|
||||
rb_define_method(rb_klass, "frames", RUBY_METHOD_FUNC(rb_get_frames), 0);
|
||||
rb_define_method(rb_klass, "frames=", RUBY_METHOD_FUNC(rb_set_frames), 1);
|
||||
rb_define_method(rb_klass, "avi_ratio", RUBY_METHOD_FUNC(rb_get_avi_ratio), 0);
|
||||
rb_define_method(rb_klass, "avi_ratio=", RUBY_METHOD_FUNC(rb_set_avi_ratio), 1);
|
||||
rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
|
||||
rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
|
||||
rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_get_width), 0);
|
||||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_get_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "fps", RUBY_METHOD_FUNC(rb_get_fps), 0);
|
||||
rb_define_method(rb_klass, "fps=", RUBY_METHOD_FUNC(rb_set_fps), 1);
|
||||
rb_define_method(rb_klass, "fourcc", RUBY_METHOD_FUNC(rb_get_fourcc), 0);
|
||||
rb_define_method(rb_klass, "frame_count", RUBY_METHOD_FUNC(rb_get_frame_count), 0);
|
||||
rb_define_method(rb_klass, "format", RUBY_METHOD_FUNC(rb_get_format), 0);
|
||||
rb_define_method(rb_klass, "mode", RUBY_METHOD_FUNC(rb_get_mode), 0);
|
||||
rb_define_method(rb_klass, "brightness", RUBY_METHOD_FUNC(rb_get_brightness), 0);
|
||||
rb_define_method(rb_klass, "contrast", RUBY_METHOD_FUNC(rb_get_contrast), 0);
|
||||
rb_define_method(rb_klass, "saturation", RUBY_METHOD_FUNC(rb_get_saturation), 0);
|
||||
rb_define_method(rb_klass, "hue", RUBY_METHOD_FUNC(rb_get_hue), 0);
|
||||
rb_define_method(rb_klass, "gain", RUBY_METHOD_FUNC(rb_get_gain), 0);
|
||||
rb_define_method(rb_klass, "exposure", RUBY_METHOD_FUNC(rb_get_exposure), 0);
|
||||
rb_define_method(rb_klass, "convert_rgb", RUBY_METHOD_FUNC(rb_get_convert_rgb), 0);
|
||||
rb_define_method(rb_klass, "white_balance", RUBY_METHOD_FUNC(rb_get_white_balance), 0);
|
||||
rb_define_method(rb_klass, "rectification", RUBY_METHOD_FUNC(rb_get_rectification), 0);
|
||||
}
|
||||
|
||||
void
|
||||
free(void *ptr)
|
||||
cvcapture_free(void *ptr)
|
||||
{
|
||||
if (ptr)
|
||||
cvReleaseCapture((CvCapture**)&ptr);
|
||||
|
@ -135,7 +143,7 @@ rb_open(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
if (!capture)
|
||||
rb_raise(rb_eStandardError, "Invalid capture format.");
|
||||
return Data_Wrap_Struct(rb_klass, 0, free, capture);
|
||||
return Data_Wrap_Struct(rb_klass, 0, cvcapture_free, capture);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,14 +175,13 @@ VALUE
|
|||
rb_retrieve(VALUE self)
|
||||
{
|
||||
IplImage *frame = cvRetrieveFrame(CVCAPTURE(self));
|
||||
if(!frame)
|
||||
if (!frame)
|
||||
return Qnil;
|
||||
VALUE image = cIplImage::new_object(cvSize(frame->width, frame->height), CV_MAKETYPE(CV_8U, frame->nChannels));
|
||||
if (frame->origin == IPL_ORIGIN_TL) {
|
||||
if (frame->origin == IPL_ORIGIN_TL)
|
||||
cvCopy(frame, CVARR(image));
|
||||
} else {
|
||||
else
|
||||
cvFlip(frame, CVARR(image));
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -188,87 +195,157 @@ VALUE
|
|||
rb_query(VALUE self)
|
||||
{
|
||||
IplImage *frame = cvQueryFrame(CVCAPTURE(self));
|
||||
if(!frame)
|
||||
if (!frame)
|
||||
return Qnil;
|
||||
VALUE image = cIplImage::new_object(cvSize(frame->width, frame->height), CV_MAKETYPE(CV_8U, frame->nChannels));
|
||||
if (frame->origin == IPL_ORIGIN_TL) {
|
||||
if (frame->origin == IPL_ORIGIN_TL)
|
||||
cvCopy(frame, CVARR(image));
|
||||
}
|
||||
else {
|
||||
else
|
||||
cvFlip(frame, CVARR(image));
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
* Film current position in milliseconds or video capture timestamp.
|
||||
* Get film current position in milliseconds or video capture timestamp.
|
||||
*/
|
||||
VALUE
|
||||
rb_millisecond(VALUE self)
|
||||
rb_get_millisecond(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_MSEC));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_MSEC));
|
||||
}
|
||||
|
||||
/*
|
||||
* 0-based index of the frame to be decoded/captured next
|
||||
* Set film current position in milliseconds or video capture timestamp.
|
||||
*/
|
||||
VALUE
|
||||
rb_frames(VALUE self)
|
||||
rb_set_millisecond(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_float_new(cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_MSEC, NUM2DBL(value)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get 0-based index of the frame to be decoded/captured next
|
||||
*/
|
||||
VALUE
|
||||
rb_get_frames(VALUE self)
|
||||
{
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_FRAMES));
|
||||
}
|
||||
|
||||
/*
|
||||
* Relative position of video file (0 - start of the film, 1 - end of the film)
|
||||
* Set 0-based index of the frame to be decoded/captured next
|
||||
*/
|
||||
VALUE
|
||||
rb_avi_ratio(VALUE self)
|
||||
rb_set_frames(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_AVI_RATIO));
|
||||
return rb_float_new(cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_FRAMES, NUM2DBL(value)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Size of frames in the video stream.
|
||||
* Get relative position of video file (0 - start of the film, 1 - end of the film)
|
||||
*/
|
||||
VALUE
|
||||
rb_size(VALUE self)
|
||||
rb_get_avi_ratio(VALUE self)
|
||||
{
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_AVI_RATIO));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set relative position of video file (0 - start of the film, 1 - end of the film)
|
||||
*/
|
||||
VALUE
|
||||
rb_set_avi_ratio(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_float_new(cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_POS_AVI_RATIO, NUM2DBL(value)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get size of frames in the video stream.
|
||||
*/
|
||||
VALUE
|
||||
rb_get_size(VALUE self)
|
||||
{
|
||||
return cCvSize::new_object(cvSize((int)cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_WIDTH),
|
||||
(int)cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_HEIGHT)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Width of frames in the video stream.
|
||||
* Set size of frames in the video stream.
|
||||
*/
|
||||
VALUE
|
||||
rb_width(VALUE self)
|
||||
rb_set_size(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_WIDTH));
|
||||
double result;
|
||||
if (cCvSize::rb_compatible_q(cCvSize::rb_class(), value)) {
|
||||
int width = NUM2INT(rb_funcall(value, rb_intern("width"), 0));
|
||||
int height = NUM2INT(rb_funcall(value, rb_intern("height"), 0));
|
||||
cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_WIDTH, width);
|
||||
result = cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_HEIGHT, height);
|
||||
}
|
||||
else
|
||||
rb_raise(rb_eTypeError, "require %s or compatible object.", rb_class2name(cCvSize::rb_class()));
|
||||
return DBL2NUM(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Height of frames in the video stream.
|
||||
* Get width of frames in the video stream.
|
||||
*/
|
||||
VALUE
|
||||
rb_height(VALUE self)
|
||||
rb_get_width(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_HEIGHT));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_WIDTH));
|
||||
}
|
||||
|
||||
/*
|
||||
* Frame rate
|
||||
* Set width of frames in the video stream.
|
||||
*/
|
||||
VALUE
|
||||
rb_fps(VALUE self)
|
||||
rb_set_width(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FPS));
|
||||
return rb_float_new(cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_WIDTH, NUM2DBL(value)));
|
||||
}
|
||||
|
||||
/*
|
||||
* 4character code of codec. see http://www.fourcc.org/
|
||||
* Get height of frames in the video stream.
|
||||
*/
|
||||
VALUE
|
||||
rb_fourcc(VALUE self)
|
||||
rb_get_height(VALUE self)
|
||||
{
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_HEIGHT));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set height of frames in the video stream.
|
||||
*/
|
||||
VALUE
|
||||
rb_set_height(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_float_new(cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_HEIGHT, NUM2DBL(value)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get frame rate
|
||||
*/
|
||||
VALUE
|
||||
rb_get_fps(VALUE self)
|
||||
{
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FPS));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set frame rate
|
||||
*/
|
||||
VALUE
|
||||
rb_set_fps(VALUE self, VALUE value)
|
||||
{
|
||||
return rb_float_new(cvSetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FPS, NUM2DBL(value)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get 4character code of codec. see http://www.fourcc.org/
|
||||
*/
|
||||
VALUE
|
||||
rb_get_fourcc(VALUE self)
|
||||
{
|
||||
char str[4];
|
||||
double fourcc = cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FOURCC);
|
||||
|
@ -277,91 +354,91 @@ rb_fourcc(VALUE self)
|
|||
}
|
||||
|
||||
/*
|
||||
* Number of frames in video file.
|
||||
* Get number of frames in video file.
|
||||
*/
|
||||
VALUE
|
||||
rb_frame_count(VALUE self)
|
||||
rb_get_frame_count(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_COUNT));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FRAME_COUNT));
|
||||
}
|
||||
|
||||
/*
|
||||
* The format of the Mat objects returned by CvCapture#retrieve
|
||||
* Get the format of the Mat objects returned by CvCapture#retrieve
|
||||
*/
|
||||
VALUE
|
||||
rb_format(VALUE self)
|
||||
rb_get_format(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FORMAT));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_FORMAT));
|
||||
}
|
||||
|
||||
/*
|
||||
* A backend-specific value indicating the current capture mode
|
||||
* Get a backend-specific value indicating the current capture mode
|
||||
*/
|
||||
VALUE
|
||||
rb_mode(VALUE self)
|
||||
rb_get_mode(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_MODE));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_MODE));
|
||||
}
|
||||
|
||||
/*
|
||||
* Brightness of the image (only for cameras)
|
||||
* Get brightness of the image (only for cameras)
|
||||
*/
|
||||
VALUE
|
||||
rb_brightness(VALUE self)
|
||||
rb_get_brightness(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_BRIGHTNESS));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_BRIGHTNESS));
|
||||
}
|
||||
|
||||
/*
|
||||
* Contrast of the image (only for cameras)
|
||||
* Get contrast of the image (only for cameras)
|
||||
*/
|
||||
VALUE
|
||||
rb_contrast(VALUE self)
|
||||
rb_get_contrast(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_CONTRAST));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_CONTRAST));
|
||||
}
|
||||
|
||||
/*
|
||||
* Saturation of the image (only for cameras)
|
||||
* Get saturation of the image (only for cameras)
|
||||
*/
|
||||
VALUE
|
||||
rb_saturation(VALUE self)
|
||||
rb_get_saturation(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_SATURATION));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_SATURATION));
|
||||
}
|
||||
|
||||
/*
|
||||
* Hue of the image (only for cameras)
|
||||
* Get hue of the image (only for cameras)
|
||||
*/
|
||||
VALUE
|
||||
rb_hue(VALUE self)
|
||||
rb_get_hue(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_HUE));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_HUE));
|
||||
}
|
||||
|
||||
/*
|
||||
* Gain of the image (only for cameras)
|
||||
* Get gain of the image (only for cameras)
|
||||
*/
|
||||
VALUE
|
||||
rb_gain(VALUE self)
|
||||
rb_get_gain(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_GAIN));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_GAIN));
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposure (only for cameras)
|
||||
* Get exposure (only for cameras)
|
||||
*/
|
||||
VALUE
|
||||
rb_exposure(VALUE self)
|
||||
rb_get_exposure(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_EXPOSURE));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_EXPOSURE));
|
||||
}
|
||||
|
||||
/*
|
||||
* Boolean flags indicating whether images should be converted to RGB
|
||||
* Get boolean flags indicating whether images should be converted to RGB
|
||||
*/
|
||||
VALUE
|
||||
rb_convert_rgb(VALUE self)
|
||||
rb_get_convert_rgb(VALUE self)
|
||||
{
|
||||
int flag = (int)cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_CONVERT_RGB);
|
||||
return (flag == 1) ? Qtrue : Qfalse;
|
||||
|
@ -371,18 +448,18 @@ rb_convert_rgb(VALUE self)
|
|||
* Currently unsupported
|
||||
*/
|
||||
VALUE
|
||||
rb_white_balance(VALUE self)
|
||||
rb_get_white_balance(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_WHITE_BALANCE));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_WHITE_BALANCE));
|
||||
}
|
||||
|
||||
/*
|
||||
* TOWRITE (note: only supported by DC1394 v 2.x backend currently)
|
||||
* Get TOWRITE (note: only supported by DC1394 v 2.x backend currently)
|
||||
*/
|
||||
VALUE
|
||||
rb_rectification(VALUE self)
|
||||
rb_get_rectification(VALUE self)
|
||||
{
|
||||
return rb_dbl2big(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_RECTIFICATION));
|
||||
return rb_float_new(cvGetCaptureProperty(CVCAPTURE(self), CV_CAP_PROP_RECTIFICATION));
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCAPTURE
|
||||
|
|
|
@ -23,33 +23,40 @@ VALUE rb_class();
|
|||
|
||||
void define_ruby_class();
|
||||
|
||||
void free(void *ptr);
|
||||
void cvcapture_free(void *ptr);
|
||||
VALUE rb_open(int argc, VALUE *argv, VALUE klass);
|
||||
|
||||
VALUE rb_grab(VALUE self);
|
||||
VALUE rb_retrieve(VALUE self);
|
||||
VALUE rb_query(VALUE self);
|
||||
|
||||
VALUE rb_millisecond(VALUE self);
|
||||
VALUE rb_frames(VALUE self);
|
||||
VALUE rb_avi_ratio(VALUE self);
|
||||
VALUE rb_size(VALUE self);
|
||||
VALUE rb_width(VALUE self);
|
||||
VALUE rb_height(VALUE self);
|
||||
VALUE rb_fps(VALUE self);
|
||||
VALUE rb_fourcc(VALUE self);
|
||||
VALUE rb_frame_count(VALUE self);
|
||||
VALUE rb_format(VALUE self);
|
||||
VALUE rb_mode(VALUE self);
|
||||
VALUE rb_brightness(VALUE self);
|
||||
VALUE rb_contrast(VALUE self);
|
||||
VALUE rb_saturation(VALUE self);
|
||||
VALUE rb_hue(VALUE self);
|
||||
VALUE rb_gain(VALUE self);
|
||||
VALUE rb_exposure(VALUE self);
|
||||
VALUE rb_convert_rgb(VALUE self);
|
||||
VALUE rb_white_balance(VALUE self);
|
||||
VALUE rb_rectification(VALUE self);
|
||||
VALUE rb_get_millisecond(VALUE self);
|
||||
VALUE rb_set_millisecond(VALUE self, VALUE value);
|
||||
VALUE rb_get_frames(VALUE self);
|
||||
VALUE rb_set_frames(VALUE self, VALUE value);
|
||||
VALUE rb_get_avi_ratio(VALUE self);
|
||||
VALUE rb_set_avi_ratio(VALUE self, VALUE value);
|
||||
VALUE rb_get_size(VALUE self);
|
||||
VALUE rb_set_size(VALUE self, VALUE value);
|
||||
VALUE rb_get_width(VALUE self);
|
||||
VALUE rb_set_width(VALUE self, VALUE value);
|
||||
VALUE rb_get_height(VALUE self);
|
||||
VALUE rb_set_height(VALUE self, VALUE value);
|
||||
VALUE rb_get_fps(VALUE self);
|
||||
VALUE rb_set_fps(VALUE self, VALUE value);
|
||||
VALUE rb_get_fourcc(VALUE self);
|
||||
VALUE rb_get_frame_count(VALUE self);
|
||||
VALUE rb_get_format(VALUE self);
|
||||
VALUE rb_get_mode(VALUE self);
|
||||
VALUE rb_get_brightness(VALUE self);
|
||||
VALUE rb_get_contrast(VALUE self);
|
||||
VALUE rb_get_saturation(VALUE self);
|
||||
VALUE rb_get_hue(VALUE self);
|
||||
VALUE rb_get_gain(VALUE self);
|
||||
VALUE rb_get_exposure(VALUE self);
|
||||
VALUE rb_get_convert_rgb(VALUE self);
|
||||
VALUE rb_get_white_balance(VALUE self);
|
||||
VALUE rb_get_rectification(VALUE self);
|
||||
|
||||
__NAMESPACE_END_CVCAPTURE
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ include OpenCV
|
|||
class TestCvCapture < OpenCVTestCase
|
||||
def setup
|
||||
@cap = CvCapture.open(AVI_SAMPLE)
|
||||
@cap.query
|
||||
end
|
||||
|
||||
def teardown
|
||||
|
@ -65,31 +66,69 @@ class TestCvCapture < OpenCVTestCase
|
|||
end
|
||||
|
||||
def test_millisecond
|
||||
@cap.millisecond = 10
|
||||
assert(@cap.millisecond.is_a? Numeric)
|
||||
# assert_equal(10, @cap.millisecond)
|
||||
@cap.millisecond = 20
|
||||
assert(@cap.millisecond.is_a? Numeric)
|
||||
# assert_equal(20, @cap.millisecond)
|
||||
end
|
||||
|
||||
def test_frames
|
||||
@cap.frames = 10
|
||||
assert(@cap.frames.is_a? Numeric)
|
||||
# assert_equal(10, @cap.frames)
|
||||
@cap.frames = 20
|
||||
assert(@cap.frames.is_a? Numeric)
|
||||
# assert_equal(20, @cap.frames)
|
||||
end
|
||||
|
||||
def test_avi_ratio
|
||||
@cap.avi_ratio = 0.1
|
||||
assert(@cap.avi_ratio.is_a? Numeric)
|
||||
# assert_equal(0.1, @cap.avi_ratio)
|
||||
@cap.avi_ratio = 0.8
|
||||
assert(@cap.avi_ratio.is_a? Numeric)
|
||||
# assert_equal(0.8, @cap.avi_ratio)
|
||||
end
|
||||
|
||||
def test_size
|
||||
@cap.size = CvSize.new(320, 240)
|
||||
assert_equal(CvSize, @cap.size.class)
|
||||
# assert_equal(320, @cap.size.width)
|
||||
# assert_equal(240, @cap.size.height)
|
||||
|
||||
@cap.size = CvSize.new(640, 480)
|
||||
assert_equal(CvSize, @cap.size.class)
|
||||
# assert_equal(640, @cap.size.width)
|
||||
# assert_equal(480, @cap.size.height)
|
||||
end
|
||||
|
||||
def test_width
|
||||
@cap.width = 320
|
||||
assert(@cap.width.is_a? Numeric)
|
||||
# assert_equal(320, @cap.width)
|
||||
@cap.width = 640
|
||||
assert(@cap.width.is_a? Numeric)
|
||||
# assert_equal(640, @cap.width)
|
||||
end
|
||||
|
||||
def test_height
|
||||
@cap.height = 240
|
||||
assert(@cap.height.is_a? Numeric)
|
||||
# assert_equal(240, @cap.height)
|
||||
@cap.height = 480
|
||||
assert(@cap.height.is_a? Numeric)
|
||||
# assert_equal(480, @cap.height)
|
||||
end
|
||||
|
||||
def test_fps
|
||||
@cap.fps = 15
|
||||
assert(@cap.fps.is_a? Numeric)
|
||||
# assert_equal(15, @cap.fps)
|
||||
@cap.fps = 30
|
||||
assert(@cap.fps.is_a? Numeric)
|
||||
# assert_equal(30, @cap.fps)
|
||||
end
|
||||
|
||||
def test_fourcc
|
||||
|
|
Loading…
Add table
Reference in a new issue