Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
67ef84d8
Commit
67ef84d8
authored
Nov 02, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5386 from StevenPuttemans:add_markers
parents
b5fd7868
587dca9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
0 deletions
+102
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+37
-0
drawing.cpp
modules/imgproc/src/drawing.cpp
+65
-0
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
67ef84d8
...
...
@@ -3904,6 +3904,43 @@ a filled ellipse sector is to be drawn.
CV_EXPORTS_W
void
ellipse
(
InputOutputArray
img
,
const
RotatedRect
&
box
,
const
Scalar
&
color
,
int
thickness
=
1
,
int
lineType
=
LINE_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 cv::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, see cv::MarkerTypes for more information.
@param img Image.
@param position The point where the crosshair is positioned.
@param markerType The specific type of marker you want to use, see cv::MarkerTypes
@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 */
/* ----------------------------------------------------------------------------------------- */
/** @overload */
CV_EXPORTS
void
fillConvexPoly
(
Mat
&
img
,
const
Point
*
pts
,
int
npts
,
const
Scalar
&
color
,
int
lineType
=
LINE_8
,
...
...
modules/imgproc/src/drawing.cpp
View file @
67ef84d8
...
...
@@ -1654,6 +1654,71 @@ PolyLine( Mat& img, const Point* v, int count, bool is_closed,
}
}
/* ----------------------------------------------------------------------------------------- */
/* 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 as marker type, draw a cross marker, to avoid crashes
default:
drawMarker
(
img
,
position
,
color
,
MARKER_CROSS
,
markerSize
,
thickness
,
line_type
);
break
;
}
}
/****************************************************************************************\
* External functions *
\****************************************************************************************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment