Ask Your Question

Revision history [back]

void setLabel(cv::Mat& im, const std::string label, const cv::Point & or)
{
    int fontface = cv::FONT_HERSHEY_SIMPLEX;
    double scale = 0.4;
    int thickness = 1;
    int baseline = 0;

    cv::Size text = cv::getTextSize(label, fontface, scale, thickness, &baseline);
    cv::rectangle(im, or + cv::Point(0, baseline), or + cv::Point(text.width, -text.height), CV_RGB(0,0,0), CV_FILLED);
    cv::putText(im, label, or, fontface, scale, CV_RGB(255,255,255), thickness, 8);

}

cv::Mat src = cv::imread(.......);
setLabel2(src,"here is the text to display", cvPoint(10,10));
void setLabel(cv::Mat& im, const std::string label, const cv::Point & or)
{
    int fontface = cv::FONT_HERSHEY_SIMPLEX;
    double scale = 0.4;
    int thickness = 1;
    int baseline = 0;

    cv::Size text = cv::getTextSize(label, fontface, scale, thickness, &baseline);
    cv::rectangle(im, or + cv::Point(0, baseline), or + cv::Point(text.width, -text.height), CV_RGB(0,0,0), CV_FILLED);
    cv::putText(im, label, or, fontface, scale, CV_RGB(255,255,255), thickness, 8);

}

cv::Mat src = cv::imread(.......);
setLabel2(src,"here setLabel(src,"here is the text to display", cvPoint(10,10));
void setLabel(cv::Mat& im, const std::string label, const cv::Point & or)
{
    int fontface = cv::FONT_HERSHEY_SIMPLEX;
    double scale = 0.4;
    int thickness = 1;
    int baseline = 0;

    cv::Size text = cv::getTextSize(label, fontface, scale, thickness, &baseline);
    cv::rectangle(im, or + cv::Point(0, baseline), or + cv::Point(text.width, -text.height), CV_RGB(0,0,0), CV_FILLED);
    cv::putText(im, label, or, fontface, scale, CV_RGB(255,255,255), thickness, 8);
}

}

cv::Mat src = cv::imread(.......);
setLabel(src,"here is the text to display", cvPoint(10,10));