Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV 2.4.2 findContours(), how to get only the straight lines contours

When I use from OpenCV 2.4.2 :

cv::findContours()

This is the output :

enter image description here

How can I get rid of all these irregular shapes and leave only straight lines ?

like image 251
Zaher Joukhadar Avatar asked Oct 20 '12 17:10

Zaher Joukhadar


2 Answers

For this case you can use cvMinAreaRect2. this function gives you a CvBox2D, since the contour you want has the biggest Bounding box the larger box is your goal. also this function can help you to find contours around long lines.

like image 111
Nima Avatar answered Nov 17 '22 16:11

Nima


You should use HoughLines instead of findContours.

like image 37
ArtemStorozhuk Avatar answered Nov 17 '22 14:11

ArtemStorozhuk