Ask Your Question
0

How to put measurement function on the text?

asked 2014-05-25 21:31:40 -0600

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);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-05-25 22:39:36 -0600

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.

edit flag offensive delete link more

Comments

It's work! Thank you so much.

norzanbzura gravatar imagenorzanbzura ( 2014-05-26 00:20:46 -0600 )edit

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

Haris gravatar imageHaris ( 2014-05-26 00:31:24 -0600 )edit

Question Tools

Stats

Asked: 2014-05-25 21:31:40 -0600

Seen: 168 times

Last updated: May 25 '14