Im using OpenCV to help me detect a coin in an image taken from an iPhone camera. Im using HoughCircles method to help me find them but the results are less than hopeful.
cv::Mat greyMat;
cv::Mat filteredMat;
cv::vector<cv::Vec3f> circles;
cv::cvtColor(mainImageCV, greyMat, CV_BGR2GRAY);
cv::threshold(greyMat, filteredMat, 100, 255, CV_THRESH_BINARY);
for ( int i = 1; i < 31; i = i + 2 )
{
// cv::blur( filteredMat, greyMat, cv::Size( i, i ), cv::Point(-1,-1) );
cv::GaussianBlur(filteredMat, greyMat, cv::Size(i,i), 0);
// cv::medianBlur(filteredMat, greyMat, i);
// cv::bilateralFilter(filteredMat, greyMat, i, i*2, i/2);
}
cv::HoughCircles(greyMat, circles, CV_HOUGH_GRADIENT, 1, 50);
NSLog(@"Circles: %ld", circles.size());
for(size_t i = 0; i < circles.size(); i++)
{
cv::Point center((cvRound(circles[i][0]), cvRound(circles[i][1])));
int radius = cvRound(circles[i][2]);
cv::circle(greyMat, center, 3, cv::Scalar(0,255,0));
cv::circle(greyMat, center, radius, cv::Scalar(0,0,255));
}
[self removeOverViews];
[self.imageView setImage: [self UIImageFromCVMat:greyMat]];
This current segment of code returns that i have 15 circles and the are all position along the right side of the image which has me confused.
Im new to OpenCV and there are barely any examples for iOS which has left me desperate.
Any help would be greatly appreciated, thanks in advance!