I'm trying to do a warp perspective on an image, but I'm failing.
I have the following code snippet:
Mat src = new Mat(4, 1, CV_32FC2); //Points describing the edges of the source image
Mat dst = new Mat(4, 1, CV_32FC2); //Points describing where I want the src edges to be moved to
//Below two rows aren't working
src.put(p1.y, p1.x, p2.y, p2.x, p4.y, p4.x, p3.y, p3.x);
dst.put(0, 0, 0, originalImgWidth, originalImgHeight, originalImgWidth, originalImgHeight, 0);
Mat perspectiveTransform = getPerspectiveTransform(src, dst);
warpPerspective(img2, img2, perspectiveTransform, new Size((int) originalImgWidth, (int) originalImgHeight));
The problem I'm encountering with the above code is that src.put, dst.put complains about "cannot resolve method".
If I type src.put, the auto complete only suggests MatExpr, Mat, Scalar and Pointer as valid input parameters. However openCV documentation suggests
there should be a method signature like:
put(int row, int col, double... data)
for the Mat object. Should I avoid using openCV documentation when using javaCV?
Am I going about trying to do a perspective warp the wrong way? Ive noticed that I can access perspectiveTransform through
JavaCV.getPerspectiveTransform, however that gives me a Mat object that's org.opencv.core.Mat, and incompatible with the other methods.
Here are my imports:
import static org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_imgproc.*;
import static org.bytedeco.javacpp.opencv_imgcodecs.*;
I'm thankful for any help.
/Johan