Opencv4.5-C++ 摄像头画面镜像显示及文件保存
生活随笔
收集整理的這篇文章主要介紹了
Opencv4.5-C++ 摄像头画面镜像显示及文件保存
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
想試下新買電腦的攝像頭好用不,就寫了個攝像頭調用程序,實現了鏡像和圖片截取保存。
代碼
#include <iostream> #include <opencv2/stitching.hpp> #include <opencv2\opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> #include <stdio.h> #include <fstream>using namespace cv; using namespace std;int main() {VideoCapture capture(0);//參數為0,表示打開筆記本內置攝像頭;參數是視頻文件路徑則打開視頻while (true){Mat face;string savedfilename;string writePath = "C:/Users/xx/Desktop/";capture >> face;//讀取當前幀blur(face, face, Size(3, 3));//進行濾波flip(face, face, 1);//可以實現圖像反轉,參數(輸入,輸出,參數(1為y軸反轉,0為x軸反轉,負數為x,y反轉))//空格拍照if (32 == waitKey(10)){savedfilename = writePath + "xx" + ".jpg";imwrite(savedfilename, face);}imshow("讀取視頻", face);waitKey(100);}capture.release();return 0; }總結
以上是生活随笔為你收集整理的Opencv4.5-C++ 摄像头画面镜像显示及文件保存的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Python 代码】类似SADPToo
- 下一篇: 第三章 使用属性升级MyBank