- 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.
推薦閱讀
- Learning Microsoft Windows Server 2012 Dynamic Access Control
- INSTANT OpenCV Starter
- Linux核心技術(shù)從小白到大牛
- WordPress Plugin Development Cookbook(Second Edition)
- 網(wǎng)絡(luò)爬蟲原理與實(shí)踐:基于C#語言
- Redis Essentials
- Visual Basic程序設(shè)計(jì)
- Kotlin開發(fā)教程(全2冊)
- Go語言從入門到精通
- Web前端開發(fā)技術(shù):HTML、CSS、JavaScript
- SQL Server實(shí)例教程(2008版)
- Serverless工程實(shí)踐:從入門到進(jìn)階
- 生成藝術(shù):Processing視覺創(chuàng)意入門
- Testing Practitioner Handbook
- 軟件測試