Skip to content

Async mode for dnn's object detection sample - #14516

Merged
opencv-pushbot merged 2 commits into
opencv:3.4from
dkurt:dnn_async_samples
May 14, 2019
Merged

opencv-pushbot merged 2 commits into
opencv:3.4from
dkurt:dnn_async_samples

Conversation

@dkurt

@dkurt dkurt commented May 8, 2019 •

Copy link
Copy Markdown
Member

This pullrequest changes

resolves #13667

Camera with 60fps @ 1280x720 is used (Logitech C922 PRO)

Target --async=0 --async=1 --async=2 --async=3 --async=4
NCS, USB 3.0 11.6 9.9 11.9 11.9 11.9
NCS2, USB 3.0 26.43 19.9 39.5 53.2 48.6

CPU: Intel® Core™ i7-6700K CPU @ 4.00GHz × 8
NCS: Intel® Movidius™ Neural Compute Stick
NCS2: Intel® Neural Compute Stick 2

  • All the numbers are frames per second which are processed by network (FPS):
$ python object_detection.py opencv_fd --target 3
allow_multiple_commits=1
buildworker:Custom=linux-2
docker_image:Custom=ubuntu-openvino:16.04
build_parallel_tests:Custom=1
test_modules:Custom=dnn
test_opencl:Custom=ON
test_bigdata:Custom=1
test_filter:Custom=*

@dkurt
dkurt force-pushed the dnn_async_samples branch 4 times, most recently from 89fd70e to 5ff42f4 Compare May 13, 2019 14:51

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is about protection of the queue size limit? (case where network FPS < capture FPS).

Latency information would be useful in async samples.

Comment thread samples/dnn/object_detection.py Outdated
import sys
import time
from threading import Thread
if sys.version[0] == '2':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.version_info[0] == 2

Comment thread samples/dnn/object_detection.py Resolved
predictionsQueue.put(np.copy(outs))

while futureOutputs and futureOutputs[0].wait_for(0) == 0:
out = futureOutputs[0].get()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, callback-based approach would look better here (instead of pulling).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it adds outputs in the order of frames. With callbacks we will need to introduce something like frames indices.

@dkurt
dkurt force-pushed the dnn_async_samples branch from 5ff42f4 to f7acb5c Compare May 14, 2019 05:53
@dkurt
dkurt force-pushed the dnn_async_samples branch from f7acb5c to c3b0a68 Compare May 14, 2019 06:59
@dkurt

dkurt commented May 14, 2019

Copy link
Copy Markdown
Member Author

Ported #14538 here.

@dkurt
dkurt force-pushed the dnn_async_samples branch from c830114 to 90f77cc Compare May 14, 2019 15:06
@alalek

alalek commented May 14, 2019

Copy link
Copy Markdown
Member

Please fix this warning:

object_detection.cpp(85): warning C4244: 'initializing': conversion from 'double' to 'float'

@dkurt
dkurt force-pushed the dnn_async_samples branch from 90f77cc to 63bb97c Compare May 14, 2019 16:09

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you 👍

@AlexeyAB

Copy link
Copy Markdown
Contributor

@dkurt
This is a very good improvement for detection performance.

  • It works well for VideoCamera, because FPS is limited.

  • But it works a bit strange for video files - very high capture_fps = 256 FPS, a lot of skipped frames. A five-minute video file is played in a several seconds. Everything flickers very fast on the screen.
    Perhaps better to limit the capture_fps = max(detection_fps, videofile_fps).

skip

@dkurt

dkurt commented Jul 15, 2019

Copy link
Copy Markdown
Member Author

@AlexeyAB, thanks! That's a good point. Feel free to propose a PR or open an issue.

@lblq2008

lblq2008 commented Jul 15, 2019 via email

Copy link
Copy Markdown

SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants