1, batch convert grayscale and save
#include <iostream> #include <opencv2/opencv.hpp> #include <string> using namespace cv; using namespace std; int main() { string fileName, grayFile; for(int i = 101; i <= 150; i++) for(int j = 0; j <= 23; j++) { //int 转换为 string stringstream ss1,ss2; string str1, str2; ss1 << i; ss1 >> str1; ss2 << j; ss2 >> str2; fileName = "srcImage/Tester_" + str1 + "TrainingPosepose_" + str2 + ".jpg"; grayFile = "grayImage/Gray_Tester_" + str1 + "TrainingPosepose_" + str2 + ".jpg"; //cout << fileName << endl; Mat srcImage = imread(fileName), grayImage; cvtColor(srcImage,grayImage,CV_BGR2GRAY); imwrite( grayFile, grayImage); } system("pause"); return 0; }
opencv batch conversion of grayscale and save - kuotian - blog Park https://www.cnblogs.com/kuotian/p/6365613.html
2, reading video files, video display
VideoCapture(0);
- VideoCapture capture;
- capture.open ( "video.mp4"); Method class // VideoCapture
- // 0:00 to open the usb camera. Enter a correct URL, you can load videos on the web
fourcc = cv2.VideoWriter_fourcc (* 'XVID') # specify the encoding format, Windows uses XVID, note that the wording is fixed
out = cv2.VideoWriter ( 'output.avi', fourcc, 20.0, (640,480)) # define a video storage object, and a video encoding method, frame rate, video format size, and finally a grayscale setting (default True color, but I tried to change the video False generate an error occurs)
OpenCV study notes (2) - How to process the video with OpenCV - blog Park - Zodiac7 https://www.cnblogs.com/zodiac7/p/9270529.htm L
The study notes --Opencv video processing module - gwpscut's blog - CSDN blog https://blog.csdn.net/gwplovekimi/article/details/80545274