- Mastering OpenCV 4 with Python
- Alberto Fernández Villán
- 121字
- 2021-07-02 12:07:17
Reading a video file
cv2.VideoCapture also allows us to read a video file. Therefore, to read a video file, the path to the video file should be provided when creating the cv2.VideoCapture object:
# We first create the ArgumentParser object
# The created object 'parser' will have the necessary information
# to parse the command-line arguments into data types.
parser = argparse.ArgumentParser()
# We add 'video_path' argument using add_argument() including a help.
parser.add_argument("video_path", help="path to the video file")
args = parser.parse_args()
# Create a VideoCapture object. In this case, the argument is the video file name:
capture = cv2.VideoCapture(args.video_path)
Check out read_video_file.py to see the full example of how to read and display a video file using cv2.VideoCapture.
推薦閱讀
- Visual C++程序設計教程
- 一步一步學Spring Boot 2:微服務項目實戰
- SOA實踐
- 零基礎學C++程序設計
- Learning Real-time Processing with Spark Streaming
- 構建移動網站與APP:HTML 5移動開發入門與實戰(跨平臺移動開發叢書)
- Rust編程從入門到實戰
- Java編程指南:基礎知識、類庫應用及案例設計
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第2版)
- 正則表達式經典實例(第2版)
- Angular開發入門與實戰
- 移動互聯網軟件開發實驗指導
- LabVIEW虛擬儀器入門與測控應用100例
- 計算機應用基礎教程(Windows 7+Office 2010)
- Kubernetes進階實戰