Hog+SVM行人检测

作者: 陨星落云 | 来源:发表于2020-03-22 19:14 被阅读0次
    # -*- coding: utf-8 -*-
    """
    Created on Sun Mar 22 16:17:14 2020
    
    @author: 陨星落云
    """
    
    import cv2
    
    img = cv2.imread("people-brasil-guys-avpaulista-109919.jpg")
    cv2.namedWindow('input',cv2.WINDOW_NORMAL)
    cv2.imshow("input", img)
    hog = cv2.HOGDescriptor()
    hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
    
    # 行人检测
    (rects, weights) = hog.detectMultiScale(img,
                                            winStride=(4, 4),
                                            padding=(8, 8),
                                            scale=1.25,
                                            useMeanshiftGrouping=False)
    for (x, y, w, h) in rects:
        cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
    cv2.namedWindow('hog-detector',cv2.WINDOW_NORMAL)
    cv2.imshow("hog-detector", img)
    cv2.imwrite('hog-detector_result.jpg', img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    
    

    结果:


    hog-detector_result.jpg

    相关文章

      网友评论

        本文标题:Hog+SVM行人检测

        本文链接:https://www.haomeiwen.com/subject/qlgvyhtx.html