mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
Bug fixes and added size() to Mat.
This commit is contained in:
parent
b648bbfb74
commit
fe3493f47c
4 changed files with 51 additions and 26 deletions
|
@ -19,7 +19,7 @@ namespace rubyopencv {
|
|||
VALUE image, options;
|
||||
rb_scan_args(argc, argv, "11", &image, &options);
|
||||
|
||||
cv::Mat *b;
|
||||
cv::Mat *b = NULL;
|
||||
cv::Mat *m = Mat::obj2mat(image);
|
||||
|
||||
try {
|
||||
|
@ -38,7 +38,7 @@ namespace rubyopencv {
|
|||
}
|
||||
|
||||
b = new cv::Mat(r);
|
||||
} catch(cv::Exception& e) {
|
||||
} catch(cv::Exception& e) {
|
||||
delete b;
|
||||
Error::raise(e);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace rubyopencv {
|
|||
|
||||
// Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String());
|
||||
VALUE rb_read_net_from_caffe(VALUE self, VALUE prototxt, VALUE caffe_model) {
|
||||
cv::dnn::experimental_dnn_v1::Net *net;
|
||||
cv::dnn::experimental_dnn_v1::Net *net = NULL;
|
||||
|
||||
try {
|
||||
net = new cv::dnn::experimental_dnn_v1::Net(cv::dnn::readNetFromCaffe(StringValueCStr(prototxt), StringValueCStr(caffe_model)));
|
||||
|
@ -60,6 +60,34 @@ namespace rubyopencv {
|
|||
return Dnn::Net::net2obj(net);
|
||||
}
|
||||
|
||||
// Net readNetFromTorch(const String &model, bool isBinary)
|
||||
VALUE rb_read_net_from_tensorflow(VALUE self, VALUE model) {
|
||||
cv::dnn::experimental_dnn_v1::Net *net = NULL;
|
||||
|
||||
try {
|
||||
net = new cv::dnn::experimental_dnn_v1::Net(cv::dnn::readNetFromTensorflow(StringValueCStr(model)));
|
||||
} catch(cv::Exception& e) {
|
||||
delete net;
|
||||
Error::raise(e);
|
||||
}
|
||||
|
||||
return Dnn::Net::net2obj(net);
|
||||
}
|
||||
|
||||
// Net readNetFromTorch(const String &model, bool isBinary)
|
||||
VALUE rb_read_net_from_torch(VALUE self, VALUE model) {
|
||||
cv::dnn::experimental_dnn_v1::Net *net = NULL;
|
||||
|
||||
try {
|
||||
net = new cv::dnn::experimental_dnn_v1::Net(cv::dnn::readNetFromTorch(StringValueCStr(model)));
|
||||
} catch(cv::Exception& e) {
|
||||
delete net;
|
||||
Error::raise(e);
|
||||
}
|
||||
|
||||
return Dnn::Net::net2obj(net);
|
||||
}
|
||||
|
||||
void init() {
|
||||
VALUE opencv = rb_define_module("Cv");
|
||||
|
||||
|
@ -67,6 +95,8 @@ namespace rubyopencv {
|
|||
|
||||
rb_define_singleton_method(rb_module, "blob_from_image", RUBY_METHOD_FUNC(rb_blob_from_image), -1);
|
||||
rb_define_singleton_method(rb_module, "read_net_from_caffe", RUBY_METHOD_FUNC(rb_read_net_from_caffe), 2);
|
||||
rb_define_singleton_method(rb_module, "read_net_from_tensorflow", RUBY_METHOD_FUNC(rb_read_net_from_tensorflow), 1);
|
||||
rb_define_singleton_method(rb_module, "read_net_from_torch", RUBY_METHOD_FUNC(rb_read_net_from_torch), 1);
|
||||
|
||||
Dnn::Net::init(rb_module);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue