需要在图片中把特定的点来标注出来,看了一下cv::circle()函数,先上代码:
#include "opencv.hpp"
using namespace cv;
int main(int argc, char** argv)
{
Mat frame1;
char c=NULL;
frame1=imread("D:\\3.jpg"); //读入图片
//cvtColor(frame1,frame1,CV_BGR2GRAY); //见图片变为灰度图
//frame1.convertTo(frame1,CV_64FC1); //图片二值化
circle(frame1,Point(100,100),4,Scalar(0,0,255),-1,4,0); //画点
rectangle(frame1,Point(90,90),Point(110,110),Scalar(0,255,0),1,8,0); //画矩形框
imshow("Image1",frame1); //输出图像
c=waitKey(0);
destroyAllWindows();
return 0;
}
大概效果就是图片中的红点加绿框,国际品位高大上的红配绿···
稍微说说参数:
void circle(Mat& img, Point center, int radius, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
center: 是画点的坐标,为Point 类型的
radius: 为所画点的半径
color: 点的颜色,为Scalar类型的
thickness: 表示点是否为空心,正数表示空心,负数表示实心
lineType: 边界的类型,这个关系不大,值为8为8连接线,值为8表示8连接线,4表示4连接线,也不知道是什么···CA_AA表示锯齿线
shift: 表示坐标和半径小数点后数目
void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
画框框的参数和画点的差不多,只是把点的中心和半径改成了矩形的左上和右下的两个点,其他参数相同。
慢慢来,每天进步一点点。