cpp
QString appPath = QCoreApplication::applicationDirPath();
imagePath = appPath + "/A.jpg";
img = cv::imread(imagePath.toStdString());
if (img.empty())
return;
Mat bg = Mat::zeros(img.size(),img.type());
Rect rect;
rect.x = 200;
rect.y = 200;
rect.width = 100;
rect.height = 50;
rectangle(bg, rect, Scalar(0, 0, 255), -1,8,0);
circle(bg, Point(50, 100), 15, Scalar(255, 0, 0), 2);
line(bg, Point(100, 100), Point(100, 200), Scalar(0, 255, 0), 2, LINE_AA, 0);
RotatedRect rrt(Point(200, 200),Size(100, 200), 90.0);
ellipse(bg, rrt, Scalar(0, 255, 255), 2, 8);
Mat dst;
addWeighted(img, 0.7,bg,0.3,0, dst);
imshow("Draw", dst);
推荐一个零声学院项目课,个人觉得老师讲得不错,分享给大家:
零声白金学习卡(含基础架构/高性能存储/golang云原生/音视频/Linux内核)
https://xxetb.xet.tech/s/3Zqhgt