# Detect not completed triangles

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

Edit: Crosspost at Stackoverflow: http://stackoverflow.com/questions/29...

edit retag close merge delete

Sort by » oldest newest most voted 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.   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

Official site

GitHub

Wiki

Documentation