opencv_core.Mat 与 opencv.core.Mat 之间的区别以及如何相互转换?

Difference between opencv_core.Mat vs opencv.core.Mat and how to convert to each other?

两者有什么区别?

org.bytedeco.javacpp.opencv_core.Mat

org.opencv.core.Mat

它们如何相互转换?

我认为 javacpp 是 opencv 的包装器,并且认为它们是相同的。但不是。

使用 JavaCPP 生成的包装器更完整,如 http://bytedeco.org/faq/ 中所述:

How does it differ from wrappers in OpenCV, TensorFlow, etc?

JavaCPP was designed for maximum performance and flexibility. It strives to map as much of C++ as the Java language can reasonably handle, offering a level of usability to native functionality unmatched by any other solutions that we are aware of. It also provides a common foundation, a set of basic classes, to increase the interoperability between different native libraries on the Java platform. Plus, its integration with standard tools such as Maven facilitates development and deployment.

JavaCV 捆绑了这两个 API,因此我们可以毫无问题地一起使用它们。我们也可以用OpenCVFrameConverter方便的在两者之间进行转换,例如:

OpenCVFrameConverter.ToMat converter1 = new OpenCVFrameConverter.ToMat();
OpenCVFrameConverter.ToOrgOpenCvCoreMat converter2 = new OpenCVFrameConverter.ToOrgOpenCvCoreMat();
Mat mat = ...;
org.opencv.core.Mat cvmat = converter2.convert(converter1.convert(mat));
Mat mat2 = converter2.convert(converter1.convert(cvmat));