Reputation: 53
I have tried many ways but some programs give me a gray color empty screen and another just exit the code detecting camera can not be accessed but couldn't find a solution even though program are successfully build in opencv.
I am using Microsoft Visual Studio 2010 with Opencv 2.4.3
These are the specification of my camera.
Upvotes: 2
Views: 13186
Reputation: 7146
First you need to discovery the rtsp url of your ONVIF camera. Than you use the code at the @Mayur answered replacing the rtsp url by your rtsp url.
To discovery your rtsp url you can look for on this list: http://www.soleratec.com/support/rtsp/rtsp_listing
Or use some software that find it, I recommend the software onvif-device-tool (link) or the gsoap-onvif (link), both works on Linux, look at your terminal, the rtsp url will be there. After discovery the rtsp url I recommend to test it on vlc player (link), you can test using the menu option "opening network stream" or from command line:
vlc rtsp://your_url
Upvotes: 1
Reputation: 799
Here's the code which worked for me.
#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://USERID:PASSWORD@IPADDRESS:PORT/video.cgi?resolution=640x360&req_fps=50&.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;
}
Upvotes: 5
Reputation: 14053
You can use OpenCV VideoCaptur class to open video streaming from web
Using
VideoCapture cap;
cap.open(192.168.1.180/?action=stream?dummy=param.mjpg);
Also refer the answer on below links
Ip-network-camera-access using OpenCV
Upvotes: 1