how to find rectangles in image

asked 2017-12-24 10:40:19 -0500

hy17003 gravatar image

updated 2017-12-24 10:42:39 -0500

hello, I need find the rectangle in the follow image: image description

i try to use Canny to find the edge, here is the result: image description

we can clearly see the rectange, my meth is: 1) find the top line: from up to down, get the first 255 point in edge image to make a point set, and to use RANSAC line fit methed to fit the line, if the line fabs(min(dx, dy)/max(dx, dy))<0.3, i sure find a horizon line or vertcal line, if the line is not horizon or vertcal, i think of it noise, i draw the noise line with dark line in edge, so the the noise is erased, and next, i try the same methed untill to find a horizon line. 2)to find other line, i try similer method. 3)finaly, i find the rectanle: image description but, i not satisfy my method, do you have other idear to solve this problem. here is the src image: C:\fakepath\src.jpg

edit retag flag offensive close merge delete


What languages? You can't do rectangle. Recommendly, used polyline. I speak python 3.5 and OpenCV 3.4.0 for raspberry pi 3.

supra56 gravatar imagesupra56 ( 2017-12-25 06:29:31 -0500 )edit

I use C++, no matter recrtangle or polyine, i should find the corners first

hy17003 gravatar imagehy17003 ( 2017-12-29 09:01:49 -0500 )edit