I am writing an iPhone app to use OpenCV to detect the 2D location in the iPhone camera of some sort of predefined marker (only one). What is the best type of marker? Circle? Square? Color? What is the fastest way to detect that marker? In addition, the detection algorithm needs to run near real-time.
I have tried openCV's circle detection but I got 1 fps (640x480 image):
Mat gray;
vector<Vec3f> circles;
CGPoint findLargestCircle(IplImage *image) {
Mat img(image);
cvtColor(img, gray, CV_BGR2GRAY);
// smooth it, otherwise a lot of false circles may be detected
GaussianBlur( gray, gray, cv::Size(9, 9), 2, 2 );
HoughCircles(gray, circles, CV_HOUGH_GRADIENT,
2, gray.rows/4, 200, 100 );
double radius=-1;
size_t ind;
for( size_t i = 0; i < circles.size(); i++ ) {
if(circles[i][2] > radius) {
radius = circles[i][2];
ind = i;
}
}
if(ind == -1) {
return CGPointMake(0, 0);
}else {
return CGPointMake(circles[ind][0], circles[ind][1]);
}
}
Any advice or code would be helpful.
Thanks in advance.