Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

faceCascade.detectMultiScale error

$
0
0
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](http://)

Viewing all articles
Browse latest Browse all 2088

Trending Articles