Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cocoapi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
National Facility
cocoapi
Commits
2e75dbf4
Commit
2e75dbf4
authored
7 years ago
by
Wenting Zhao
Browse files
Options
Downloads
Patches
Plain Diff
Make drawing bbox an option in showAnns.
parent
ed842bff
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
PythonAPI/pycocotools/coco.py
+9
-1
9 additions, 1 deletion
PythonAPI/pycocotools/coco.py
with
9 additions
and
1 deletion
PythonAPI/pycocotools/coco.py
+
9
−
1
View file @
2e75dbf4
...
...
@@ -230,7 +230,7 @@ class COCO:
elif
type
(
ids
)
==
int
:
return
[
self
.
imgs
[
ids
]]
def
showAnns
(
self
,
anns
):
def
showAnns
(
self
,
anns
,
draw_bbox
=
False
):
"""
Display the specified annotations.
:param anns (array of object): annotations to display
...
...
@@ -286,6 +286,14 @@ class COCO:
plt
.
plot
(
x
[
sk
],
y
[
sk
],
linewidth
=
3
,
color
=
c
)
plt
.
plot
(
x
[
v
>
0
],
y
[
v
>
0
],
'
o
'
,
markersize
=
8
,
markerfacecolor
=
c
,
markeredgecolor
=
'
k
'
,
markeredgewidth
=
2
)
plt
.
plot
(
x
[
v
>
1
],
y
[
v
>
1
],
'
o
'
,
markersize
=
8
,
markerfacecolor
=
c
,
markeredgecolor
=
c
,
markeredgewidth
=
2
)
if
draw_bbox
:
[
bbox_x
,
bbox_y
,
bbox_w
,
bbox_h
]
=
ann
[
'
bbox
'
]
poly
=
[[
bbox_x
,
bbox_y
],
[
bbox_x
,
bbox_y
+
bbox_h
],
[
bbox_x
+
bbox_w
,
bbox_y
+
bbox_h
],
[
bbox_x
+
bbox_w
,
bbox_y
]]
np_poly
=
np
.
array
(
poly
).
reshape
((
4
,
2
))
polygons
.
append
(
Polygon
(
np_poly
))
color
.
append
(
c
)
p
=
PatchCollection
(
polygons
,
facecolor
=
color
,
linewidths
=
0
,
alpha
=
0.4
)
ax
.
add_collection
(
p
)
p
=
PatchCollection
(
polygons
,
facecolor
=
'
none
'
,
edgecolors
=
color
,
linewidths
=
2
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment