[英]Cannot Video Capture With opencv on macOS
在 python 上,當我嘗試使用 open cv2 進行視頻捕獲時,我得到:
2021-11-18 11:07:36.572 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
2021-11-18 11:07:36.572 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
2021-11-18 11:07:36.572 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
2021-11-18 11:07:36.572 Python[5863:20765] =>> Checked Property: [cfac] 1667653987
2021-11-18 11:07:36.621 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
2021-11-18 11:07:36.622 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
2021-11-18 11:07:36.722 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
2021-11-18 11:07:36.722 Python[5863:20765] =>> Checked Property: [cfen] 1667655022
我也是這個 windows 開口:
這是我的代碼:
import cv2
trained_face_data = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
webcam = cv2.VideoCapture(0)
ret, frame = webcam.read()
grayscaled_img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('image face detector', grayscaled_img)
cv2.waitKey(1)
解決只需將參數cv2.VideoCapture(0)
更改為cv2.VideoCapture(2)
希望對其他 Mac 用戶有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.