Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

Thank you for your help

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

Thank you for your help

Edit: Crosspost at Stackoverflow: http://stackoverflow.com/questions/29468850/detect-not-complete-perfect-triangles