mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
add VideoCapture#release
This commit is contained in:
parent
b2c6d1d4dc
commit
bd38779f40
2 changed files with 25 additions and 0 deletions
|
@ -248,6 +248,25 @@ namespace rubyopencv {
|
|||
return (ret) ? Mat::mat2obj(dstptr) : Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Closes video file or capturing device.
|
||||
*
|
||||
* @overload release
|
||||
* @return [nil]
|
||||
* @opencv_func cv::VideCapture::release
|
||||
*/
|
||||
VALUE rb_release(VALUE self) {
|
||||
cv::VideoCapture* selfptr = obj2videocapture(self);
|
||||
try {
|
||||
selfptr->release();
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
Error::raise(e);
|
||||
}
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void init() {
|
||||
VALUE opencv = rb_define_module("Cv");
|
||||
|
||||
|
@ -261,6 +280,7 @@ namespace rubyopencv {
|
|||
rb_define_method(rb_klass, "set", RUBY_METHOD_FUNC(rb_set), 2);
|
||||
rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
|
||||
rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), -1);
|
||||
rb_define_method(rb_klass, "release", RUBY_METHOD_FUNC(rb_release), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,4 +56,9 @@ class TestVideoCapture < OpenCVTestCase
|
|||
@cap.set(CAP_PROP_POS_MSEC, 1000)
|
||||
assert_equal(1000, @cap.get(CAP_PROP_POS_MSEC))
|
||||
end
|
||||
|
||||
def test_release
|
||||
@cap.release
|
||||
assert_false(@cap.opened?)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue