1 #include <iostream> 2 #include <opencv2/opencv.hpp> 3 using namespace std; 4 using namespace cv; 5 int main() 6 { 7 Mat img = imread("e.bmp"); 8 imshow("原圖", img); 9 char tem[50]; 10 sprintf(tem, "%s","Where are you?"); 11 //img原圖像,tem輸出內容,Point輸出位置,0.9文字大小Scalar()顏色,1字體粗細, 12 putText(img, tem, Point(40, 250), FONT_HERSHEY_SIMPLEX, 0.9, Scalar(255, 255, 200),1,3);//在圖片上寫文字 13 namedWindow("效果圖"); 14 imshow("效果圖", img); 15 waitKey(); 16 return 0; 17 }