Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

java.lang.IllegalArgumentException: Incompatible Mat

$
0
0
I am using OpenCV in Java and I've the following function: Mat getSearchArea(Mat frame, Point startPoint, Point endPoint) { Point upperLineStartPoint = new Point(startPoint.x, startPoint.y - MARGIN); Point lowerLineStartPoint = new Point(startPoint.x, startPoint.y); Point lowerLineEndPoint = new Point(endPoint.x, endPoint.y); Point upperLineEndPoint = new Point(endPoint.x, endPoint.y - MARGIN); pointsForTrapezoid.add(upperLineStartPoint); pointsForTrapezoid.add(new Point(0, frame.rows())); pointsForTrapezoid.add(new Point(frame.cols(), frame.rows())); pointsForTrapezoid.add(upperLineEndPoint); // ROI by creating mask for the trapezoid Mat mask = new Mat(frame.rows(), frame.cols(), CvType.CV_8UC1, new Scalar(0)); // Make the necessary conversions to that we don't get an error MatOfPoint2f tmpTrapeziod = new MatOfPoint2f(); MatOfPoint2f tmpROI = new MatOfPoint2f(); tmpTrapeziod.fromList(pointsForTrapezoid); tmpROI.fromList(roiPolygonized); // Create Polygon from vertices Imgproc.approxPolyDP(tmpTrapeziod, tmpROI, 1.0, true); // Fill polygon white Imgproc.fillConvexPoly(mask, new MatOfPoint(tmpROI), new Scalar(255), 8, 0); // Create new image for result storage, populate it with zeros to avoid // memory leftovers Mat maskedImage = Mat.zeros(frame.rows(), frame.cols(), CvType.CV_8UC3); frame.copyTo(maskedImage, mask); return maskedImage; } which is responsible for creating a trapezoid from the points passed, and creating a mask out of it, and applying the mask. I get the following error at the line where `fillConvexPoly()` is: Exception in thread "main" java.lang.IllegalArgumentException: Incompatible Mat at org.opencv.core.MatOfPoint.(MatOfPoint.java:29) I am clueless about why I am getting this error, is there a problem with the initialization or ?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>