Android 如何使用OpenCV从canny边缘检测中找到x和y位置?

Android 如何使用OpenCV从canny边缘检测中找到x和y位置?,android,opencv,edge-detection,Android,Opencv,Edge Detection,我试图找到x和y位置的图像转换后,从canny边缘检测,但我无法找到准确的结果。我正在使用opencvlibrary311 这是我的代码片段 // transformation matrix Mat transformMatrix = Imgproc.getPerspectiveTransform(srcMat, dstMat); finalMat = Mat.zeros((int) maxHeight, (int) maxWidth, CvType.CV_32FC2); Imgproc.wa

我试图找到x和y位置的图像转换后,从canny边缘检测,但我无法找到准确的结果。我正在使用opencvlibrary311

这是我的代码片段

// transformation matrix
Mat transformMatrix = Imgproc.getPerspectiveTransform(srcMat, dstMat);

finalMat = Mat.zeros((int) maxHeight, (int) maxWidth, CvType.CV_32FC2);
Imgproc.warpPerspective(rgbMat, finalMat, transformMatrix, finalMat.size());
Log.e("FinalDisplay", "finalMat: " + finalMat.size());

// display final results
Bitmap dstBitmap = Bitmap.createBitmap(finalMat.width(), finalMat.height(), Bitmap.Config.RGB_565);
Log.e("FinalDisplay", "dstBitmap: " + img.getWidth() + " x " + img.getHeight());
Utils.matToBitmap(finalMat, dstBitmap); //convert mat to bitmap

// create cropped bitmap based on canny edge x and y and height and width
try {
    Bitmap crop = Bitmap.createBitmap(rotateandscalebitmap, cannyMat.rows(),cannyMat.cols(), dstBitmap.getWidth(), dstBitmap.getHeight()-20);
    // Bitmap crop = Bitmap.createBitmap(rotateandscalebitmap, ((int) horizontals.get(5)._center.y + 150), ((int) verticals.get(0)._center.x), dstBitmap.getWidth() + 100, dstBitmap.getHeight() + 10);

    croppedbitmap = crop;
    doRecognize(croppedbitmap);

} catch (Exception e) {
    e.printStackTrace();
}
我希望这低于输出


您的代码显示透视变换和裁剪。Canny和这个问题有什么关系?@CrisLuengo我想检测矩形卡片的边缘(4条边),这样Canny就可以返回矩形的完美边缘,并从其边缘裁剪出卡片图像。但我无法检测边缘的起始位置(x)和结束位置(y)。我添加了一个图像(我需要此输出)。感谢没有输入的输出没有多大帮助(请模糊个人详细信息,即使它们是您的)。您使用Canny而不是轮廓检测或Hough变换有什么特别的原因吗?@user2986898谢谢您的建议。你能给我提供演示代码或任何有用的关于轮廓检测或霍夫变换的链接吗?