I'm using OpenCV to detect areas of red color from images with different backgrounds and light conditions:
A) Ideal conditions:
B) Similar color background:
C) Low light:
I've mainly tried using inRange
. First in the BGR color space, by extracting pixels that had a minimum red value of around 200. That worked well in A and B but not in C (low light). I tried converting the image to HSV and doing an inRange
for reds (borrowing from here):
Mat imgThresholded;
Mat imageHSV;
cvtColor(src, imageHSV, CV_BGR2HSV);
int iLowH = 0;
int iHighH = 50;
int iLowS = 100;
int iHighS = 255;
int iLowV = 80;
int iHighV = 255;
inRange(imageHSV,
Scalar(iLowH, iLowS, iLowV),
Scalar(iHighH, iHighS, iHighV),
imgThresholded);
return imgThresholded;
Which works well with A and C, but not with B.
Which approach would be best?
Thanks!