Find distorted rectangle in image (OpenCV)

≯℡__Kan透↙ 提交于 2019-12-03 17:39:43

问题


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:

Thanks!

Dennis


回答1:


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




回答2:


little different answer, see

http://opencv.willowgarage.com/documentation/cpp/camera_calibration_and_3d_reconstruction.html




回答3:


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




回答4:


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




回答5:


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




回答6:


  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;
    }
    


来源:https://stackoverflow.com/questions/6356891/find-distorted-rectangle-in-image-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!