[英]Return Opencv Mat to node.js v8
How can I wrap an Opencv Mat and return it to node.js. 如何包装Opencv Mat并将其返回到node.js。 Thank you. 谢谢。 This is what I have. 这就是我所拥有的。
void testFunc(const Nan::FunctionCallbackInfo<v8::Value>& info){
Mat img = imread("test.jpg");
do stuff...
return image "img"
}
void Init(v8::Local<v8::Object> exports) {
exports->Set(Nan::New("pow").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(testFunc)->GetFunction());
}
NODE_MODULE(pow, Init)
Depends on what you want to do with the Mat
on the JavaScript side. 取决于您要在JavaScript端使用Mat
做什么。
Mat
used as its backing store. 您还可以设计一个与JS兼容的对象,该对象使用索引拦截器访问用作其后备存储的Mat
。 Note, however, that crossing the API boundary is relatively slow, so for fast code, it typically makes more sense to pass lots of data at once (like the Array suggestion above), and then avoid API-crossing calls inside hot loops. 但是请注意,越过API边界相对较慢,因此对于快速代码而言,一次传递大量数据(例如上面的Array建议)并避免在热循环内进行API交叉调用通常更有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.