Ask Your Question
0

How to use multiprocessing with OpenCV-C++ ?

asked 2020-03-02 02:31:48 -0600

ToanVnET gravatar image

Hi,

I'm a newbie in OpenCV-C++. Recently, I tried multithread with OpenCV-C++ but not reach my goal. So I try to using multiprocessing with OpenCV-C++. But unfortunately, I can not find any relevant results.

Is multiprocessing feature available on OpenCV-C++ ? If It's available, How to use it ?

Thank you so much,

Toan

edit retag flag offensive close merge delete

Comments

A lot of things in OpenCV are parallelized by default if you use, for example, the forEach member function. Many of the function implementations are parallized as well so it'd help us to describe what exactly you're trying to do.

exbigboss gravatar imageexbigboss ( 2020-03-02 17:41:22 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2020-03-02 19:10:54 -0600

HYPEREGO gravatar image

You need to compile OpenCV from the sources with some flags such as TBB for best multithreading performances. Moreover you can set many flags, I sugget you to use CMake GUI and check it. If the time execution matters, I suggest you to compile in RELEASE mode and not in debug mode: doing so the resulting binary will be more compact and the execution time is just impressive comparing to the DEBUG mode. Activating CUDA is also a good choice. If you don't need debug, then I suggest to you this:

cmake -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_IPP=ON -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=OFF -D WITH_NVCUVID=ON -D WITH_CUDA=ON -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D WITH_CSTRIPES=ON -D WITH_OPENCL=ON CMAKE_INSTALL_PREFIX=/usr/local/ ..

If you need debug or just want an idea, go here

P.S. = similar question that have the same link I gave here is this one

edit flag offensive delete link more

Comments

Hi @HYPEREGO, thank you for your useful answer. I found some information which concern about TBB. TBB has separately function but It's quite complex. Do you have any example about using TBB to read and write video or something else ? I used multithread to read and write video but video quality is lower than not using.

ToanVnET gravatar imageToanVnET ( 2020-03-02 20:10:00 -0600 )edit
1

Honestly I never used it explicitly, some part of OpenCV are internally already parallelized, so compile the source activating TBB can give to you a smaller speedup in any case. I found this thread, this tutorial (switch the version of your opencv on the top), and this tutorial. Take attention to the data flow and parallelize only the part that give to you a real advantage. Unfortunately I can't give to you more information, because I've not that much experience

HYPEREGO gravatar imageHYPEREGO ( 2020-03-03 03:27:25 -0600 )edit
1

I also add this resource. As stated here, some part internally in OpenCV are already parallelized

HYPEREGO gravatar imageHYPEREGO ( 2020-03-03 03:29:20 -0600 )edit
1

answered 2020-03-02 17:41:13 -0600

exbigboss gravatar image

A lot of things in OpenCV are parallelized by default if you use, for example, the forEach member function. Many of the function implementations are parallized as well so it'd help us to describe what exactly you're trying to do.

edit flag offensive delete link more

Comments

Thank you for your useful information. :)

ToanVnET gravatar imageToanVnET ( 2020-03-02 20:11:22 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-02 02:31:48 -0600

Seen: 1,052 times

Last updated: Mar 02 '20