I have a problem with detecting speed road signs with opencv 2.4 for Android. I do the following:
"capture frame → convert it to HSV → extract red areas → detect signs with ellipse detection"
While ellipse detection works perfectly, so far the image is good. But, as you see in the figures below, red extraction does not work properly, due to the poor quality of the frames, in my opinion.
Convert source image to HSV:
Imgproc.cvtColor(this.source, this.source, Imgproc.COLOR_RGB2HSV, 3);
Extraction of red flowers:
Core.inRange(this.source, new Scalar(this.h,this.s,this.v), new Scalar(230,180,180), this.source);
So my question is another way to detect a traffic sign like this, or to extract red areas from it, which, incidentally, can be very weak, like in the last image?
This is the original image:

This is a conversion to HSV, as you can see that the red areas look the same as the nearby trees. Thats how I suppose to know this is red, but I can’t.
Converted to HSV:

It is with highlighted red flowers. If the colors are correct, I should get an almost perfect circle / ellipse around the mark, but it is incomplete due to false colors.
Result after extraction:

Ellipse Method:
private void findEllipses(Mat input){ Mat thresholdOutput = new Mat(); int thresh = 150; List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); MatOfInt4 hierarchy = new MatOfInt4(); Imgproc.threshold(source, thresholdOutput, thresh, 255, Imgproc.THRESH_BINARY); //Imgproc.Canny(source, thresholdOutput, 50, 180); Imgproc.findContours(source, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); RotatedRect minEllipse[] = new RotatedRect[contours.size()]; for(int i=0; i<contours.size();i++){ MatOfPoint2f temp=new MatOfPoint2f(contours.get(i).toArray()); if(temp.size().height > minEllipseSize && temp.size().height < maxEllipseSize){ double a = Imgproc.fitEllipse(temp).size.height; double b = Imgproc.fitEllipse(temp).size.width; if(Math.abs(a - b) < 10) minEllipse[i] = Imgproc.fitEllipse(temp); } } detectedObjects.clear(); for( int i = 0; i< contours.size(); i++ ){ Scalar color = new Scalar(180, 255, 180); if(minEllipse[i] != null){ detectedObjects.add(new DetectedObject(minEllipse[i].center)); DetectedObject detectedObj = new DetectedObject(minEllipse[i].center); Core.ellipse(source, minEllipse[i], color, 2, 8); } }
}
Problem Sign: 