I'm currently working on face detection using OpenCV. I finished training by using my positive and negative images with a cascade trainer GUI. However when I run my code to test for face detection, only the first image works(only when .detectMultiScale is set to gray,1.01,7) and it doesn't work on the other images.
import cv2
import numpy as np
face_cascade = cv2.CascadeClassifier('classifier/cascade.xml')
img = cv2.imread('p/pic2.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray,1.01,7)
for (x,y,w,h) in faces:
img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
All of my positive images are in gray scale and their size is (600,600). My negative image sizes are bigger but not in gray scale. There are 80 positive images and 160 negative. I'm sure if this is what's effecting the results.
My suggestion is following this tutorial by following the documentation. I used this tutorial and trained many objects before so it is good to follow