C ++ OpenCV没有在mat图像上绘制圆圈

时间:2015-07-27 16:12:47

标签: c++ opencv opencv-mat

我有使用cv :: Mat显示的图像,我试图用圆圈突出显示某些点

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));

    }
}/**/

但是,除了相关图像之外的图像上没有显示任何内容。我哪里出错了,怎么修好?

1 个答案:

答案 0 :(得分:3)

虽然Micka回答了它,但仍然打开了,所以:

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 );
}