I'm trying to convert some opencv code from C++ to Java, but I'm stuck at this code:
Mat matXyz; // some Mat
Mat result; // some other Mat
// ... set above mats to some values ...
result = Mat::ones(matXyz.size(), CV_32F) - result;
First, I don't really understand what the last line even does. Second, I don't know how to transfer this line to Java (OpenCV 2.4.6), as there are no overloaded operators like in C++, and I could not find any comparable method in the Java class (see OpenCV Javadoc).
What is the best way to transfer this into Java?
There are matrix operations in the org.opencv.core.Core class, including subtraction operators.
Mat endResult;
Core.subtract(Mat.ones(matXyz.size(),CvType.CV_32F),result,endResult);
The last line of your code creates a Matrix filled with ones, the same size as matXyz
, where the data are floating point numbers. It is all described in the docs that you linked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With