Ask Your Question
-1

Detect not completed triangles

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

Kailegh gravatar image

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

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;
   findContours(copia,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_SIMPLE);
   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)))
           drawContours(capture->image,contours,i,Scalar(0,255,0));

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: http://stackoverflow.com/questions/29...

edit retag flag offensive close merge delete

Comments

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

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

1 answer

Sort by ยป oldest newest most voted
1

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

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

Comments

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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 2,014 times

Last updated: Apr 07 '15