- 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.
推薦閱讀
- OpenShift開發指南(原書第2版)
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- Visual Basic編程:從基礎到實踐(第2版)
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰
- Neo4j Essentials
- WordPress Plugin Development Cookbook(Second Edition)
- 表哥的Access入門:以Excel視角快速學習數據庫開發(第2版)
- Learning OpenStack Networking(Neutron)(Second Edition)
- Lighttpd源碼分析
- Service Mesh實戰:基于Linkerd和Kubernetes的微服務實踐
- 區塊鏈技術進階與實戰(第2版)
- Developing Java Applications with Spring and Spring Boot
- INSTANT LESS CSS Preprocessor How-to
- Clojure Data Structures and Algorithms Cookbook
- R語言數據分析從入門到實戰