Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
42001234
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
42001234
编写于
11月 23, 2015
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5390 from StevenPuttemans:add_markers_2.4
上级
6e885e57
406cfc48
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
105 addition
and
0 deletion
+105
-0
modules/core/include/opencv2/core/core.hpp
modules/core/include/opencv2/core/core.hpp
+38
-0
modules/core/src/drawing.cpp
modules/core/src/drawing.cpp
+67
-0
未找到文件。
modules/core/include/opencv2/core/core.hpp
浏览文件 @
42001234
...
...
@@ -2639,6 +2639,44 @@ CV_EXPORTS_W void ellipse(CV_IN_OUT Mat& img, Point center, Size axes,
CV_EXPORTS_W
void
ellipse
(
CV_IN_OUT
Mat
&
img
,
const
RotatedRect
&
box
,
const
Scalar
&
color
,
int
thickness
=
1
,
int
lineType
=
8
);
/* ----------------------------------------------------------------------------------------- */
/* ADDING A SET OF PREDEFINED MARKERS WHICH COULD BE USED TO HIGHLIGHT POSITIONS IN AN IMAGE */
/* ----------------------------------------------------------------------------------------- */
//! Possible set of marker types used for the drawMarker function
enum
MarkerTypes
{
MARKER_CROSS
=
0
,
// A crosshair marker shape
MARKER_TILTED_CROSS
=
1
,
// A 45 degree tilted crosshair marker shape
MARKER_STAR
=
2
,
// A star marker shape, combination of cross and tilted cross
MARKER_DIAMOND
=
3
,
// A diamond marker shape
MARKER_SQUARE
=
4
,
// A square marker shape
MARKER_TRIANGLE_UP
=
5
,
// An upwards pointing triangle marker shape
MARKER_TRIANGLE_DOWN
=
6
// A downwards pointing triangle marker shape
};
/** @brief Draws a marker on a predefined position in an image.
The function drawMarker draws a marker on a given position in the image. For the moment several
marker types are supported (`MARKER_CROSS`, `MARKER_TILTED_CROSS`, `MARKER_STAR`, `MARKER_DIAMOND`, `MARKER_SQUARE`,
`MARKER_TRIANGLE_UP` and `MARKER_TRIANGLE_DOWN`).
@param img Image.
@param position The point where the crosshair is positioned.
@param markerType The specific type of marker you want to use, see
@param color Line color.
@param thickness Line thickness.
@param line_type Type of the line, see cv::LineTypes
@param markerSize The length of the marker axis [default = 20 pixels]
*/
CV_EXPORTS_W
void
drawMarker
(
CV_IN_OUT
Mat
&
img
,
Point
position
,
const
Scalar
&
color
,
int
markerType
=
MARKER_CROSS
,
int
markerSize
=
20
,
int
thickness
=
1
,
int
line_type
=
8
);
/* ----------------------------------------------------------------------------------------- */
/* END OF MARKER SECTION */
/* ----------------------------------------------------------------------------------------- */
//! draws a filled convex polygon in the image
CV_EXPORTS
void
fillConvexPoly
(
Mat
&
img
,
const
Point
*
pts
,
int
npts
,
const
Scalar
&
color
,
int
lineType
=
8
,
...
...
modules/core/src/drawing.cpp
浏览文件 @
42001234
...
...
@@ -1797,6 +1797,73 @@ void ellipse(Mat& img, const RotatedRect& box, const Scalar& color,
EllipseEx
(
img
,
center
,
axes
,
_angle
,
0
,
360
,
buf
,
thickness
,
lineType
);
}
/* ----------------------------------------------------------------------------------------- */
/* ADDING A SET OF PREDEFINED MARKERS WHICH COULD BE USED TO HIGHLIGHT POSITIONS IN AN IMAGE */
/* ----------------------------------------------------------------------------------------- */
void
drawMarker
(
Mat
&
img
,
Point
position
,
const
Scalar
&
color
,
int
markerType
,
int
markerSize
,
int
thickness
,
int
line_type
)
{
switch
(
markerType
)
{
// The cross marker case
case
MARKER_CROSS
:
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
,
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
,
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// The tilted cross marker case
case
MARKER_TILTED_CROSS
:
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// The star marker case
case
MARKER_STAR
:
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
,
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
,
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// The diamond marker case
case
MARKER_DIAMOND
:
line
(
img
,
Point
(
position
.
x
,
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
),
Point
(
position
.
x
,
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
,
position
.
y
+
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
),
Point
(
position
.
x
,
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// The square marker case
case
MARKER_SQUARE
:
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// The triangle up marker case
case
MARKER_TRIANGLE_UP
:
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
+
(
markerSize
/
2
)),
Point
(
position
.
x
,
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
,
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// The triangle down marker case
case
MARKER_TRIANGLE_DOWN
:
line
(
img
,
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
+
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
Point
(
position
.
x
,
position
.
y
+
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
line
(
img
,
Point
(
position
.
x
,
position
.
y
+
(
markerSize
/
2
)),
Point
(
position
.
x
-
(
markerSize
/
2
),
position
.
y
-
(
markerSize
/
2
)),
color
,
thickness
,
line_type
);
break
;
// If any number that doesn't exist is entered, draw a cross marker
default:
drawMarker
(
img
,
position
,
color
,
MARKER_CROSS
,
markerSize
,
thickness
,
line_type
);
break
;
}
}
/* ----------------------------------------------------------------------------------------- */
void
fillConvexPoly
(
Mat
&
img
,
const
Point
*
pts
,
int
npts
,
const
Scalar
&
color
,
int
line_type
,
int
shift
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录