============
1、读取摄像头画面并转换为灰度图
import numpy as np import cv2 cap = cv2.VideoCapture(0) while(True): # 按帧读取 ret, frame = cap.read() # Our operations on the frame come here gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # 显示画面 cv2.imshow('frame',frame) cv2.imshow('gray',gray) if cv2.waitKey(20) & 0xFF == ord('q'): break # 完成后释放资源 cap.release() cv2.destroyAllWindows()
============
Copyright © 2015 - 2016 DISPACE.NET | 使用帮助 | 关于我们 | 投诉建议