OpenCV 连接 Android(安卓)IP摄像头
16lz
2022-03-12
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 0;}
注意里头的红色字符串!!一定一定要加!!!否则就是出错!!!我找了好久的原因最后发现因为这个!!!
加它的原因:
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:545)
3.参考资料
http://stackoverflow.com/questions/7266256/how-to-get-mjpg-stream-video-from-android-ipwebcam-using-opencv
google search: "opencv android ip camera"
花了我两天时间折腾啊!!!
更多相关文章
- Android(安卓)前置摄像头的默认是180度,导致应用拍照和录制视频是
- Android(安卓)摄像头后台采集
- Android开发错误信息收集
- 【android】Error: Static interface methods are only supporte
- 两个星期的Android开发
- Android(安卓)Sqlite Failed to open database(无法打开数据库文
- Android(安卓)studio b Error: No resource found that matches
- Android(安卓)Studio编译报错:sdk:minSdkVersion 1 cannot be sma
- (Android(安卓)jni) error: base operand of '->' has non-pointer