Imvideo helps you create time-lapse videos from camera-generated image folder and your matplotlib loop.
To install this package, type pip install imvideo in command prompt.
C:\Users\user>pip install imvideoCollecting imvideo Using cached imvideo-0.0.1-py3-none-any.whl (3.6 kB)Installing collected packages: imvideoSuccessfully installed imvideo-0.0.1Class local: timelapse(title, fps, folder_path, inspect=True):
xxxxxxxxxxtimelapse(title, fps, folder_path, inspect=True):Function constructs time-lapse video from images in a folder.Inputs: title (string) video title + .avifps (double) time-lapse video frames per secondfolder_path (raw string) location of the image folderinspect (boolean) True (default)/FalseOutput:time-lapse video
Class memory: savebuff(frame, container):
xxxxxxxxxxsavebuff(frame, container):Function saves image in in-memory locationInputs: frame (matplotlib image)container (list) empty image containerOutput: container (list) image container with added frame location
construct(container, title, fps, inspect=True):
xxxxxxxxxxconstruct(container, title, fps, inspect=True):Function constructs video from images in the container.Inputs: container (list) image container with frame locationtitle (string) video title + .avifps (double) time-lapse video frames per secondinspect (boolean) True (default)/FalseOutput:video
ximport imvideo as imvimv.local.timelapse('demo.avi', 5, r".\tests\test_image"))xxxxxxxxxximport imvideo as imvdef test_matplot_loop(n): ''' Input: n number of frames''' images = [] # empty image container plt.figure() for i in range(n): plt.plot([np.random.randint(2), np.random.randint(2)]) plt.title("test" + str(i)) images = imv.memory.savebuff(plt, images) # save image in in-memory location plt.close() imv.memory.construct(images, 'matplot_demo.avi', 5) # construct video; 5 fps return test_matplot_loop(100) # construct a demo video with 100 frames