First time here? Check out the FAQ!

Ask Your Question
0

How to put measurement function on the text?

asked May 26 '14

norzanbzura gravatar image

Hi, actually I want to put the measurement on the text. But I doesn't have any idea how to put it. There's anyone can help me? Here is the code that I want to implement the measurement function on it. I'm not sure whether the code is right or not. Thank you in advanced.

    int imgW = 650;
    int imgH = 50;

    Mat frame = Mat::zeros(imgH,imgW, CV_8UC1);
    int fontFace = FONT_HERSHEY_COMPLEX_SMALL;
    double fontScale = 1.5;
    int thickness = 2;
    Point textOrg(imgW/5, imgH/1.2);
    string someText = "Dimension: ";
    putText(frame, someText, textOrg, fontFace, fontScale, Scalar::all(255), thickness,8);
Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered May 26 '14

Haris gravatar image

Use format() to fromat your text, and use it like sprintf.

For example,

int value=10;
string someText = format("Dimension: %d", value);
putText(frame, someText, textOrg, fontFace, fontScale, Scalar::all(255), thickness,8);
imshow("frame",frame);

and use CV_8UC3 instead CV_8UC1 if you need colour image.

Preview: (hide)

Comments

It's work! Thank you so much.

norzanbzura gravatar imagenorzanbzura (May 26 '14)edit

most welcome..........

Haris gravatar imageHaris (May 26 '14)edit

Question Tools

Stats

Asked: May 26 '14

Seen: 172 times

Last updated: May 25 '14