CvType to use with Transformation
Hello there I am trying to warp a section of an image using OpenCV Java and am failing to do so as I am getting an assertion error. My current code is here. 'bw' is the original matrix of an image and the corners[] array holds the points which border the quadrilateral I want to warp.
Mat src_mat = new Mat(bw.rows(), bw.cols(), CvType.CV_8UC1);
Mat dst_mat = new Mat(bw.rows(), bw.cols(), CvType.CV_8UC1);
src_mat.put(0, 0, corners[0].x, corners[0].y, corners[1].x, corners[1].y,
corners[2].x, corners[2].y, corners[3].x, corners[3].y);
dst_mat.put(0, 0, 0.0, 0.0, bw.cols(), 0.0, 0.0, bw.rows(),
bw.cols(), bw.rows());
Mat pTransform = Imgproc.getPerspectiveTransform(src_mat, dst_mat); //FAILING HERE
Imgproc.warpPerspective(bw, newMatrix, pTransform, new Size(bw.cols(), bw.rows()));
The error is
OpenCV Error: Assertion failed (src.checkVector(2, CV_32F) == 4 && dst.checkVector(2, CV_32F) == 4) in cv::getPerspectiveTransform, file ..\..\..\..\opencv\modules\imgproc\src\imgwarp.cpp, line 3922
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ..\..\..\..\opencv\modules\imgproc\src\imgwarp.cpp:3922: error: (-215) src.checkVector(2, CV_32F) == 4 && dst.checkVector(2, CV_32F) == 4 in function cv::getPerspectiveTransform
]
at org.opencv.imgproc.Imgproc.getPerspectiveTransform_0(Native Method)
at org.opencv.imgproc.Imgproc.getPerspectiveTransform(Imgproc.java:6529)
at judge.objectTracking.main(objectTracking.java:281)
Any help would be greatly appreciated thank you.
...and the error is ?
Edited, I apologise
no need to apologize ;)