迅维网
标题:
Python 调用 本机摄像头
[打印本页]
作者:
zty19911020
时间:
2017-10-23 19:52
标题:
Python 调用 本机摄像头
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
#cv2.imshow('frame',frame)
ret,img_encode = cv2.imencode('.jpg', frame)
data_encode = np.array(img_encode)
str_encode = img_encode.tostring()
nparr = np.fromstring(str_encode, np.uint8)
img_decode = cv2.imdecode(nparr, 1)
cv2.imshow('frame',img_decode)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
作者:
バ幸福De右岸
时间:
2017-10-24 10:49
这个需要翻译才可以使用吗?
作者:
バ幸福De右岸
时间:
2017-10-24 10:49
这个需要翻译才可以使用吗?
作者:
zty19911020
时间:
2017-10-28 11:38
不需要,Python2.7以上版本可以运行
作者:
zty19911020
时间:
2017-10-28 11:53
バ幸福De右岸 发表于 2017-10-24 10:49
这个需要翻译才可以使用吗?
你学Python?这个还需要OpenCV库
作者:
バ幸福De右岸
时间:
2017-10-28 16:15
zty19911020 发表于 2017-10-28 11:53
你学Python?这个还需要OpenCV库
我没有接触过这个,看到这个代码才过来问一下如何使用
欢迎光临 迅维网 (https://www.chinafix.com/)
Powered by Discuz! X3.4