如何通过按键保存图片呢???
import cv2
import 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()