想用opencv2.4.9+QT接收一个wifi模块传回的视频,根据网上的资料和实际情况,编写如下:const string addr="http://192.168.1.1:8080/?action=stream.mjpg";
VideoCapture cap(addr);
但是就是读不出来,我用浏览器可以显示视频,请问前辈们有遇到这种情况的么,是因为什么地方配置不对吗?还请指教
想用opencv2.4.9+QT接收一个wifi模块传回的视频,根据网上的资料和实际情况,编写如下:const string addr="http://192.168.1.1:8080/?action=stream.mjpg";
但是就是读不出来,我用浏览器可以显示视频,请问前辈们有遇到这种情况的么,是因为什么地方配置不对吗?还请指教
試試看我下免寫的 code. 我自己用的 video camera 會成功 !!
讀取 local video 方式如下:
#include <cstdio>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(){
VideoCapture video(0);
if (!video.isOpened()){
return -1;
}
Size videoSize = Size((int)video.get(CV_CAP_PROP_FRAME_WIDTH),(int)video.get(CV_CAP_PROP_FRAME_HEIGHT));
namedWindow("video demo", CV_WINDOW_AUTOSIZE);
Mat videoFrame;
while(true){
video >> videoFrame;
if(videoFrame.empty()){
break;
}
imshow("video demo", videoFrame);
waitKey(33);
}
return 0;
}
讀取遠端 video 方式如下:
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <iostream>
int main(int, char**) {
cv::VideoCapture vcap;
cv::Mat image;
// This works on a D-Link CDS-932L
const std::string videoStreamAddress = "http://USER:PWD@IPADDRESS:8088/mjpeg.cgi?user=USERNAME&password=PWD&channel=0&.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;
}
for(;;) {
if(!vcap.read(image)) {
std::cout << "No frame" << std::endl;
cv::waitKey();
}
cv::imshow("Output Window", image);
if(cv::waitKey(1) >= 0) break;
}
}