opencv使用电脑摄像头抓取并保存图片,自动顺序命名保存的图片

xiaoxiao2021-02-28  47

#include"stdafx.h" #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> //#include<string> //#include<iostream> using namespace cv; int main() { VideoCapture cap(0); if (!cap.isOpened()) return -1; VideoCapture video_capture; video_capture.set(CV_CAP_PROP_FPS, 12); video_capture.set(CV_CAP_PROP_EXPOSURE, -12.0); video_capture.open(0); video_capture.set(CV_CAP_PROP_FOURCC, CV_FOURCC('M', 'J', 'P', 'G')); video_capture.set(CV_CAP_PROP_FRAME_WIDTH, 1920); video_capture.set(CV_CAP_PROP_FRAME_HEIGHT, 1080); Mat frame;         Mat edges; char str[10]; int i = 0; while(1) { cap >> frame; cvtColor(frame, edges, 0); imshow("a", edges); //if (std::cin.get() != '\n') if (waitKey(1) == 32) { sprintf_s(str, "%d%s", i++, ".jpg"); imwrite(str, edges); } else if(waitKey(1) == 27 ) break; } return 0; }opencv使用电脑摄像头抓取并保存图片,自动顺序命名保存的图片
转载请注明原文地址: https://www.6miu.com/read-2626288.html

最新回复(0)