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

后端 未结 7 1049
广开言路
广开言路 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:02

    If you are using OpenCV 3.x or 4.0, you have to replace CV_AA by LINE_AA. So, the complete call would be:

    cv::putText(yourImageMat, 
                "Text to add",
                cv::Point(5,5), // Coordinates
                cv::FONT_HERSHEY_COMPLEX_SMALL, // Font
                1.0, // Scale. 2.0 = 2x bigger
                cv::Scalar(255,255,255), // BGR Color
                1, // Line Thickness (Optional)
                cv::LINE_AA); // Anti-alias (Optional)
    

    This was posted in this forum.

提交回复
热议问题