如何用Python和Matplotlib连接并打开相机?
- 内容介绍
- 文章标签
- 相关推荐
本文共计149个文字,预计阅读时间需要1分钟。
如何通过按键保存图片呢?pythonimport cv2import matplotlib.pyplot as pltcapture=cv2.VideoCapture(0)fig, ax=plt.subplots()plt.ion()if capture.isOpened(): while True:
如何通过按键保存图片呢???
import cv2import matplotlib.pyplot as plt
capture = cv2.VideoCapture(0)
fig = plt.figure()
plt.ion()
if capture is not None:
while (True):
# 获取一帧
ret, frame = capture.read()
if frame is not None:
# opencv
# cv2.imshow("camera", frame)
# cv2.waitKey(1)
# matplotlib
plt.imshow(frame)
plt.pause(0.1)
fig.clf()
else:
print("Fail to grab")
continue
else:
print("Fail to open camera")
plt.ioff()
本文共计149个文字,预计阅读时间需要1分钟。
如何通过按键保存图片呢?pythonimport cv2import matplotlib.pyplot as pltcapture=cv2.VideoCapture(0)fig, ax=plt.subplots()plt.ion()if capture.isOpened(): while True:
如何通过按键保存图片呢???
import cv2import matplotlib.pyplot as plt
capture = cv2.VideoCapture(0)
fig = plt.figure()
plt.ion()
if capture is not None:
while (True):
# 获取一帧
ret, frame = capture.read()
if frame is not None:
# opencv
# cv2.imshow("camera", frame)
# cv2.waitKey(1)
# matplotlib
plt.imshow(frame)
plt.pause(0.1)
fig.clf()
else:
print("Fail to grab")
continue
else:
print("Fail to open camera")
plt.ioff()

