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
d0e02ccc
Commit
d0e02ccc
authored
Jan 23, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
samples(dnn): avoid 'async' keyword (Python 3.7+)
parent
3019927a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
object_detection.py
samples/dnn/object_detection.py
+4
-3
No files found.
samples/dnn/object_detection.py
View file @
d0e02ccc
...
@@ -43,6 +43,7 @@ parser.add_argument('--target', choices=targets, default=cv.dnn.DNN_TARGET_CPU,
...
@@ -43,6 +43,7 @@ parser.add_argument('--target', choices=targets, default=cv.dnn.DNN_TARGET_CPU,
'
%
d: OpenCL fp16 (half-float precision), '
'
%
d: OpenCL fp16 (half-float precision), '
'
%
d: VPU'
%
targets
)
'
%
d: VPU'
%
targets
)
parser
.
add_argument
(
'--async'
,
type
=
int
,
default
=
0
,
parser
.
add_argument
(
'--async'
,
type
=
int
,
default
=
0
,
dest
=
'asyncN'
,
help
=
'Number of asynchronous forwards at the same time. '
help
=
'Number of asynchronous forwards at the same time. '
'Choose 0 for synchronous mode'
)
'Choose 0 for synchronous mode'
)
args
,
_
=
parser
.
parse_known_args
()
args
,
_
=
parser
.
parse_known_args
()
...
@@ -231,8 +232,8 @@ def processingThreadBody():
...
@@ -231,8 +232,8 @@ def processingThreadBody():
try
:
try
:
frame
=
framesQueue
.
get_nowait
()
frame
=
framesQueue
.
get_nowait
()
if
args
.
async
:
if
args
.
async
N
:
if
len
(
futureOutputs
)
==
args
.
async
:
if
len
(
futureOutputs
)
==
args
.
async
N
:
frame
=
None
# Skip the frame
frame
=
None
# Skip the frame
else
:
else
:
framesQueue
.
queue
.
clear
()
# Skip the rest of frames
framesQueue
.
queue
.
clear
()
# Skip the rest of frames
...
@@ -256,7 +257,7 @@ def processingThreadBody():
...
@@ -256,7 +257,7 @@ def processingThreadBody():
frame
=
cv
.
resize
(
frame
,
(
inpWidth
,
inpHeight
))
frame
=
cv
.
resize
(
frame
,
(
inpWidth
,
inpHeight
))
net
.
setInput
(
np
.
array
([[
inpHeight
,
inpWidth
,
1.6
]],
dtype
=
np
.
float32
),
'im_info'
)
net
.
setInput
(
np
.
array
([[
inpHeight
,
inpWidth
,
1.6
]],
dtype
=
np
.
float32
),
'im_info'
)
if
args
.
async
:
if
args
.
async
N
:
futureOutputs
.
append
(
net
.
forwardAsync
())
futureOutputs
.
append
(
net
.
forwardAsync
())
else
:
else
:
outs
=
net
.
forward
(
outNames
)
outs
=
net
.
forward
(
outNames
)
...
...
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