0

I'm trying to connect to a ip camera by rtsp protocoll to solve a object detection task, my issue is the access to the camera. I use the rtsp protocoll, and when I launch the system in release mode, after few minutes it gives me a bad memory access exception:

enter image description here

I access the camera using the following code:

VideoCapture cap; 
Mat src; 
cap.open("rtsp://<xxx>:<xxx>@ip_adress:554"); 

while(true){

    cap.copyTo(src);
    resize(src, src, Size(640, 480)); 
    imshow("source", src); 
    char k = (char)cv::waitKey(25);

    if (k == 27)
        break;
}

I process the frame to apply a neural network, and I don't figure why the system give me this exception, after 4/5 minutes.

Thank's.

ll_gzr
  • 99
  • 10
  • 1
    Why do you resize every time in the loop? And for the code it would be better, if you provide full example with headers, so that we can know which function resize and imshow "links" to – RoQuOTriX Feb 12 '20 at 08:58
  • I resize the frame every time because I capture with a resolution of 1920x1080. This aproach work fine when working with fixed camera, but I suppose the problem could be the latency of the ip camera that drops some frames when make the detections. Now while capturing and resizing the frames from the ip camera the system gives me this exception: !ssize.empty() in function 'cv::resize' – ll_gzr Feb 12 '20 at 10:10
  • Could you provide the call stack, when the error occurs? – RoQuOTriX Feb 12 '20 at 10:26
  • The exception that occours is: [EXCEPTION] ImageWithFrameIdx::Read(): OpenCV(4.1.2) C:\build\master_winpack-build-win64-vc14\opencv\modules\imgproc\src\resize.cpp:3720: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize' – ll_gzr Feb 12 '20 at 10:41
  • I'm using HikVision camera – ll_gzr Feb 12 '20 at 10:52
  • Thank's for answer, but I've to work in c++. I try to build a multithread architecture, but this implementation gives me always a latency of ~3 seconds. Now I'm test to use LibVLC to process each frame. – ll_gzr Feb 13 '20 at 08:25

0 Answers0