日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

opencv 打开网络摄像头

發布時間:2023/12/14 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 opencv 打开网络摄像头 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

閑著沒事從同學那里找到了個openwrt ? ,突然間想起來OPENCV可以很輕松的打開自帶的攝像頭,剛開始學習OPENCV 打開過若干次筆記本的攝像頭,OPENCV能否打開網絡攝像頭呢?在百度上搜資料看到別人曾經做到過OPENCV+openwrt做無線監控的項目,覺得OPENCV從網絡攝像頭獲取視頻也必定可以實現,其他的論壇里也找到過相關的資料 ?。我在自己的電腦上面試試了試剛開始老是不行,直接報錯找不到攝像頭,這個問題很是讓我郁悶。不過最后還是解決了:


下面附上程序 :

#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 be an address of 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 will be created automatically each time you call
? ? //`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;
??
? ? } ??
}







總結

以上是生活随笔為你收集整理的opencv 打开网络摄像头的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。