Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Displaying the coordinates of the points clicked on the image using Python-OpenCV
Next article icon

OpenCV comes with many powerful video editing functions. In the current scenario, techniques such as image scanning and face recognition can be accomplished using OpenCV. OpenCV library can be used to perform multiple operations on videos. Let’s try to do something interesting using CV2. Take a video as input and break the video into frame by frame and save those frames. Now, a number of operations can be performed on these frames. Like reversing the video file or cropping the video etc. For playing video in reverse mode, we need only to store the frames in a list and iterate reverse in the list of frames. Use the reverse method of the list to reverse the order of frames in the list. 

Function Used:

VideoCapture(File_path) : Read the video(.mp4 format) 

read(): Read data depending upon the type of object that callsimwrite(filename, img[, params]) :Saves an image to a specified file.

Below is the implementation: 

Python3
# Program To Read video# and Extract Framesimportcv2# Function to extract framesdefFrameCapture(path):# Path to video filevidObj=cv2.VideoCapture(path)# Used as counter variablecount=0# checks whether frames were extractedsuccess=1whilesuccess:# vidObj object calls read# function extract framessuccess,image=vidObj.read()# Saves the frames with frame-countcv2.imwrite("frame%d.jpg"%count,image)count+=1# Driver Codeif__name__=='__main__':# Calling the functionFrameCapture("C:\\Users\\Admin\\PycharmProjects\\project_1\\openCV.mp4")

Output:


Improve
Article Tags :
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp