查找图像中扭曲的矩形(OpenCV)

发布于 2024-11-15 16:02:36 字数 308 浏览 3 评论 0原文

我正在寻找正确的算法集来解决此图像处理问题:

  • 我有一个包含扭曲矩形的扭曲二值图像
  • 我需要找到该矩形的 4 个角点的良好近似值

我可以使用 OpenCV 计算轮廓,但是由于图像扭曲,它通常会包含 4 个以上的角点。 是否有一个好的近似算法(最好使用 OpenCV 运算)来使用二值图像或轮廓描述找到矩形角点?

图像如下所示:

在此处输入图像描述

谢谢!

丹尼斯

I am looking for the right set of algorithms to solve this image processing problem:

  • I have a distorted binary image containing a distorted rectangle
  • I need to find a good approximation of the 4 corner points of this rectangle

I can calculate the contour using OpenCV, but as the image is distorted it will often contain more than 4 corner points.
Is there a good approximation algorithm (preferably using OpenCV operations) to find the rectangle corner points using the binary image or the contour description?

The image looks like this:

enter image description here

Thanks!

Dennis

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

很糊涂小朋友 2024-11-22 16:02:36

使用 cvApproxPoly 函数消除轮廓的节点数量,然后过滤掉那些具有太多节点或角度与 90 度相差很大的轮廓。另请参阅类似答案

Use cvApproxPoly function to eliminate number of nodes of your contour, then filter out those contours that have too many nodes or have angles which much differ from 90 degrees. See also similar answer

冷夜 2024-11-22 16:02:36

看opencv函数ApproxPoly。它从轮廓近似多边形。

Look at the opencv function ApproxPoly. It approximates a polygon from a contour.

野却迷人 2024-11-22 16:02:36

尝试哈里斯角探测器。 OpenCV 包中有示例。您需要使用图像的参数。

并查看其他 OpenCV 算法: http://www.comp.leeds .ac.uk/vision/opencv/opencvref_cv.html#cv_imgproc_features

Try Harris Corner Detector. There is example in OpenCV package. You need to play with params for your image.

And see other OpenCV algorithms: http://www.comp.leeds.ac.uk/vision/opencv/opencvref_cv.html#cv_imgproc_features

人心善变 2024-11-22 16:02:36

我会尝试广义霍夫变换,它有点慢,但可以很好地处理扭曲/不完整的形状。

http://en.wikipedia.org/wiki/Hough_transform

I would try generalised Hough Transform it is a bit slow but deals well with distorted/incomplete shapes.

http://en.wikipedia.org/wiki/Hough_transform

极致的悲 2024-11-22 16:02:36
  1. 即使您一开始有一些缺陷,即您的 approxPolly 调用返回五边形/六边形,这也会起作用。它会将任何轮廓(例如 transContours)减少为四边形或您想要的任何多边形。
  2. 向量<点> cardPoly;// 四存储
    int PolyLines = 0;//PolyPoly 计数器 ;)
    double simple = 0.5;//调整增量,较低的数字可能更精确,而较高的数字则循环速度更快。
    while(PolyLines != 4)//调整这个 
    {
        approxPolyDP(transContours, Poly, simple, true);
        PolyLines = Poly.size();
        简单性+= 0.5;
    }
    
  1. This will work even if you start with some defects, i.e. your approxPolly call returns pent/hexagons. It will reduce any contour, transContours in example, to a quad, or whatever poly you wish.
  2. vector<Point> cardPoly;// Quad storage
    int PolyLines = 0;//PolyPoly counter ;)
    double simplicity = 0.5;//Increment of adjustment, lower numbers may be more precise vs. high numbers being faster to cycle.
    while(PolyLines != 4)//Adjust this 
    {
        approxPolyDP(transContours, Poly, simplicity, true);
        PolyLines = Poly.size();
        simplicity += 0.5;
    }
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文