OpenCV绘图

标记函数void cv::drawMarker

void cv::drawMarker	(	InputOutputArray 	img,	//输入输出图片
				Point 	position,					//标记的点
				const Scalar & 	color,				//颜色
				int 	markerType = MARKER_CROSS,
				int 	markerSize = 20,
				int 	thickness = 1,
				int 	line_type = 8 
)	

关于标记类型,有如下几种:图片源自网络

画圆(实心、空心)、画点void cv::circle

The function cv::circle draws a simple or filled circle with a given center and radius.
cv::circle绘制具有给定圆心和半径的简单圆或填充圆。

void cv::circle	(	InputOutputArray 	img,	//输入输出图片
					Point 	center,				//圆心,或点的位置
					int 	radius,				//半径
					const Scalar & 	color,		//颜色
					int 	thickness = 1,		//圆轮廓的厚度(正值),为负值则填充圆
					int 	lineType = LINE_8,
					int 	shift = 0 
)	

画线void cv::line

//参数与circle大致相同
void cv::line	(	InputOutputArray 	img,
					Point 	pt1,
					Point 	pt2,
					const Scalar & 	color,
					int 	thickness = 1,
					int 	lineType = LINE_8,
					int 	shift = 0 
)

画自定义旋转矩形、多边形等(用画直线实现)

      auto vertices = armor.SurfaceVertices();			//旋转矩形的四个点的向量
      auto num_vertices = vertices.size();				//四个点
      for (std::size_t i = 0; i < num_vertices; ++i) {	//遍历连线
        cv::line(output, vertices[i], vertices[(i + 1) % num_vertices], kGREEN);
      }

轮廓函数void cv::drawContours


void cv::drawContours	(	InputOutputArray 	image,			//输入输出图像
							InputArrayOfArrays 	contours,		//输入轮廓数组
							int 	contourIdx,					//画的轮廓的索引。为负则绘制全部
							const Scalar & 	color,				//颜色
							int 	thickness = 1,				//线的厚度,为负则填充
							int 	lineType = LINE_8,
							InputArray 	hierarchy = noArray(),
							int 	maxLevel = INT_MAX,
							Point 	offset = Point() 
)	
//例程
cv::drawContours(output, contours_, -1, kRED);

输出文字void cv::putText


void cv::putText	(	InputOutputArray 	img,			//输入输出图片
						const String & 	text,				//字符串
						Point 	org,						//左上角点的位置
						int 	fontFace,					//字体
						double 	fontScale,					//字体大小
						Scalar 	color,						//颜色
						int 	thickness = 1,
						int 	lineType = LINE_8,
						bool 	bottomLeftOrigin = false 
)	
//例程:
cv::putText(output, label, cv::Point(0, v_pos), kCV_FONT, 1.0, kGREEN);

更多很多函数待补充

画矩形、椭圆等

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值