gpt4 book ai didi

python - 在opencv-python中更改视频源时图像检测不佳

转载 作者:行者123 更新时间:2023-12-02 17:22:34 24 4
gpt4 key购买 nike

我制作了一个Opencv应用程序,以手机摄像头作为视频源来检测人脸,该功能可以完美地用于接收数据和显示视频,但是问题在于图像sample detected image的检测

我确实使用了脸部级联,但效果仍然很差
这是我的代码

import cv2
import numpy

url = 'http://192.168.xxx.xx:8080/video'
cap = cv2.VideoCapture(url)
face = cv2.CascadeClassifier('cascade.xml')
while(True):
ret, frame = cap.read()
if frame is not None:
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face.detectMultiScale(gray, 1.1, 4)
for (x, y, w, h) in faces :
cv2.rectangle(frame,(x,y),(x+w, x+h),(255,0,0),2)
cv2.imshow('frame',frame)
q = cv2.waitKey(1)
if q == ord("q"):
break
cv2.destroyAllWindows()

我的问题是..

有什么方法可以使检测更加准确?

提前致谢

最佳答案

objects =   cv.CascadeClassifier.detectMultiScale(  image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]
Parameters
image Matrix of the type CV_8U containing an image where objects are detected.
objects Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
scaleFactor Parameter specifying how much the image size is reduced at each image scale.
minNeighbors Parameter specifying how many neighbors each candidate rectangle should have to retain it.
flags Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSize Minimum possible object size. Objects smaller than that are ignored.
maxSize Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.

您可以使用scaleFactor和minNeighbors。

关于python - 在opencv-python中更改视频源时图像检测不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61459720/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com