OpenCV 连接 Android IP摄像头

0.下载IP摄像头(android软件)并安装

比如这个(图标是一个灰色的摄像头的那个软件)

1.新建cpp文件,编译

#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv; int main(){
VideoCapture capture("http://192.168.0.100:8080/video?dummy=param.mjpg");
if(!capture.isOpened())cout<<"fail to open"<<endl;
else cout<<"Success!!!!!!!!!!!"<<endl;
return ;
}

注意里头的红色字符串!!一定一定要加!!!否则就是出错!!!我找了好久的原因最后发现因为这个!!!

加它的原因:

OpenCV expects a filename extension for its VideoCapture argument, even though one isn't always necessary (like in your case).

You can "trick" it by passing in a dummy parameter which ends in the mjpg extension:

意思就是:

虽然我们的ipCamera没有后缀,但是OpenCV很傻,一定要一个.mjpg之类的后缀才认,所以就骗它,这么加一个

(2.如果不怎么做就会报错)

warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:)

3.参考资料

http://*.com/questions/7266256/how-to-get-mjpg-stream-video-from-android-ipwebcam-using-opencv

google search: "opencv android ip camera"

花了我两天时间折腾啊!!!

上一篇:Atitit osi tcp ip 对应attilax总结


下一篇:数据结构与算法分析–Minimum Spanning Tree(最小生成树)