How to overlay text on image when working with cv::Mat type

后端 未结 7 1008
广开言路
广开言路 2020-12-29 21:57

I am using opencv 2.1. In my code I have a few images stored as Mat objects initialized like this:

Mat img1 = imread(\"img/stuff.pgm\", CV_LOAD_IMAGE_GRAYSCA         


        
7条回答
  •  说谎
    说谎 (楼主)
    2020-12-29 22:05

    I was looking at the wrong place. I found the answer in the newer OpenCV documentation for cpp. There is a new function called putText() that accepts cv::Mat objects. So I tried this line and it works:

    putText(result, "Differencing the two images.", cvPoint(30,30), 
        FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(200,200,250), 1, CV_AA);
    

    Hope this helps someone.

提交回复
热议问题