Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
face_detect
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiajunjie
face_detect
Commits
15f161fe
Commit
15f161fe
authored
Jan 21, 2021
by
jack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
843d9c7c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
19 deletions
+34
-19
darknet.cpython-35.pyc
examples/python/hatdet/__pycache__/darknet.cpython-35.pyc
+0
-0
darknet.py
examples/python/hatdet/darknet.py
+16
-10
test_darknet.py
examples/python/hatdet/test_darknet.py
+18
-9
No files found.
examples/python/hatdet/__pycache__/darknet.cpython-35.pyc
View file @
15f161fe
No preview for this file type
examples/python/hatdet/darknet.py
View file @
15f161fe
...
...
@@ -27,7 +27,7 @@ class DarknetYolo:
self
.
COLORS
=
COLORS
def
getdetresults
(
self
,
frame
,
hasdraw
):
def
getdetresults
(
self
,
frame
):
netMain
,
metaMain
,
thresh
,
COLORS
=
self
.
netMain
,
self
.
metaMain
,
self
.
thresh
,
self
.
COLORS
# Create a 4D blob from a frame.
...
...
@@ -65,19 +65,25 @@ class DarknetYolo:
# lower confidences.
idxs
=
cv2
.
dnn
.
NMSBoxes
(
boxes
,
confidences
,
thresh
,
0.3
)
if
len
(
idxs
)
>
0
:
if
not
hasdraw
:
return
idxs
,
boxes
,
confidences
,
classIDs
,
metaMain
;
lists
=
[[
0
for
i
in
range
(
0
)]
for
i
in
range
(
len
(
idxs
.
flatten
())
)]
k
=
0
for
i
in
idxs
.
flatten
():
# get x,y,w,h
(
x
,
y
)
=
(
boxes
[
i
][
0
],
boxes
[
i
][
1
])
(
w
,
h
)
=
(
boxes
[
i
][
2
],
boxes
[
i
][
3
])
# draw rectangle
x2
=
x
+
w
y2
=
y
+
h
lists
[
k
]
.
append
(
x
)
lists
[
k
]
.
append
(
y
)
lists
[
k
]
.
append
(
x2
)
lists
[
k
]
.
append
(
y2
)
label
=
metaMain
[
classIDs
[
i
]]
confidence
=
confidences
[
i
]
color
=
[
int
(
c
)
for
c
in
COLORS
[
classIDs
[
i
]]]
cv2
.
rectangle
(
frame
,
(
x
,
y
),
(
x
+
w
,
y
+
h
),
color
,
1
,
lineType
=
cv2
.
LINE_AA
)
text
=
"{}: {:.4f}"
.
format
(
metaMain
[
classIDs
[
i
]],
confidences
[
i
])
cv2
.
putText
(
frame
,
text
,
(
x
,
y
-
5
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
color
,
1
,
lineType
=
cv2
.
LINE_AA
)
cv2
.
imshow
(
"Tag"
,
frame
)
#cv2.waitKey(0)
lists
[
k
]
.
append
(
label
)
lists
[
k
]
.
append
(
confidence
)
lists
[
k
]
.
append
(
color
)
k
=
k
+
1
return
lists
else
:
print
(
"Cann't detect objects,please check image!"
)
examples/python/hatdet/test_darknet.py
View file @
15f161fe
...
...
@@ -53,14 +53,23 @@ while cv.waitKey(1) < 0:
# Release device
cap
.
release
()
break
detections_lists
=
[]
detections_lists
=
yolo
.
getdetresults
(
frame
)
print
(
len
(
detections_lists
))
idxs
,
boxes
,
confidences
,
classIDs
,
metaMain
=
yolo
.
getdetresults
(
frame
,
False
)
for
i
in
idxs
.
flatten
():
(
x
,
y
)
=
(
boxes
[
i
][
0
],
boxes
[
i
][
1
])
(
w
,
h
)
=
(
boxes
[
i
][
2
],
boxes
[
i
][
3
])
cv
.
rectangle
(
frame
,
(
x
,
y
),
(
x
+
w
,
y
+
h
),
(
255
,
255
,
255
),
1
,
lineType
=
cv
.
LINE_AA
)
text
=
"{}: {:.4f}"
.
format
(
metaMain
[
classIDs
[
i
]],
confidences
[
i
])
cv
.
putText
(
frame
,
text
,
(
x
,
y
-
5
),
cv
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
255
,
255
,
255
),
1
,
lineType
=
cv
.
LINE_AA
)
c
v
.
imshow
(
"Tag"
,
frame
)
for
i
in
range
(
len
(
detections_lists
)
):
# get x,y,w,h
x1
=
detections_lists
[
i
][
0
]
y1
=
detections_lists
[
i
][
1
]
x2
=
detections_lists
[
i
][
2
]
y2
=
detections_lists
[
i
][
3
]
label
=
detections_lists
[
i
][
4
]
confidence
=
detections_lists
[
i
][
5
]
c
olor
=
detections_lists
[
i
][
6
]
cv
.
rectangle
(
frame
,
(
x1
,
y1
),
(
x2
,
y2
),
color
,
1
,
lineType
=
cv
.
LINE_AA
)
text
=
"{}: {:.4f}"
.
format
(
label
,
confidence
)
cv
.
putText
(
frame
,
text
,
(
x1
,
y1
-
5
),
cv
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
color
,
1
,
lineType
=
cv
.
LINE_AA
)
cv
.
imshow
(
"Tag"
,
frame
)
#print(detections_lists)
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