Reputation: 310
I want to detect an object and I tried using the Houghcirles function from OpenCV, but I could not achieve the better parameters for all the images and but by doing threasholding I could filter out for the circle. Code I have used is
int main()
{
// Load an image
src = imread("occupant/cam_000569.png");
threshold(src,binary,52,255,0);
imwrite("binary.png",binary);
canny(src,canny,50,200,3);
houghcircles(canny,circles,CV_HOUGH_GRADIENT,1,src.gray.rows/8,7,24,28);
After thresholding, I get the below image and even though there is disturbance included but for a threshold value of 52
I could see the same for all the other images where the object is clear.
After using the canny
and houghcircles
function with the parameters mentioned the code. I could detect the object required.
But the problem is when I use the next images the same thresholding value is applicable but using the same parameters for canny and houghcircles I am unable detect the object.
So my question is how to choice the parameters for the houghcircle or is it possible to detect the object with different OpenCV function?
Upvotes: 2
Views: 179
Reputation: 310
The better solution for this detection is use of blob detection in C++ or regionprops in MATLAB and filter out based on area and circularity calculation.
Upvotes: 1
Reputation: 3408
I think the main problem here is lighting. Try histogram equalization followed by some smoothing, before you apply the canny edge detector. You will have to take a number of images and estimate the canny and Hough parameters that work well for most of them. It is impossible to find values that result in a 100% detection rate.
Another option is to train an object detector for the object that you want to recognize, using Haar or LBP features. This just seems kind of overkill if the object is a circle.
Upvotes: 2