OpenCV——基本图形绘制(椭圆、圆、多边形、直线、矩形)
//绘制椭圆
void DrawEllipse(Mat img, double angle)
{
int thickhness = ;
int lineType = ; ellipse(img,
Point(WINDOW_WIDTH / , WINDOW_WIDTH / ),
Size(WINDOW_WIDTH / , WINDOW_WIDTH / ),
angle,
, ,
Scalar(, , ),
thickhness,
lineType); }

//绘制实心圆
void DrawFilledCircle(Mat img, Point center)
{
int thickness = -;
int lineType = ; circle(img,
center,
WINDOW_WIDTH / ,
Scalar(, , ),
thickness,
lineType);
}

当thickness为其他>0的值时为正常的空心圆
void DrawPolygon(Mat img)
{
int lineType = ; Point rookPoints[][];
rookPoints[][] = Point(WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(*WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(WINDOW_WIDTH/, WINDOW_WIDTH/);
rookPoints[][] = Point(WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(* WINDOW_WIDTH/,* WINDOW_WIDTH/);
rookPoints[][] = Point(WINDOW_WIDTH/,* WINDOW_WIDTH/); const Point* ppt[] = { rookPoints[] };
int npt[] = { }; fillPoly(img,
ppt,
npt,
,//好像只能为1,填其他数程序出错
Scalar(, , ),
lineType); }
1、cvPolyLine 绘制简单或多样的多边形。
void cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int
contours, int is_closed,
CvScalar color, int thickness=1, int line_type=8, int shift=0
);
img
图像。
pts
折线的顶点指针数组。
npts
折线的定点个数数组。也可以认为是pts指针数组的大小
contours 折线的线段数量。
is_closed 指出多边形是否封闭。如果封闭,函数将起始点和结束点连线。
color
折线的颜色。
thickness 线条的粗细程度。
line_type 线段的类型。参见cvLine。
shift
顶点的小数点位数。
2、cvFillPoly用于一个单独被多边形轮廓所限定的区域内进行填充。
函数可以填充复杂的区域,例如,有漏洞的区域和有交叉点的区域等等。
void cvFillPoly( CvArr* img, CvPoint** pts, int* npts, int
contours,CvScalar color, int line_type=8, int shift=0 );
img
图像。
pts
指向多边形的数组指针。
npts
多边形的顶点个数的数组。
contours 组成填充区域的线段的数量。
color
多边形的颜色。
line_type 组成多边形的线条的类型。
shift
顶点坐标的小数点位数
绘制直线
int thickness = ;
int lineType = ;
line(rookImage,//要绘制的图
Point(, ),//起始点
Point(WINDOW_WIDTH, WINDOW_WIDTH),//终点
Scalar(, , ),
thickness,
lineType);
绘制矩形
rectangle (image3, rec1,Scalar(, , ), -, , )
rectangle( CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color,
int thickness=1, int line_type=8, int shift=0 );
- img
- 图像.
- pt1
- 矩形的一个顶点。
- pt2
- 矩形对角线上的另一个顶点
- color
- 线条颜色 (RGB) 或亮度(灰度图像 )(grayscale image)。
- thickness
- 组成矩形的线条的粗细程度。取负值时(如 CV_FILLED)函数绘制填充了色彩的矩形。
- line_type
- 线条的类型。见cvLine的描述
- shift
- 坐标点的小数点位数。
OpenCV——基本图形绘制(椭圆、圆、多边形、直线、矩形)的更多相关文章
- IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)
... 首先了解一下CGContextRef: An opaque type that represents a Quartz 2D drawing environment. Graphics Con ...
- (转) IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)
首先了解一下CGContextRef: An opaque type that represents a Quartz 2D drawing environment. Graphics Context ...
- [置顶] IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)
首先了解一下CGContextRef: An opaque type that represents a Quartz 2D drawing environment. Graphics Context ...
- opencv:基本图形绘制
可以使用opencv绘制 直线.圆.方形.椭圆等基本图形. 示例代码: #include <opencv.hpp> using namespace cv; int main() { // ...
- opencv:图形绘制与填充
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace st ...
- Android利用canvas画各种图形(点、直线、弧、圆、椭圆、文字、矩形、多边形、曲线、圆角矩形) .
1.首先说一下canvas类: Class Overview The Canvas class holds the "draw" calls. To draw something, ...
- 【opencv系列04】OpenCV4.X图形绘制
一. 基本图形绘制 1. 基本函数与参数 cv2.line(): 线 cv2.circle(): 圆 cv2.rectangle(): 矩形 cv2.ellipse(): 椭圆 cv2.putText ...
- 使用原生JavaScript的Canvas实现拖拽式图形绘制,支持画笔、线条、箭头、三角形、矩形、平行四边形、梯形以及多边形和圆形,不依赖任何库和插件,有演示demo
前言 需要用到图形绘制,没有找到完整的图形绘制实现,所以自己实现了一个 - - 一.实现的功能 1.基于oop思想构建,支持坐标点.线条(由坐标点组成,包含方向).多边形(由多个坐标点组成).圆形(包 ...
- QT 基本图形绘制
QT 基本图形绘制 1.告诉绘制引擎一些东西 QPainter::Antialiasing 在可能的情况下,反锯齿 QPainter::TextAntialiasing 在可能的情况下,文 ...
随机推荐
- Incircle and Circumcircle(二分+几何)浙大月赛zoj3806(详解版)图
Incircle and Circumcircle Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge A triangle is o ...
- Java开发中常用的设计模式(二)---单例模式
一. 懒汉式单例 //懒汉式单例类.在第一次调用的时候实例化自己 public class Singleton { private Singleton() {} private static Sing ...
- 新建hadoop用户以及用户组,给予sudo权限
1.首先新建用户,adduser命令 sudo adduser hadoop passwd hadoop 输入密码之后,一路 y 确定. 2.添加用户组 在创建hadoop用户的同时也创建了hadoo ...
- php命令行按模板生成应用的入口文件
接着这篇文章php命令行生成项目结构 继续改造: ghostwu@dev:~/php/php1/12$ tree . ├── app │ └── index.php ├── core │ ├─ ...
- 本地服务器搭建服务:svn
SVN(使用VisualSVN-server)可视化SVN 服务搭建,适合小白:简单又快捷,深入了解命令行方式等高手请移步官网看教程 1.官网 :http://subversion.apache.or ...
- 设计模式原则(5)--Law of Demeter(LoD)--迪米特法则
作者QQ:1095737364 QQ群:123300273 欢迎加入! 1.定义: 一个软件实体应当尽可能少地与其他实体发生相互作用.也就是说:一个类对自己依赖的类知道的越少越好.也就是 ...
- Angular 实现Bootstrap ScrollSpy控件
Bootstap是基于JQuery开发,Angular中不支持Bootstrap相关事件逻辑.本文基于Typecript开发了一个Angular可用的ScrollSpy控件.Scrollspy控件主要 ...
- SQLServer SQL连接查询深度探险(摘录
SQL连接查询深度探险[摘录] 测试环境: Windows XP Profession MySQL 5.0.45 Oracle 9i DB2 UDB 9.1 测试的SQL脚本如下:此脚本适合MySQL ...
- .net4.0多进程间共享内存实现通信(VB.Net)
.net4.0新增内存共享功能,从而很方便的实现了多进程间通信. 源码下载
- ES6 箭头函数下的this指向
在javscript中,this 是在函数运行时自动生成的一个内部指针,它指向函数的调用者. 箭头函数有些不同,它的this是继承而来, 默认指向在定义它时所处的对象(宿主对象),而不是执行时的对象. ...