绘画
绘制图形如果设置为-1则扩展整个内部包裹区域, 下面两个是一样的
-1
CV_FILLED
画线
line(final, cv::Point(0,0), cv::Point(100,100),Scalar(255,0,0),5);
矩形
rectangle(final, cv::Point(0,0), cv::Point(200,200), Scalar(255,0,0),-1);
圆形
circle(final, cv::Point(0,0), 200,Scalar(0,255,0),3);
circle(final, {100,50}, 200,{0,255,0},3);
椭圆
ellipse(final, {200,200}, {100,200}, 0, 0, 360, 255,-1);
多边形
cv::Point points[0][4];
points[0][0] = { 100, 100 };
points[0][1] = { 200, 100 };
points[0][2] = { 250, 200 };
points[0][3] = { 50, 200 };
cv::Point* pts[]= {points[0]};
int npt[1] = {4};
polylines(final, pts, npt, 1, true, {255,0,0});
std::vector<cv::Point> imagePoints;
imagePoints.push_back(cv::Point(144,103));
imagePoints.push_back(cv::Point(206,75));
imagePoints.push_back(cv::Point(109,151));
imagePoints.push_back(cv::Point(253,159));
polylines(final, imagePoints, true, {200,100,150},5);
文字
putText(final, "test 123", {100,100}, FONT_HERSHEY_SIMPLEX, 4, {200,200,200},5);
直接操作像素
for (int i=0; i<10; i++) {
for (int j=0; j<10; j++) {
Vec3b& color = final.at<Vec3b>(50+i,50+j);
color[2] = 0;
color[1] = 0;
color[0] = 0;
}
}
绘画api,用于debug处理是的必备api。