为什么OpenCV-Python在视频仪(0)中需要4到5秒才能打开相机和查看屏幕
我有一个相当简单的代码,该代码检测到Cascadeclalsifier的面孔
import cv2
photo_face = cv2.VideoCapture(0)
cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
while True:
_, frame = photo_face.read()
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = cascade.detectMultiScale(gray_frame)
for x, y, w, h in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (255, 0, 0), 2)
cv2.imshow('recognize_face', frame)
if cv2.waitKey(10) == ord('q'):
break
,但视频拍摄量大约需要4到5秒钟才能打开相机。我知道其他任何代码都不花时间,因为我尝试将其删除。我尝试在循环和级联打开时删除整个整个
I have a fairly simple code which detects faces by CascadeClassifier
import cv2
photo_face = cv2.VideoCapture(0)
cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
while True:
_, frame = photo_face.read()
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = cascade.detectMultiScale(gray_frame)
for x, y, w, h in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (255, 0, 0), 2)
cv2.imshow('recognize_face', frame)
if cv2.waitKey(10) == ord('q'):
break
But the videocamera takes around 4 to 5 seconds to open the camera. I know that any other code is not taking time as I have tried removing it. I tried removing the whole while loop and cascade opening and just did a print statement after photo_face = cv2.VideoCapture(0)
but even then it takes 4 to 5 seconds to print yes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论