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

我制作了一个 Opencv 应用程序,用我的手机摄像头作为视频源来检测人脸,这在接收数据和显示视频方面非常有效,但问题在于图像检测,检测到的图像样本


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


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()

我的问题是..


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


提前致谢


慕尼黑的夜晚无繁华
浏览 126回答 1
1回答

SMILET

objects =   cv.CascadeClassifier.detectMultiScale(  image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]Parametersimage   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。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python