The full form of OpenCv is Open Source Computer Vision, using this library we can perform different operations on images, videos.
Application areas of OpenCV
- Facial recognition system
- Motion tracking
- Artificial neural network
- Deep neural network
- Video streaming etc.
For installing on Windows we can use this command line
pip install opencv-python
For Linux −
sudo apt-get install python-opencv
To complete our task we have to follow some steps −
Step 1: We import OpenCv library named cv2. Step 2: Take a video as input data. Step 3: First we break the video into a number of frames and store all these frames in a list. Step 4: When we are getting all the frames then we shall apply iteration method. Step 5: Here we apply iteration for reversing the list. Step 6: Use the reverse() method for reversing the order of the frames in the list.
Example code
import cv2 # Grab the current frame. my_check , vid = cap.read() # use counter variable for # Counting frames counter = 0 check = True frame_list = [] while(check == True): cv2.imwrite("frame%d.jpg" %counter , vid) check , vid = cap.read() frame_list.append(vid) # increment the counter by 1 counter += 1 frame_list.pop() # looping in the List of frames. for frame in frame_list: # show the frame. cv2.imshow("Frame" , frame) if cv2.waitKey(25) and 0xFF == ord("q"): break cap.release() # close any open windows cv2.destroyAllWindows() frame_list.reverse() for frame in frame_list: cv2.imshow("Frame" , frame) if cv2.waitKey(25) and 0xFF == ord("q"): break cap.release() cv2.destroyAllWindows()