Ask Your Question
1

VideoCapture open starts many threads

asked 2015-11-18 12:22:43 -0600

genzm gravatar image

Hy,

I've noticed that when opening a video file using the VideoCapture class (in C++), about eight new threads are created. As I need 7 video files simultaneously this results in about 50 threads running. I was wondering why this happens and what the threads do (because I can't find anything about this online).

Thanks

edit retag flag offensive close merge delete

Comments

os ? opencv version ?

berak gravatar imageberak ( 2015-11-18 22:33:44 -0600 )edit

I'm sorry, ubuntu 14.04 and opencv 2.4.11

genzm gravatar imagegenzm ( 2015-11-19 01:19:32 -0600 )edit

Could you add your CMAKE configuration? I am interested in what build options you have used (might give a clue to where to look for the solution)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-19 07:52:42 -0600 )edit

Maybe I don't undestand your question but I think this is expected. On my win7, VideoCapture from cam opens 5 threads. In opencv many operations are in parallel. If you use cv::cvtColor you will see 4 threads more. In addiction the codec could have internal threads.

pklab gravatar imagepklab ( 2015-11-20 04:06:32 -0600 )edit
1

Yes, I understand that it is to make the decoding process faster. But decoding one video creates many threads. I can imagine quite a few use cases where you do not want to use your entire computational power to decode the video. It just seemed a little bit strange to have this as a default behaviour.

genzm gravatar imagegenzm ( 2015-11-26 11:38:36 -0600 )edit

@genzm you should be able to force your application only to use a single thread. If you built with OpenMP for example you can do it like this. Exactly the reason why I am asking your CMAKE output.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-27 04:09:40 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-26 11:40:45 -0600

genzm gravatar image

I found this line of code in the github repositories.

https://github.com/Itseez/opencv/blob...

Changing this line will determine how many threads get created when using ffmpeg. I changed this to two in my application. It is surprising that this is no parameter.

edit flag offensive delete link more

Comments

You might want to supply the functionality to parametrize this through a PR?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-27 04:10:16 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-18 12:22:43 -0600

Seen: 1,444 times

Last updated: Nov 26 '15