Free from the students found a openwrt, suddenly think up OpenCV can easily open their own camera, just began to learn OpenCV opened a number of notebook camera, OPENCV can open webcam it. Search data in Baidu to see others have done opencv+openwrt do wireless monitoring project, feel OpenCV from webcam to get video can also be achieved, other forums also found relevant information. I tried on my own computer to try the beginning is always not, the direct error can not find the camera, this problem is very depressing to me. But in the end it was solved:
Attached below is a program:
#include "Cv.h"
#include "highgui.h"
#include <iostream>
int main (int, char**) {
Cv::videocapture Vcap;
Cv::mat image;
Cvcapture *capture;
Const std::string videostreamaddress = "Http://192.168.1.1:8080/?action=stream?dummy=param.mjpg";
/* It May is an MJPEG stream,
e.g. "http://user:pass@cam_address:8081/cgi/mjpg/mjpg.cgi?.mjpg" * *
Open the video stream and make sure it ' s opened
if (!vcap.open (videostreamaddress)) {
Std::cout << "Error opening video stream or file" << Std::endl;
return-1;
}
Create Output window for displaying frames.
It ' s important to create this window outside of the ' for ' Loop
Otherwise this window would be created automatically the
' Imshow (...) ', which is very inefficient.
Cv::namedwindow ("Output window");
for (;;) {
if (!vcap.read (image)) {
Std::cout << "No frame" << Std::endl;
Cv::waitkey ();
}
Cv::imshow ("Output window", image);
if (Cv::waitkey (1) >= 0) break;
}
}