- 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.
推薦閱讀
- .NET之美:.NET關鍵技術深入解析
- The Android Game Developer's Handbook
- Magento 2 Theme Design(Second Edition)
- Responsive Web Design with HTML5 and CSS3
- Apex Design Patterns
- Python:Master the Art of Design Patterns
- 編程數學
- Learning ArcGIS for Desktop
- Android系統原理及開發要點詳解
- Visual Basic程序設計實驗指導(第二版)
- 區塊鏈底層設計Java實戰
- Node Cookbook(Second Edition)
- Getting Started with Python
- Vue.js 3應用開發與核心源碼解析
- Python Web自動化測試設計與實現