Ask Your Question

Leonardo's profile - activity

2018-12-19 02:01:45 -0600 received badge  Famous Question (source)
2017-12-20 06:35:59 -0600 received badge  Notable Question (source)
2017-08-09 01:09:55 -0600 received badge  Popular Question (source)
2017-02-09 09:27:11 -0600 received badge  Student (source)
2017-02-09 04:56:04 -0600 commented question cv::VideoCapture leaks memory on ethernet cams?

Done! https://github.com/opencv/opencv/issues/8151 (Issue_8151)

2017-02-09 04:55:09 -0600 received badge  Enthusiast
2017-02-08 13:42:41 -0600 commented question IP Camera Capture delay/lag

Real answer is:You need to grab as fast as the camera fps, else it goes to a buffer, and it causes lag.

2017-02-08 13:37:05 -0600 asked a question cv::VideoCapture leaks memory on ethernet cams?

Hello!

I have been noticing my software memory usage grows (slowly) over time.

I used to believe it was some kind of buffer. But after I let it running overnight, and it crashed because it was out of memory, I had to debug.

I found out if disable grab() and replace retrieve() for a still image, memory usage doesn't grow. A still image runs my algorithm normally.

My software uses 8 VideoCapture instances in RTSP Ethernet Cameras, each one in it's thread, at around 5FPS.

  • After I re-enabled grab(), but not retrieve, the software grown 80MB in 1h23m.
  • After I re-enabled grab and retrieve, the software grown 120MB in 16min.

Question is:

  • Is there a way cv::VideoCapture leaks any memory, for rtsp ethernet cameras?
  • Is there any kind of buffer I can configure?
  • Is there any kind of "clean buffer" I am not aware of?

More info:

  • I sometimes get an error : " [rtsp @ 0xXXXXXXXXXXXX] Too short data for FU-A H.264 RTP packet"
  • I am using OpenCV 3.2 on Linux 64-bits.
  • I have to do 5 grabs for 1 retrieve, so my image don't get delays.

Any help will be appreciated.

2016-09-28 13:17:28 -0600 commented question IP Camera Capture delay/lag

I could get good lag results on VLC, after reducing cache/buffer to 300ms, I believe network and processing are not to blame. Now I got a stronger feeling that cache is to blame

2016-09-28 13:17:21 -0600 commented question IP Camera Capture delay/lag

It May have something to do with VideoCapture buffer. Is there a way to make it aways use the latest image?

2016-09-28 08:24:01 -0600 commented answer IP Camera Capture delay/lag

Thanks for your asnwer!

Do you mean directly on Camera? If so, rtsp works 'well' on VLC, after I set network cache/buffer time to 300ms. So I believe there is no limitation on processing and the problem is something on network cache time on OpenCV that I may not be knowing how to set.

Can you help me with that?

2016-09-27 08:42:02 -0600 received badge  Editor (source)
2016-09-22 08:52:42 -0600 asked a question IP Camera Capture delay/lag

Hello,

I am trying to so some processing on a IP Camera (Onvif) output image, and it works well, but I see a lag between the real world and the video capture in about 3~4 seconds.

I am using the rtsp:// protocol.

This camera have a web interface (IE / ActiveX) that shows the image with very low lag. (about 200~300 ms).

I have no idea why it's so slow on OpenCV. I wold like some tips to make the capture faster.

edit: It May have something to do with VideoCapture buffer. Is there a way to make it aways use the latest image?

edit2: I could get good lag results on VLC, after reducing cache/buffer to 300ms, I believe network and processing are not to blame. Now I got a stronger feeling that cache is to blame

Thank you!

You can see the code I am using bellow, i also included the output:

CODE

#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <thread>
#include <unistd.h>

using namespace cv;
using namespace std;

int main(int argc, char *argv[])
{
    cout << getBuildInformation();
    VideoCapture cap;
    cout << "open stream: " << argv[1] << endl;
    if(!cap.open(argv[1]))
        exit(-1);
    cout << "stream open!\n";

    Mat test;
    do{
        cap >> test;

    if(test.empty()){
        cout << "Empty!\n";
    } else {
        imshow("imagem", test);
    }
} while(waitKey(1) < 0);

}

Output

leonardo@LeonardoB:~/Desktop/Ether_Test/build$ make ; ./EtherTest rtsp://admin:[email protected]:554/ucast/11
Scanning dependencies of target EtherTest
[ 50%] Building CXX object CMakeFiles/EtherTest.dir/main.cpp.o
[100%] Linking CXX executable EtherTest
[100%] Built target EtherTest

General configuration for OpenCV 3.1.0-dev =====================================
  Version control:               3.1.0-1362-gcde9d64

  Extra modules:
    Location (extra):            /home/leonardo/OpenCV/OpenCV3/opencv_contrib/modules
    Version control (extra):     3.1.0-297-g246ea8f

  Platform:
    Timestamp:                   2016-09-22T13:20:09Z
    Host:                        Linux 4.7.4-1-ARCH x86_64
    CMake:                       3.6.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      NO
    C++ Compiler:                /usr/bin/c++  (ver 6.2.1)
    C++ flags (Release):         -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fPIC   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations ...
(more)