cvQueryFrame returns over 100 seconds with 20 threads..

asked 2014-06-30 04:12:25 -0500

ur_special gravatar image

updated 2014-06-30 04:28:13 -0500

I'm using OpenCV 2.4.2 playing 20 RTSP videos in an application. That application contains 20 threads which manage 1 rtsp connection per thread.

Each thread calls cvCaptureFromFile for connection, calls cvQueryFrame for grabbing images.

For just one thread running, after successful connection to the rtsp video, when I remove rtsp video source, cvQueryFrame returns in 10 seconds. it's ignorable enough.

But when it runs 20 threads, (getting the same video A) when I remove rtsp video source(A), cvQueryFrame returns over 150 seconds (for each thread) It's too long to wait, so the application become not to react user's control anymore.

Is there any solution to shorten response time(the time to return: cvQueryFrame)? Can't I use cvQueryFrame in threads? it works like running within just one thread..


my code in capture thread

'dwTickElapsed' is over 100 seconds when the video source removed under the situation which the app runs 20 thread capturing the same video.

DWORD dwTick1 = GetTickCount();
IplImage* frame = cvQueryFrame(pCapture);
DWORD dwTick2 = GetTickCount();

DWORD dwTickElapsed = dwTick2 - dwTick1;
edit retag flag offensive close merge delete