简体   繁体   中英

C++ OpenCV not drawing circles on mat image

I've got images that are displayed using cv::Mat and I'm trying to highlight certain points with circles as so

cv::namedWindow("image_window");
cv::Mat image = cv::imread(fileLoc);

cv::imshow("image_window", image);

/*for (unsigned int b = 0; b < points.size(); b++)*/
if (points[0].num_parts() != 0)
{
    for (unsigned int c = 0; c < points[0].num_parts(); c++)
    {
        dlib::point pp = points[0].part(c);
        cv::circle(image, cv::Point(pp.x()/2 , pp.y()/2 ), 3, cv::Scalar(0, 0, 0));
        std::stringstream ss;
        ss << (c);
        /*cout << c << endl;
        cout << pp << endl;*/
        cv::putText(image, ss.str(), cv::Point(pp.x() , pp.y() ), cv::FONT_HERSHEY_PLAIN, 0.8f, cv::Scalar(0x99, 0xFF, 0xFF));

    }
}/**/

However, nothing is displayed on image other than the image in question. Where am I going wrong and how can it be fixed?

Though Micka had answered it, still open, so:

void ShowBlackCircle( const cv::Mat & img, cv::Point cp, int radius )
{
    int t_out = 0;
    std::string win_name = "circle";
    cv::Scalar black( 0, 0, 0 );
    cv::circle( img, cp, radius, black );
    cv::imshow( win_name, img ); cv::waitKey( t_out );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM