opencv读取手机摄像头
【摘要】 http://192.168.0.101:8081/
测试:
浏览器可以直接输入网址,弹出框输入用户名密码进行读取。
opencv代码:#include <stdio.h>#include <opencv2/opencv.hpp>#include <iostream> int main(int, char**) { cv::Vi...
http://192.168.0.101:8081/
测试:
浏览器可以直接输入网址,弹出框输入用户名密码进行读取。
-
opencv代码:
-
#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://<username:password>@<ip_address>/video.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;
-
}
-
-
for(;;) {
-
if(!vcap.read(image)) {
-
std::cout << "No frame" << std::endl;
-
cv::waitKey();
-
}
-
cv::imshow("Output Window", image);
-
if(cv::waitKey(1) >= 0) break;
-
}
-
}
-
-
这个图是白色的:
CvCapture *camera=cvCaptureFromFile("http://admin:admin@192.168.1.2:8081/axis-cgi/mjpg/video.cgi?resolution=640x480&req_fps=30&.mjpg");
if (camera==NULL){
printf("camera is null\n");
return -1;
}
else printf("camera is not null");
cvNamedWindow("img");
while (cvWaitKey(10)!=atoi("q")){
double t1=(double)cvGetTickCount();
IplImage *img=cvQueryFrame(camera);
if(!img)break;
cvShowImage("img1",img);
double t2=(double)cvGetTickCount(); printf("time: %gms fps: %.2g\n",(t2-t1)/(cvGetTickFrequency()*1000.), 1000./((t2-t1)/(cvGetTickFrequency()*1000.)));
} cvReleaseCapture(&camera);
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/54983247
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)