OpenCV Python Tutorial
OpenCV Python Resources
Selected Reading
- OpenCV Python - Digit Recognition
- OpenCV Python - Feature Matching
- OpenCV Python - Feature Detection
- OpenCV Python - Meanshift/Camshift
- OpenCV Python - Face Detection
- OpenCV Python - Video from Images
- OpenCV Python - Images From Video
- OpenCV Python - Play Videos
- OpenCV Python - Capture Videos
- OpenCV Python - Fourier Transform
- OpenCV Python - Image Blending
- OpenCV Python - Image Addition
- OpenCV Python - Image Pyramids
- OpenCV Python - Template Matching
- OpenCV Python - Image Contours
- OpenCV Python - Transformations
- OpenCV Python - Color Spaces
- OpenCV Python - Histogram
- OpenCV Python - Edge Detection
- OpenCV Python - Image Filtering
- OpenCV Python - Image Threshold
- OpenCV Python - Resize and Rotate
- OpenCV Python - Add Trackbar
- OpenCV Python - Mouse Events
- OpenCV Python - Shapes and Text
- OpenCV Python - Bitwise Operations
- OpenCV Python - Image Properties
- OpenCV Python - Using Matplotlib
- OpenCV Python - Write Image
- OpenCV Python - Reading Image
- OpenCV Python - Environment
- OpenCV Python - Overview
- OpenCV Python - Home
OpenCV Python Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
OpenCV Python - Video from Images
OpenCV Python - Video from Images
In the previous chapter, we have used the VideoWriter() function to save the pve stream from a camera as a video file. To stitch multiple images into a video, we shall use the same function.
First, ensure that all the required images are in a folder. Python’s glob() function in the built-in glob module builds an array of images so that we can iterate through it.
Read the image object from the images in the folder and append to an image array.
Following program explains how to stitch multiple images in a video −
import cv2 import numpy as np import glob img_array = [] for filename in glob.glob( *.png ): img = cv2.imread(filename) height, width, layers = img.shape size = (width,height) img_array.append(img)
The create a video stream by using VideoWriter() function to write the contents of the image array to it. Given below is the program for the same.
out = cv2.VideoWriter( video.avi ,cv2.VideoWriter_fourcc(* DIVX ), 15, size) for i in range(len(img_array)): out.write(img_array[i]) out.release()
You should find the file named ‘video.avi’ in the current folder.
Advertisements