Skip to content

Instantly share code, notes, and snippets.

@MareArts
Last active February 14, 2018 20:38
Show Gist options
  • Save MareArts/dcd940d9c118eaf7dadb74f07238280b to your computer and use it in GitHub Desktop.
Save MareArts/dcd940d9c118eaf7dadb74f07238280b to your computer and use it in GitHub Desktop.
put text example for opencv
http://study.marearts.com/2014/03/opencv-study-write-text-on-image.html
//////////////////////////
//cvPutText, IplImage case.
CvFont * font = new CvFont;
cvInitFont(font, CV_FONT_VECTOR0, 0.5f, 1.0f, 0, 1, 8); //rate of width and height is 1:2
char szText[8];
sprintf(szText, "TextOut"); //make string
cvPutText(Image, szText, CenterPoint, font, CV_RGB(255, 255, 255)); //draw text on the IplImage* (Image)
//////////////////////////
//putText, Mat case.
char TestStr[100];
sprintf(TestStr,"total time : %lf sec", 0.001 );
putText(OutImg, TestStr, Point(100,250), CV_FONT_NORMAL, 1, Scalar(255,255,255),1,1); //OutImg is Mat class;
@MareArts
Copy link
Author

MareArts commented Feb 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment