opencv按空格保存图片

#include
#include "stdio.h"
#include

using namespace std;
using namespace cv;

int main()
{
	int ss = 80;
	char filename[200];
	VideoCapture camera = VideoCapture("things1.mp4");
	while (1){
		Mat image;
		camera >> image;
		cout << image.cols << " " << image.rows << endl;
		Mat img = image.clone();
		if (image.empty())
			break;
		resize(image, img, Size(640, 360));
		if (waitKey(50)== 32)
		{
			sprintf(filename, "%s%d%s", "images\\", ss++, ".jpg");
			imwrite(filename, img);
		}
		
		imshow("image", img);
	}
	return 0;
}


你可能感兴趣的:(技术--opencv与视觉)