[Image Processing] folder multiple pictures together referred to as video _c ++

Folders multiple pictures together referred to as video _c ++

The same folder all the pictures into avi.
Picture naming requirements

0000.jpg,0001.jpg,0002.jpg。。。。

Generation video name save.avi.

void img2avi(char* address)
{
	assert(address != NULL);
	char buf[128];
	int nums = 1;
	sprintf(buf, "%s/%04d.jpg", address, nums);

	cv::Mat frame = cv::imread(buf);

	while(frame.data == NULL)
	{
		nums++;
		printf("num = %d\n", nums);
		sprintf(buf, "%s/%04d.jpg", address, nums);
		frame = cv::imread(buf);
	}

	cv::VideoWriter save;
	save.open("save.avi", CV_FOURCC('M','P','4','2'), 25.0, frame.size(), true);
	save << frame;
	nums++;

	while(frame.data != NULL)
	{
		sprintf(buf, "%s/%04d.jpg", address, nums++);
		frame = cv::imread(buf);
		save << frame;
	}
	save.release();
	printf("save over!\n");
}

Published 34 original articles · won praise 13 · views 6300

Guess you like

Origin blog.csdn.net/qq_35306281/article/details/104382450