<commit_before>#include <e_line_judge/ball_detection.h>

BallDetection::BallDetection(const cv::Scalar &lower_range, const cv::Scalar &upper_range, double radius_estimate)
{
    hsv_min = lower_range;
    hsv_max = upper_range;
    radius_estimate_ = radius_estimate;
    std::cout << "Start detection system" << std::endl;
}

BallDetection::~BallDetection()
{
    
}

bool BallDetection::detect_ball(const cv::Mat &image, cv::Point2i &ball_center, double &ball_radius, bool debug)
{
    cv::Mat hsv_image;
    
    //vector for storing the detected circles
    std::vector<cv::Vec3f> circles;
    
    //convert image to HSV format
    cv::cvtColor(image, hsv_image, CV_BGR2HSV, 0);
    
    //orange color detection
    cv::inRange(hsv_image, hsv_min, hsv_max, hsv_image);
    if (debug)
    {
        cv::imshow("before blur", hsv_image);
        cv::waitKey(30);
    }
    
    //filter noise
//  cv::GaussianBlur(hsv_image, hsv_image, cv::Size(9, 9), 2, 2 );
    cv::medianBlur(hsv_image, hsv_image,13);
    
    if (debug)
    {        
        cv::imshow("blur", hsv_image);
        cv::waitKey(30);
    }
    //Apply the Hough Transform to find the circles
    cv::HoughCircles(hsv_image, circles, CV_HOUGH_GRADIENT, 2, hsv_image.rows/4, 100, 40, 20, 200);
    
    //Detect the largest circle
    double max_radius = 0.0;
    if(circles.size() == 0)
    {
        return false;
    }
    else<commit_msg>decreasing minimum radius to detect from 20 to 5 pixels<commit_after>#include <e_line_judge/ball_detection.h>

BallDetection::BallDetection(const cv::Scalar &lower_range, const cv::Scalar &upper_range, double radius_estimate)
{
    hsv_min = lower_range;
    hsv_max = upper_range;
    radius_estimate_ = radius_estimate;
    std::cout << "Start detection system" << std::endl;
}

BallDetection::~BallDetection()
{
    
}

bool BallDetection::detect_ball(const cv::Mat &image, cv::Point2i &ball_center, double &ball_radius, bool debug)
{
    cv::Mat hsv_image;
    
    //vector for storing the detected circles
    std::vector<cv::Vec3f> circles;
    
    //convert image to HSV format
    cv::cvtColor(image, hsv_image, CV_BGR2HSV, 0);
    
    //orange color detection
    cv::inRange(hsv_image, hsv_min, hsv_max, hsv_image);
    if (debug)
    {
        cv::imshow("before blur", hsv_image);
        cv::waitKey(30);
    }
    
    //filter noise
//  cv::GaussianBlur(hsv_image, hsv_image, cv::Size(9, 9), 2, 2 );
    cv::medianBlur(hsv_image, hsv_image,13);
    
    if (debug)
    {        
        cv::imshow("blur", hsv_image);
        cv::waitKey(30);
    }
    //Apply the Hough Transform to find the circles
    cv::HoughCircles(hsv_image, circles, CV_HOUGH_GRADIENT, 2, hsv_image.rows/4, 100, 40, 5, 200);
    
    //Detect the largest circle
    double max_radius = 0.0;
    if(circles.size() == 0)
    {
        return false;
    }
    else
{'fraction_non_alphanumeric': 0.12835716777118938, 'fraction_numerical': 0.020927799093128707, 'mean_word_length': 3.132564841498559, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2605990', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1024, 'n_words': 224}