arunponnusamy / cvlib

A simple, high level, easy to use, open source Computer Vision library for Python.

Home Page:http://arunponnusamy.com/cvlib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No face detected in image

cronero95 opened this issue · comments

Hello, I am doing a simple test; I take a picture with 5 faces, each in a different position, then try to detect the faces, but the "faces" list is empty.

Here is the image I used: https://drive.google.com/open?id=1v8C-SP0nsZ4aLuyLu8f3tjA7uI6JaQ2R

This is the code:

import cvlib as cv
import cv2

imgColor = cv2.imread('D:/images/rostro_poses.jpg', -1)

faces, confidences = cv.detect_face(imgColor)

for face,conf in zip(faces,confidences):

    (startX,startY) = face[0],face[1]
    (endX,endY) = face[2],face[3]

    cv2.rectangle(imgColor, (startX,startY), (endX,endY), (255,0,0), 2)
    
cv2.imshow('something', imgColor)

Thanks for the help.

**using this code

import cv2

Load Trained cascade classifier

face_cascade = cv2.CascadeClassifier('C:/Users/Atin/Desktop/haarcascade_frontalface_default.xml')

#Read the given image

img = cv2.imread('C:/Users/Atin/Downloads/group.jpg')

Convert color image into grayscale

gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Dectect face ROI

#syntax: classifer.detectMultiScale(input image,scale factor,mini navores)

facce = face_cascade.detectMultiScale(img,5.5,4)
print(facce)

#draw Rectangle around the face

for (x,y,w,h) in facce:
cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),4)

#show image

cv2.imshow('output img',img)

#wait for close window

cv2.waitKey()

#close all windows

cv2.destroyAllWindows()