Answer the question
In order to leave comments, you need to log in
OpenCV multi-threaded search in video?
Greetings!
I wrote a Qt program using OpenCV under Ubuntu that looks for the position in a video file from a photo from the screen, for example.
The path to the video is set, the path to the image after processing is given time in seconds.
I decided to optimize by adding a split search into available processor cores.
Each thread selects a core, initializes its VideoCapture, starts searching from a certain position and for a certain number of frames.
Everything works correctly, in my case, all 12 cores are loaded at one hundred percent, unlike the first version that loaded one core.
BUT!... The search is about 10 times slower...
What could be the reason for this?
Answer the question
In order to leave comments, you need to log in
each core performs the same task
try (if possible) split the video into squares by cores
All answers are on the nvidia website. Gpu gives a performance increase of 15 times compared to cpu. There is another program, thanks to which you can be 17 times more productive. Caffe look, convolutional neural network. It processes the video twice - cutting the video into Horizontal stripes for the number of cores, then into vertical ones. I can't provide links. Opencv - 1 recognition layer. Convolutional neural network - from eight.
Try disabling OpenCL and CUDA support at the opencv build stage.
The file is on disk, in the case of a single-threaded program, you sequentially, byte by byte, read the file.
In the case of multithreaded, the disk is forced to turn the head back and forth, i.e. data access time increases.
That. the drive can be the bottleneck for your system. The fact that it shows 100% load for processors does not mean anything.
The second option: inside OpenCV, there may be some kind of shared resource that cannot be used simultaneously by all threads. That. perhaps (I'm not an expert), it is enough to compile OpenCV with multithreading support.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question