Cv :: VideoCapture works for webcams, but not for IP cameras?

It was about to happen, I was stuck at the last stage of my project when I want to use my code, which works like a charm on my webcam, on an IP camera. The URL works fine in my browser, but nothing works with OpenCV ... Here is my code:

#include <opencv/highgui.h> using namespace cv; int main(int argc, char *argv[]) { Mat frame; namedWindow("video", 1); VideoCapture cap("http://192.168.1.99:99/videostream.cgi?resolution=32&rate=0&user=admin&pwd=password&.mjpg"); while ( cap.isOpened() ) { cap >> frame; if(frame.empty()) break; imshow("video", frame); if(waitKey(30) >= 0) break; } return 0; } 

And compiler settings:

 //Added to the .pro file of QtCreator INCLUDEPATH += C:\\OpenCV243\\release\\include LIBS += -LC:\\OpenCV243\\release\\lib \ -lopencv_core243.dll \ -lopencv_highgui243.dll 

I tested opening the .avi file with the same code and it works ... But the regular IP camera URL, such as http://66.184.211.231/mjpg/video.mjpg , does not work! What then happens?

Deleted by editing: I considered FFMPEG a problem, but v2.4.3. has native support for FFMPEG and .avi files, although I don't have the FFMPEG library installed (need to be explained?)

Thanks in advance,

Regards, Mr Mr

+6
source share
2 answers

I solved it by copying opencv_ffmpeg.dll from the build \ x86 \ mingw \ bin folder of the sources and pasting it next to the built-in DLLs (the folder with bits accessible via PATH): I have no idea why, but opencv_ffmpeg_64.dll were made instead.

+5
source

Since you can connect and capture frames from a webcam, I think your library is configured correctly, and you should be able to connect to IP cameras. I believe the problem is with the specified camera url.

Try to enter the camera and disable its password protection. Remove the login and password fields from the URL, so it will be something like "http://192.168.1.99:99/videostream.cgi?resolution=32&.mjpg" . In addition, you can enter the camera and check its resolution. I noticed that you have resolution=32 , but I think it should be something like resolution=704x480 .

Hope this helps.

+2
source

Source: https://habr.com/ru/post/944571/


All Articles