Ask Your Question

Detect not completed triangles

asked 2015-04-06 09:22:38 -0500

Kailegh gravatar image

updated 2015-04-06 11:55:39 -0500

I am tryng to detect traffic signs by their colour and shape, i have the binary image from de colour segmentation and i try to detect triangles in it, by unless all the sides of the triangle are complete y doesnt work,

in this image for example it does not detect any triangle

the code i am using is this:

vector<Point> approx;
   vector<Rect_ <int> > boundRect( contours.size() );
   vector<Rect_ <int> > boundRect_( contours.size() );
   for(size_t i=0; i<contours.size();i++)

       approxPolyDP(Mat(contours[i]), approx,arcLength(Mat(contours[i]), true)*0.02, true);

       if (approx.size() == 3 &&fabs(contourArea(Mat(approx))) > 300 && isContourConvex(Mat(approx)))

It is not a problem of the cotourArea, i have no problem detecting complete triangles. I do not know if i could do something to detect that kind of "not complete triangles" or i would have to do something to complete the triangle so that i could detect them. In either case i am a bit lost

Thank you for your help

Edit: Crosspost at Stackoverflow:

edit retag flag offensive close merge delete


Maybe you shoud try to find 3 points and use link text

wuling gravatar imagewuling ( 2015-04-06 09:35:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-04-07 07:45:05 -0500

theodore gravatar image

As it was pointed to you at the thread in stackoverflow you can apply different approaches. Getting the hull of the triangle gives the result below. Then I guess you can apply your already implemented triangle detection algorithm, that you have and works as you said without problem for full triangles.

image description image description image description

edit flag offensive delete link more


i have tried to do this and it detects more triangles(when some parts of the sides are missing it sometimes still fail) however now i get a lot of false positives in the images, in parts where there is nothing remotly similar to a triangle

Kailegh gravatar imageKailegh ( 2015-04-13 10:18:03 -0500 )edit

Question Tools

1 follower


Asked: 2015-04-06 09:22:38 -0500

Seen: 1,515 times

Last updated: Apr 07 '15