当前位置:网站首页>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()
边栏推荐
- Briefly: how are fragments communicated?
- C MDI open subform to remove automatically generated menu bar
- Database learning notes (sql03)
- [PHP] PHP pressure test, error reporting: generally, each socket address (Protocol / network address / port) is only allowed to be used
- [lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network
- MySQL基础3
- php微信商家转账到零钱 发起商家转账API
- 【Spark】scala基础操作(持续更新)
- A Si's mood swings
- 简要的说一下:Fragment 间的通信方式?
猜你喜欢
随机推荐
How to design test cases
[PHP] PHP variable memory release
2022年最新最详细IDEA关联数据库方式、在IDEA中进行数据库的可视化操作(包含图解过程)
[PHP] PHP pressure test, error reporting: generally, each socket address (Protocol / network address / port) is only allowed to be used
岁月不饶人
YuMinHong: my retreat and advance; The five best software architecture patterns that architects must understand; Redis kills 52 consecutive questions | manong weekly VIP member exclusive email weekly
Which securities company is better and which platform is safer for stock speculation account opening
Initial i/o and its basic operations
Which securities company is better and which platform is safer for stock speculation account opening
微信支付 APP端 第三弹 申请退款
Statistical query of SQL Server database
Time flies that year
视频转图像-cv2.VideoCapture()用法
About SQL: create a view_ XB view, whose function is ① to delete views with duplicate names before creating them ② to display the number of male and female students in this class in the XSB table, and
【云原生】容器场景下的内核安全
IDEA中的常用设置
Store log files in RAM to reduce physical storage loss
Small and medium-sized enterprises should pay attention to these points when signing ERP contracts
Quick pow: how to quickly find power
间歇采样转发干扰









