当前位置:网站首页>Video to image -cv2 Videocapture() usage
Video to image -cv2 Videocapture() usage
2022-06-30 00:39:00 【Ning Ranye】
purpose : Video frame extraction , Video visualization
1、cap = cv2.VideoCapture(0)
VideoCapture() Parameter is 0, Indicates that the built-in camera of the notebook is turned on , If the parameter is the path of the video file, open
Such as cap = cv2.VideoCapture(“…/test.avi”)
# If the parameter is the path of the video file, open
cap = cv2.VideoCapture('./RobustPCA_video_demo.avi')
2、ret,frame = cap.read()
cap.read() Read video by frame ,ret,frame Yes cap.read() Method .
among ret Boolean value , If the read frame is correct, return True, If the file reads to the end , Its return value is False.
frame It's the image of every frame , It's a three-dimensional matrix .
3、 cv2.destroyAllWindows() To delete a window ,() No parameters are specified in the , Delete all windows , Delete a specific window , Go to () Enter a specific window value .
4、 call release() Release camera , call destroyAllWindows() Close all image windows .
import cv2
# cv2.VideoCapture Video frame extraction , Video visualization
# If the parameter is the path of the video file, open
cap = cv2.VideoCapture('./RobustPCA_video_demo.avi')
all_frames = []
while(cap.isOpened()):
# ret Boolean value , If the read frame returns correctly true, When reading to the end, it will return false
# frame Is the image of each frame , It's a three-dimensional matrix
ret, frame = cap.read()
if not ret :
break
all_frames.append(frame)
cap.release()
cv2.destroyAllWindows()
cv2.VideoCapture() Usage and examples
cv2.waitKey() and cv2.destroyAllWindows()
边栏推荐
- Birds in the corn field
- 字节面试惨遭滑铁卢:一面就被吊打,幸得华为内推,三面拿到offer
- C MDI open subform to remove automatically generated menu bar
- 01 backpack problem
- MySQL deadlock
- About the case of SQL statements
- The SQL statement concat cannot find the result
- MySQL foundation 2
- VIM plug in manager VIM plug installation method
- Small and medium-sized enterprises should pay attention to these points when signing ERP contracts
猜你喜欢

开发者,为什么说容器技术的成熟预示着云原生时代的到来?

博途V16 更改PLC的型号和固件版本

Yunna | fixed assets system management, NC system management where are the fixed assets

Quick pow: how to quickly find power

MySQL advanced 2

干外包3年,真废了...

Distributed task scheduling elasticjob demo

外包干了三年,废的一踏糊涂...

云呐|如何利用系统管理固定资产?如何进行固定资产管理?

Yunna | advantages of fixed assets system management, what are the characteristics of fixed assets management system
随机推荐
[uitableview] Pit 1: tableview:heightforheaderinsection: method does not execute
传统微服务框架如何无缝过渡到服务网格 ASM
Swift notes
Go out and protect yourself
MySQL advanced 2
公司固定资产该哪个部门管理,一般公司固定资产怎么管理
MySQL基础篇1
How to seamlessly transition from traditional microservice framework to service grid ASM
太卷了~ 八股文,面试最强王者!
TwinCAT 3 EL7211模塊控制倍福伺服
IDEA中的常用设置
阿洛觉得自己迷茫
Some thoughts on life
降低打新的预期
01 backpack problem
Sofaregistry source code | data synchronization module analysis
Mysql Duplicate entry ‘xxx‘ for key ‘xxx‘
面试官:大量请求 Redis 不存在的数据,从而影响数据库,该如何解决?
Applying for let's encrypt SSL certificate with certbot
股票网上开户及开户流程怎样?还有,在线开户安全么?