Create video from images with VideoCapture (OpenCV)
I would like to write all my image files named "pictures_1 / 2/3 / etc ..." into a video file.
The code below creates the video.avi file successfully. However, there is no data written inside the latter.
I know that the video capture function is mainly used for capturing data from video, but I heard that it is possible to use it for images too ( as described here (1st answer))
void video (void)
{
VideoCapture in_capture("/path/.../pictures_%d.jpg");
Mat img;
VideoWriter out_capture("path/.../video.avi", CV_FOURCC('M','J','P','G'), 30, Size(1989,1680));
while (true)
{
in_capture >> img;
if(img.empty())
break;
out_capture.write(img);
}
}
+1
user1197918
source
to share
1 answer