我正在尝试使用一个IP摄像头通过opencv(python)通过192.168.1.36:8080 url检测人脸。我可以完美地连接到移动摄像头(Ip摄像头),但openCV无法检测人脸。 当我使用笔记本电脑相机一切正常,但通过Ip摄像头,我无法检测到人脸。 我的密码是:
import dlib
import cv2
detector = dlib.get_frontal_face_detector()
cam = cv2.VideoCapture("http://192.168.1.40:8080")
color_green = (0,255,0)
line_width = 3
while True:
ret_val, img = cam.read()
# rgb_image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
dets = detector(img)
for det in dets:
cv2.rectangle(img,(det.left(), det.top()), (det.right(), det.bottom()), color_green, line_width)
cv2.imshow('my webcam', img)
if cv2.waitKey(1) == 27:
break # esc to quit
cv2.destroyAllWindows()
我得到这个错误:
Traceback (most recent call last): File "/home/nima-s-h/PycharmProjects/FaceRecoUsingDlib/FaceDetector.py", line 14, in cv2.imshow('frame', frame) cv2.error: OpenCV(4.1.0) /io/opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
请尝试以下地址:
而不是
^{pr2}$相关问题 更多 >
编程相关推荐