![](/img/trans.png)
[英]Python Opencv2 + webcam facial dection, no face being detected no error
[英]OpenCV2 Write to webcam python
我可以做這樣的事情嗎?
import cv2
cap = cv2.VideoCapture(0)
wri = cv2.device(0)
while 1:
ret, val = cv2.cvtColor(cap.read(), cv2.RGB2GRAY)
if ret:
wri.setCurrentFrame(val)
if cv2.WaitKey(0) == 27:
break
cap.release()
wri.release()
cv2.destroyAllWindows()
我想做像ManyCam這樣的東西。
我已經研究過,但找不到類似的東西。
試試這種方式
import cv2
capture = cv2.VideoCapture(0)
while(True):
ret, frame = capture.read()
grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('video gray', grayFrame)
cv2.imshow('video original', frame)
if cv2.waitKey(1) == 27:
break
capture.release()
cv2.destroyAllWindows()
而已
請注意,VideoCapture object 嚴格負責從流(網絡攝像頭、視頻文件、RTSP、etc.)中捕獲(讀取)圖像。 然后您可以使用任何 opencv 函數進行任何進一步處理
現在,網絡攝像頭硬件是您讀取而不是寫入的設備。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.