我自动尝试transform perspective
,我正在使用HERE中的手册
正好是chapter 4: Flexible perspective transform
当我得到要转换的图像时,我得到下一个错误:
错误
11-04 13:34:25.759: E/cv::error()(17332): OpenCV Error: Assertion failed (count >= 0 && (depth == CV_32F || depth == CV_32S)) in double cv::arcLength(cv::InputArray, bool), file /home/maksim/workspace/android-pack/opencv/modules/imgproc/src/shapedescr.cpp, line 301
11-04 13:34:25.759: E/org.opencv.imgproc(17332): imgproc::arcLength_10() caught cv::Exception: /home/maksim/workspace/android-pack/opencv/modules/imgproc/src/shapedescr.cpp:301: error: (-215) count >= 0 && (depth == CV_32F || depth == CV_32S) in function double cv::arcLength(cv::InputArray, bool)
11-04 13:34:25.759: E/AndroidRuntime(17332): FATAL EXCEPTION: main
11-04 13:34:25.759: E/AndroidRuntime(17332): Process: com.example.alvaro.opencv, PID: 17332
11-04 13:34:25.759: E/AndroidRuntime(17332): CvException [org.opencv.core.CvException: cv::Exception: /home/maksim/workspace/android-pack/opencv/modules/imgproc/src/shapedescr.cpp:301: error: (-215) count >= 0 && (depth == CV_32F || depth == CV_32S) in function double cv::arcLength(cv::InputArray, bool)
11-04 13:34:25.759: E/AndroidRuntime(17332): ]
代码
Mat gray = new Mat();
Imgproc.cvtColor(sampledImage, gray, Imgproc.COLOR_RGB2GRAY, 0);
Imgproc.GaussianBlur(gray, gray, new Size(7, 7), 0);
Mat edgeImage = new Mat();
Imgproc.Canny(gray, edgeImage, 100, 200);//1500,300
Mat lines = new Mat();
int threshold = 100;//200
Imgproc.HoughLinesP(edgeImage, lines, 1, Math.PI / 180, threshold, 60, 10);//100,60
ArrayList<org.opencv.core.Point> corners = new ArrayList<org.opencv.core.Point>();
//Find the intersection of the four lines to get the four corners
for (int i = 0; i < lines.cols(); i++)
{
for (int j = i + 1; j < lines.cols(); j++)
{
org.opencv.core.Point intersectionPoint = getLinesIntersection(lines.get(0, i), lines.get(0, j));
if (intersectionPoint != null)
{
Log.i(TAG, "intersectionPoint: " + intersectionPoint.x + " " + intersectionPoint.y);
corners.add(intersectionPoint);
}
}
}
MatOfPoint2f approxCorners=new MatOfPoint2f();
MatOfPoint2f cornersMat=new MatOfPoint2f();
cornersMat.fromList(corners);
//ERROR LINE on "Imgproc.arcLength"
double approxDistance = Imgproc.arcLength(cornersMat, true) * 0.02;
Imgproc.approxPolyDP(cornersMat, approxCorners,approxDistance, true);
我尝试了什么
我尝试将图像32位更改为8位(或另一位)而没有结果
在她的边缘使用另一种方法。
我发现HERE同样的问题,但......我真的无法找到解决方案......
我真的不知道如何解决它。