Ask Your Question

patagonia's profile - activity

2020-10-21 15:44:54 -0600 received badge  Notable Question (source)
2019-12-25 07:01:25 -0600 received badge  Popular Question (source)
2017-04-19 13:56:10 -0600 asked a question face recognition error

Hi~ I am practicing a program for face recognition, I do not know why the error occurred. Ask for help.

python-3.6.1-amd64.exe numpy-1.12.1+mkl-cp36-cp36m-win_amd64.whl opencv_python-3.2.0-cp36-cp36m-win_amd64.whl scipy-0.19.0-cp36-cp36m-win_amd64.whl

import cv2 import sys import glob

cascPath = "E:\Job\Work_TEMP\20170419_face\haarcascade_frontalface_default.xml"

Create the haar cascade

faceCascade = cv2.CascadeClassifier(cascPath)

files=glob.glob("*.jpg") for file in files: # Read the image image = cv2.imread(file)

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


# Detect faces in the image
#faces = faceCascade.detectMultiScale(gray, 1.3, 5)
faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.1,
    minNeighbors=5,
    minSize=(30, 30),
    flags = cv2.CASCADE_SCALE_IMAGE
)

print ("Found {0} faces!".format(len(faces)))

# Crop Padding
left = 10
right = 10
top = 10
bottom = 10

# Draw a rectangle around the faces
for (x, y, w, h) in faces:
    print (x, y, w, h)

    # Dubugging boxes
    # cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)


image  = image[y-top:y+h+bottom, x-left:x+w+right]

print ("cropped_{1}{0}".format(str(file),str(x)))
cv2.imwrite("cropped_{1}_{0}".format(str(file),str(x)), image)

http:// (image description)

2017-04-19 13:55:33 -0600 asked a question faceCascade.detectMultiScale error

I want to test face detection, An error occurs. Please help me

python-3.6.1-amd64.exe numpy-1.12.1+mkl-cp36-cp36m-win_amd64.whl opencv_python-3.2.0-cp36-cp36m-win_amd64.whl scipy-0.19.0-cp36-cp36m-win_amd64.whl

import cv2
import sys
import glob

cascPath = "E:\Job\Work_TEMP\20170419_face\haarcascade_frontalface_default.xml"

# Create the haar cascade
faceCascade = cv2.CascadeClassifier(cascPath)


files=glob.glob("*.jpg")
for file in files:
    # Read the image
    image = cv2.imread(file)

    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


    # Detect faces in the image
    #faces = faceCascade.detectMultiScale(gray, 1.3, 5)

    faces = faceCascade.detectMultiScale(
        gray,
        scaleFactor=1.1,
        minNeighbors=5,
        minSize=(30, 30),
        flags = cv2.CASCADE_SCALE_IMAGE
    )

    print ("Found {0} faces!".format(len(faces)))

    # Crop Padding
    left = 10
    right = 10
    top = 10
    bottom = 10

    # Draw a rectangle around the faces
    for (x, y, w, h) in faces:
        print (x, y, w, h)

        # Dubugging boxes
        # cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)


    image  = image[y-top:y+h+bottom, x-left:x+w+right]

    print ("cropped_{1}{0}".format(str(file),str(x)))
    cv2.imwrite("cropped_{1}_{0}".format(str(file),str(x)), image)

image description