简体   繁体   中英

error while using python 3.6 and opencv-python cv2

Error in using python open cv to initialize the camera in a face recognition task

import cv2
camera = cv2.VideoCapture(1)
camera.grab()
ret, frame = camera.retrieve()
cv2.namedWindow('frame')

.

OpenCV: out device of bound (0-0): 1
OpenCV: camera failed to properly initialize!

问题是我没有使用额外的网络摄像头,并且我的电脑只有一个摄像头,因此此行应为:camera = cv2.VideoCapture(0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM