Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV network (IP) camera frames per second slow after initial burst
    primarykey
    data
    text
    <p>EDIT: Upgrading to OpenCV 2.4.2 and FFMPEG 0.11.1 seems to have solved all the errors and connection problems, but it still hasn't solved the slow-down of frame rate.</p> <p>I am using the default OpenCV package in Ubuntu 12.04 which I believe is 2.3.1. I am connecting to a Foscam FI8910W which streams MJPEG. I have seen where people have said that the best way is to use opencv+libjpeg+curl since <a href="http://opencv-users.1802565.n2.nabble.com/Integration-of-Gstreamer-with-Opencv-code-td7196046.html" rel="nofollow">it is faster than the gstreamer solution</a>. However, I can occasionally (50% of the time) connect to the camera from OpenCV as it is built and get a video stream. This stream starts out at around 30 fps for about 1 s but then slows down to 5-10 fps. The project I am working on will require having 6 of cameras preferably running at 15-30 fps (faster is better).</p> <p>Here are my questions:</p> <ol> <li>Is this a problem that is fixed in 2.4.2 and I should just upgrade? </li> <li>If not, any ideas why I get a short burst and then it slows down?</li> <li>Is the best solution still to use curl+libjpeg?</li> <li>I see lots of people who say that solutions have been posted, but very few actual links to posts with solutions. Having all the actual solutions (both curl and gstreamer) referenced in one place would be very handy as per <a href="http://opencv-users.1802565.n2.nabble.com/IP-camera-solution-td7345005.html" rel="nofollow">http://opencv-users.1802565.n2.nabble.com/IP-camera-solution-td7345005.html</a>.</li> </ol> <p>Here is my code:</p> <pre><code> VideoCapture cap; cap.open("http://10.10.1.10/videostream.asf?user=test&amp;pwd=1234&amp;resolution=32"); Mat frame; cap &gt;&gt; frame; wr.open("test.avi", CV_FOURCC('P','I','M','1'), 29.92, frame.size(), true); if(!wr.isOpened()) { cout &lt;&lt; "Video writer open failed" &lt;&lt; endl; return(-1); } Mat dst = Mat::zeros(frame.rows + HEADER_HEIGHT, frame.cols, CV_8UC3); Mat roi(dst, Rect(0, HEADER_HEIGHT-1, frame.cols, frame.rows)); Mat head(dst, Rect(0,0,frame.cols, HEADER_HEIGHT)); Mat zhead = Mat::zeros(head.rows, head.cols, CV_8UC3); namedWindow("test", 1); time_t tnow; tm *tS; double t1 = (double)getTickCount(); double t2; for(int i = 0; i&gt;-1 ; i++) // infinite loop { cap &gt;&gt; frame; if(!frame.data) break; tnow = time(0); tS = localtime(&amp;tnow); frame.copyTo(roi); std::ostringstream L1, L2; L1 &lt;&lt; tS-&gt;tm_year+1900 &lt;&lt; " " &lt;&lt; coutPrep &lt;&lt; tS-&gt;tm_mon+1 &lt;&lt; " "; L1 &lt;&lt; coutPrep &lt;&lt; tS-&gt;tm_mday &lt;&lt; " "; L1 &lt;&lt; coutPrep &lt;&lt; tS-&gt;tm_hour; L1 &lt;&lt; ":" &lt;&lt; coutPrep &lt;&lt; tS-&gt;tm_min &lt;&lt; ":" &lt;&lt; coutPrep &lt;&lt; tS-&gt;tm_sec; actValueStr = L1.str(); zhead.copyTo(head); putText(dst, actValueStr, Point(0,HEADER_HEIGHT/2), fontFace, fontScale, Scalar(0,255,0), fontThickness, 8); L2 &lt;&lt; "Frame: " &lt;&lt; i; t2 = (double)getTickCount(); L2 &lt;&lt; " " &lt;&lt; (t2 - t1)/getTickFrequency()*1000. &lt;&lt; " ms"; t1 = (double)getTickCount(); actValueStr = L2.str(); putText(dst, actValueStr, Point(0,HEADER_HEIGHT), fontFace, fontScale, Scalar(0,255,0), fontThickness, 8); imshow("test", dst); wr &lt;&lt; dst; // write frame to file cout &lt;&lt; "Frame: " &lt;&lt; i &lt;&lt; endl; if(waitKey(30) &gt;= 0) break; } </code></pre> <p>Here are the errors listed when it runs correctly:</p> <pre><code>Opening 10.10.1.10 Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later. Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later. [asf @ 0x701de0] max_analyze_duration reached [asf @ 0x701de0] Estimating duration from bitrate, this may be inaccurate [asf @ 0x701de0] ignoring invalid packet_obj_size (21084 656 21720 21740) [asf @ 0x701de0] freeing incomplete packet size 21720, new 21696 [asf @ 0x701de0] ff asf bad header 0 at:1029744 [asf @ 0x701de0] ff asf skip 678 (unknown stream) [asf @ 0x701de0] ff asf bad header 45 at:1030589 [asf @ 0x701de0] packet_obj_size invalid [asf @ 0x701de0] ff asf bad header 29 at:1049378 [asf @ 0x701de0] packet_obj_size invalid [asf @ 0x701de0] freeing incomplete packet size 21820, new 21684 [asf @ 0x701de0] freeing incomplete packet size 21684, new 21836 Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later. Using network protocols without global network initialization. Please use avformat_network_init(), this will become mandatory later. [asf @ 0x701de0] Estimating duration from bitrate, this may be inaccurate Successfully opened network camera [swscaler @ 0x8cf400] No accelerated colorspace conversion found from yuv422p to bgr24. Output #0, avi, to 'test.avi': Stream #0.0: Video: mpeg1video (hq), yuv420p, 640x480, q=2-31, 19660 kb/s, 90k tbn, 29.97 tbc [swscaler @ 0x9d25c0] No accelerated colorspace conversion found from yuv422p to bgr24. Frame: 0 [swscaler @ 0xa89f20] No accelerated colorspace conversion found from yuv422p to bgr24. Frame: 1 [swscaler @ 0x7f7840] No accelerated colorspace conversion found from yuv422p to bgr24. Frame: 2 [swscaler @ 0xb9e6c0] No accelerated colorspace conversion found from yuv422p to bgr24. Frame: 3 </code></pre> <p>Sometimes it hangs after the first <code>Estimating duration from bitrate</code> statement</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload