[Python] Fullbody Detection Using OpenCV Haar Cascades

Discussão em 'Python' iniciado por Stack, Fevereiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    I want to detect the full body of human within image using OpenCV fullbody Haar Cascades. Here's my code:

    import numpy as np
    import cv2
    from matplotlib import pyplot as plt

    bodydetection = cv2.CascadeClassifier('cascades/haarcascade_fullbody.xml')
    img = cv2.imread('gambar/fullbody2.jpg')
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    body = bodydetection.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in body:
    cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)

    cv2.imshow('img',img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


    Here's the result:

    [​IMG]

    As you can see, my code didn't detect the full body of human in the image.

    By the way I'm newbie in OpenCv and this is my first question in here, so just correct me if I'm doing something wrong and I hope someone can help me to correct my code.

    Sorry for bad English ;).

    Continue reading...

Compartilhe esta Página