I am building a robot soccer system using aruco marker as the robot id. The aruco marker already can be detected now i'm having problem to detect the ball. I am using Hough Circle Transform to detect the circle. I am having problem when I combined the aruco code with the hough circle code.
This is the code for hough circle transform
transform
#ifndef BALL_HPP
#define BALL_HPP
BALL_HPP
#include <vector>
#include <opencv2/aruco.hpp>
#include <opencv2/opencv.hpp>
class Ball
{
private:
public:
Ball(){}
~Ball(){}
inline cv::Mat Run( cv::Mat input )
{
cv::Mat gray;
cv::Mat bw;
std::vector<cv::Vec3f> circles;
/// Convert it to gray
cvtColor( input, gray, CV_BGR2GRAY );
/// Reduce the noise so we avoid false circle detection
cv::GaussianBlur( gray, gray, cv::Size( 9, 9 ), 2, 2 );
// medianBlur( gray, gray, 5 );
// Threshold
threshold( gray, bw, 150, 255, 0 );
// return bw;
/// Apply the Hough Transform to find the circles
cv::HoughCircles( bw, circles, CV_HOUGH_GRADIENT, 1, bw.rows / 8, 200, 60, 0, 0 );
/// Draw the circles detected
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]);
// std::cout << radius << std::endl;
// circle center
cv::circle( input, center, 3, cv::Scalar( 0, 255, 0 ), -1, 8, 0 );
// circle outline
cv::circle( input, center, radius, cv::Scalar( 0, 0, 255 ), 3, 8, 0 );
}
return input;
}
};
#endif // BALL_HPP