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
a2d6d96e
Commit
a2d6d96e
authored
Nov 10, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7161 from terfendail:shortline_fix
parents
67c40463
1d045f27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
0 deletions
+157
-0
types.hpp
modules/core/include/opencv2/core/types.hpp
+2
-0
test_drawing.cpp
modules/imgcodecs/test/test_drawing.cpp
+134
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+21
-0
drawing.cpp
modules/imgproc/src/drawing.cpp
+0
-0
No files found.
modules/core/include/opencv2/core/types.hpp
View file @
a2d6d96e
...
...
@@ -177,6 +177,7 @@ public:
};
typedef
Point_
<
int
>
Point2i
;
typedef
Point_
<
int64
>
Point2l
;
typedef
Point_
<
float
>
Point2f
;
typedef
Point_
<
double
>
Point2d
;
typedef
Point2i
Point
;
...
...
@@ -308,6 +309,7 @@ public:
};
typedef
Size_
<
int
>
Size2i
;
typedef
Size_
<
int64
>
Size2l
;
typedef
Size_
<
float
>
Size2f
;
typedef
Size_
<
double
>
Size2d
;
typedef
Size2i
Size
;
...
...
modules/imgcodecs/test/test_drawing.cpp
View file @
a2d6d96e
...
...
@@ -410,9 +410,143 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
return
0
;
}
class
CV_DrawingTest_Far
:
public
CV_DrawingTest_CPP
{
public
:
CV_DrawingTest_Far
()
{}
protected
:
virtual
void
draw
(
Mat
&
img
);
};
void
CV_DrawingTest_Far
::
draw
(
Mat
&
img
)
{
Size
imgSize
(
32768
+
600
,
400
);
img
.
create
(
imgSize
,
CV_8UC3
);
vector
<
Point
>
polyline
(
4
);
polyline
[
0
]
=
Point
(
32768
+
0
,
0
);
polyline
[
1
]
=
Point
(
imgSize
.
width
,
0
);
polyline
[
2
]
=
Point
(
imgSize
.
width
,
imgSize
.
height
);
polyline
[
3
]
=
Point
(
32768
+
0
,
imgSize
.
height
);
const
Point
*
pts
=
&
polyline
[
0
];
int
n
=
(
int
)
polyline
.
size
();
fillPoly
(
img
,
&
pts
,
&
n
,
1
,
Scalar
::
all
(
255
));
Point
p1
(
32768
+
1
,
1
),
p2
(
32768
+
3
,
3
);
if
(
clipLine
(
Rect
(
32768
+
0
,
0
,
imgSize
.
width
,
imgSize
.
height
),
p1
,
p2
)
&&
clipLine
(
imgSize
,
p1
,
p2
))
circle
(
img
,
Point
(
32768
+
300
,
100
),
40
,
Scalar
(
0
,
0
,
255
),
3
);
// draw
p2
=
Point
(
32768
+
3
,
imgSize
.
height
+
1000
);
if
(
clipLine
(
Rect
(
32768
+
0
,
0
,
imgSize
.
width
,
imgSize
.
height
),
p1
,
p2
)
&&
clipLine
(
imgSize
,
p1
,
p2
))
circle
(
img
,
Point
(
65536
+
500
,
300
),
50
,
cvColorToScalar
(
255
,
CV_8UC3
),
5
,
8
,
1
);
// draw
p1
=
Point
(
imgSize
.
width
,
1
),
p2
=
Point
(
imgSize
.
width
,
3
);
if
(
clipLine
(
Rect
(
32768
+
0
,
0
,
imgSize
.
width
,
imgSize
.
height
),
p1
,
p2
)
&&
clipLine
(
imgSize
,
p1
,
p2
))
circle
(
img
,
Point
(
32768
+
390
,
100
),
10
,
Scalar
(
0
,
0
,
255
),
3
);
// not draw
p1
=
Point
(
imgSize
.
width
-
1
,
1
),
p2
=
Point
(
imgSize
.
width
,
3
);
if
(
clipLine
(
Rect
(
32768
+
0
,
0
,
imgSize
.
width
,
imgSize
.
height
),
p1
,
p2
)
&&
clipLine
(
imgSize
,
p1
,
p2
))
ellipse
(
img
,
Point
(
32768
+
390
,
100
),
Size
(
20
,
30
),
60
,
0
,
220.0
,
Scalar
(
0
,
200
,
0
),
4
);
//draw
ellipse
(
img
,
RotatedRect
(
Point
(
32768
+
100
,
200
),
Size
(
200
,
100
),
160
),
Scalar
(
200
,
200
,
255
),
5
);
polyline
.
clear
();
ellipse2Poly
(
Point
(
32768
+
430
,
180
),
Size
(
100
,
150
),
30
,
0
,
150
,
20
,
polyline
);
pts
=
&
polyline
[
0
];
n
=
(
int
)
polyline
.
size
();
polylines
(
img
,
&
pts
,
&
n
,
1
,
false
,
Scalar
(
0
,
0
,
150
),
4
,
CV_AA
);
n
=
0
;
for
(
vector
<
Point
>::
const_iterator
it
=
polyline
.
begin
();
n
<
(
int
)
polyline
.
size
()
-
1
;
++
it
,
n
++
)
{
line
(
img
,
*
it
,
*
(
it
+
1
),
Scalar
(
50
,
250
,
100
));
}
polyline
.
clear
();
ellipse2Poly
(
Point
(
32768
+
500
,
300
),
Size
(
50
,
80
),
0
,
0
,
180
,
10
,
polyline
);
pts
=
&
polyline
[
0
];
n
=
(
int
)
polyline
.
size
();
polylines
(
img
,
&
pts
,
&
n
,
1
,
true
,
Scalar
(
100
,
200
,
100
),
20
);
fillConvexPoly
(
img
,
pts
,
n
,
Scalar
(
0
,
80
,
0
));
polyline
.
resize
(
8
);
// external rectengular
polyline
[
0
]
=
Point
(
32768
+
0
,
0
);
polyline
[
1
]
=
Point
(
32768
+
80
,
0
);
polyline
[
2
]
=
Point
(
32768
+
80
,
80
);
polyline
[
3
]
=
Point
(
32768
+
0
,
80
);
// internal rectangular
polyline
[
4
]
=
Point
(
32768
+
20
,
20
);
polyline
[
5
]
=
Point
(
32768
+
60
,
20
);
polyline
[
6
]
=
Point
(
32768
+
60
,
60
);
polyline
[
7
]
=
Point
(
32768
+
20
,
60
);
const
Point
*
ppts
[]
=
{
&
polyline
[
0
],
&
polyline
[
0
]
+
4
};
int
pn
[]
=
{
4
,
4
};
fillPoly
(
img
,
ppts
,
pn
,
2
,
Scalar
(
100
,
100
,
0
),
8
,
0
,
Point
(
500
,
20
));
rectangle
(
img
,
Point
(
32768
+
0
,
300
),
Point
(
32768
+
50
,
398
),
Scalar
(
0
,
0
,
255
));
string
text1
=
"OpenCV"
;
int
baseline
=
0
,
thickness
=
3
,
fontFace
=
FONT_HERSHEY_SCRIPT_SIMPLEX
;
float
fontScale
=
2
;
Size
textSize
=
getTextSize
(
text1
,
fontFace
,
fontScale
,
thickness
,
&
baseline
);
baseline
+=
thickness
;
Point
textOrg
((
32768
+
img
.
cols
-
textSize
.
width
)
/
2
,
(
img
.
rows
+
textSize
.
height
)
/
2
);
rectangle
(
img
,
textOrg
+
Point
(
0
,
baseline
),
textOrg
+
Point
(
textSize
.
width
,
-
textSize
.
height
),
Scalar
(
0
,
0
,
255
));
line
(
img
,
textOrg
+
Point
(
0
,
thickness
),
textOrg
+
Point
(
textSize
.
width
,
thickness
),
Scalar
(
0
,
0
,
255
));
putText
(
img
,
text1
,
textOrg
,
fontFace
,
fontScale
,
Scalar
(
150
,
0
,
150
),
thickness
,
8
);
string
text2
=
"abcdefghijklmnopqrstuvwxyz1234567890"
;
Scalar
color
(
200
,
0
,
0
);
fontScale
=
0.5
,
thickness
=
1
;
int
dist
=
5
;
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_SIMPLEX
,
fontScale
,
thickness
,
&
baseline
);
textOrg
=
Point
(
32768
+
5
,
5
)
+
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_SIMPLEX
,
fontScale
,
color
,
thickness
,
CV_AA
);
fontScale
=
1
;
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_PLAIN
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_PLAIN
,
fontScale
,
color
,
thickness
,
CV_AA
);
fontScale
=
0.5
;
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_DUPLEX
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_DUPLEX
,
fontScale
,
color
,
thickness
,
CV_AA
);
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_COMPLEX
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_COMPLEX
,
fontScale
,
color
,
thickness
,
CV_AA
);
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_TRIPLEX
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_TRIPLEX
,
fontScale
,
color
,
thickness
,
CV_AA
);
fontScale
=
1
;
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_COMPLEX_SMALL
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
180
)
+
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_COMPLEX_SMALL
,
fontScale
,
color
,
thickness
,
CV_AA
);
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_SCRIPT_SIMPLEX
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_SCRIPT_SIMPLEX
,
fontScale
,
color
,
thickness
,
CV_AA
);
textSize
=
getTextSize
(
text2
,
FONT_HERSHEY_SCRIPT_COMPLEX
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_HERSHEY_SCRIPT_COMPLEX
,
fontScale
,
color
,
thickness
,
CV_AA
);
dist
=
15
,
fontScale
=
0.5
;
textSize
=
getTextSize
(
text2
,
FONT_ITALIC
,
fontScale
,
thickness
,
&
baseline
);
textOrg
+=
Point
(
0
,
textSize
.
height
+
dist
);
putText
(
img
,
text2
,
textOrg
,
FONT_ITALIC
,
fontScale
,
color
,
thickness
,
CV_AA
);
img
=
img
(
Rect
(
32768
,
0
,
600
,
400
)).
clone
();
}
#ifdef HAVE_JPEG
TEST
(
Imgcodecs_Drawing
,
cpp_regression
)
{
CV_DrawingTest_CPP
test
;
test
.
safe_run
();
}
TEST
(
Imgcodecs_Drawing
,
c_regression
)
{
CV_DrawingTest_C
test
;
test
.
safe_run
();
}
TEST
(
Imgcodecs_Drawing
,
far_regression
)
{
CV_DrawingTest_Far
test
;
test
.
safe_run
();
}
#endif
class
CV_FillConvexPolyTest
:
public
cvtest
::
BaseTest
...
...
modules/imgproc/include/opencv2/imgproc.hpp
View file @
a2d6d96e
...
...
@@ -4414,6 +4414,13 @@ it returns true .
*/
CV_EXPORTS
bool
clipLine
(
Size
imgSize
,
CV_IN_OUT
Point
&
pt1
,
CV_IN_OUT
Point
&
pt2
);
/** @overload
@param imgSize Image size. The image rectangle is Rect(0, 0, imgSize.width, imgSize.height) .
@param pt1 First line point.
@param pt2 Second line point.
*/
CV_EXPORTS
bool
clipLine
(
Size2l
imgSize
,
CV_IN_OUT
Point2l
&
pt1
,
CV_IN_OUT
Point2l
&
pt2
);
/** @overload
@param imgRect Image rectangle.
@param pt1 First line point.
...
...
@@ -4439,6 +4446,20 @@ CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
int
arcStart
,
int
arcEnd
,
int
delta
,
CV_OUT
std
::
vector
<
Point
>&
pts
);
/** @overload
@param center Center of the arc.
@param axes Half of the size of the ellipse main axes. See the ellipse for details.
@param angle Rotation angle of the ellipse in degrees. See the ellipse for details.
@param arcStart Starting angle of the elliptic arc in degrees.
@param arcEnd Ending angle of the elliptic arc in degrees.
@param delta Angle between the subsequent polyline vertices. It defines the approximation
accuracy.
@param pts Output vector of polyline vertices.
*/
CV_EXPORTS
void
ellipse2Poly
(
Point2d
center
,
Size2d
axes
,
int
angle
,
int
arcStart
,
int
arcEnd
,
int
delta
,
CV_OUT
std
::
vector
<
Point2d
>&
pts
);
/** @brief Draws a text string.
The function putText renders the specified text string in the image. Symbols that cannot be rendered
...
...
modules/imgproc/src/drawing.cpp
View file @
a2d6d96e
This diff is collapsed.
Click to expand it.
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