opencv摄像头读取图片

# 摄像头捕获图像或视频
import
numpy as np import cv2
# 创建相机的对象 cap
= cv2.VideoCapture(0) while(True):   # 读取相机所拍到的图片   ret, frame = cap.read()   # 给这个frame添加自适应的颜色   # gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)   # 将这个   # cv2.imshow('frame',gray)
  # 将这个frame显示出来
  cv2.imshow('frame',frame)
# 判断退出的条件
  if cv2.waitKey(1) & 0xFF == ord('q'): break 

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

 

posted @ 2019-05-27 20:33  随性岁分享  阅读(456)  评论(0编辑  收藏  举报