# 从摄像头获取图像数据

cap = cv2.VideoCapture(0)

while(True):
    # ret 读取成功True或失败False
    # frame读取到的图像的内容
    # 读取一帧数据
    ret,frame = cap.read()
    # 变为灰度图
    gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
    cv2.imshow('frame',gray)
    # waitKey功能是不断刷新图像,单位ms,返回值是当前键盘按键值
    # ord返回对应的ASCII数值
    if cv2.waitKey(1) & 0xff == ord('q'):
        break
cap.release()
#摄像头释放
cv2.destroyAllWindows()
#窗口释放

读取摄像头

 

相关文章:

  • 2022-02-12
  • 2022-01-18
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-12-09
  • 2022-12-23
  • 2021-12-27
  • 2022-01-16
  • 2021-06-03
  • 2022-01-03
相关资源
相似解决方案