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()));
Any help would be greatly appreciated thank you.