The code given below is for accessing an Axis IP camera using OpenCV. On running the program it first displays "Error in opening cap_ffmpeg_impl..." and then it displays Camera not found.
#include <opencv\cv.h>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
int main()
{
Mat frame;
namedWindow("video", 1);
VideoCapture cap("http://IPADDRESS/video.mjpg");
if(!cap.isOpened())
{
cout<<"Camera not found"<<endl;
getchar();
return -1;
}
while ( cap.isOpened() )
{
cap >> frame;
if(frame.empty()) break;
imshow("video", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}
Where am I going wrong?
I installed "Mini WebCam" app on my iphone and used it as an ip camera with "http://192.168.1.103" as it's address. In addition I used this piece of code:
it works.(http://192.168.1.103/video.cgi?.mjpg)
The following works for an Axis M1004-W connected to my computer via ethernet cable:
/mjpg/video.mjpg
, and I bet yours will be similar.The address you give to OpenCV should look like this:
This is what mine looks like:
I entered my address into your code and can see the video stream from an OpenCV window.
I faced similar problem when trying to display IP camera using the public IP camera. Opencv needs some typical kind of URL to open the camera.Try the URL from below code. Heres the code that worked for me.
Copy this code as it is and try.