Haar Training detectMultiScale does not work very well when size vary

asked 2016-10-07 13:00:11 -0600

Neldar gravatar image

Hello,

I created my CascadeClassifier in order to find in some images if a parking sign is present. Sadly, it does not work very well. When I analyse the image from my webcam, taking a picture of a parking sign I printed and vary the distance between the image and my webcam, it only work when I am at a quite precise distance. The cascade identifier does not work when the image appear too big or too small.

I played with the scaleFactor but it didn't helped. Could you help me find a way to identify if a parking sign is in the picture, whatever the size of it in the picture?

edit retag flag offensive close merge delete

Comments

What method are you using to detect the parking sign? How have you trained the cascade? How many negative or positives ?

Some code would be helpful.

atv gravatar imageatv ( 2016-10-08 03:40:15 -0600 )edit

The code I'm using to test my classifier is the following: import numpy as np import cv2

parking_cascade = cv2.CascadeClassifier('cascadeP2.xml')
cap = cv2.VideoCapture(0)

while 1:
    ret, img = cap.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    # image, reject levels level weights.
    parkinges = parking_cascade.detectMultiScale(gray, 5, 50)

    for (x,y,w,h) in parkinges:
        cv2.rectangle(img,(x,y),(x+w,y+h),(255,255,0),2)
    cv2.imshow('img',img)
    k = cv2.waitKey(30) & 0xff
    if k == 27:
        break

cap.release()
cv2.destroyAllWindows()

I trained my classifier withe 1950 negative, positives images and 30 steps for the haartraining.

Neldar gravatar imageNeldar ( 2016-10-08 09:30:58 -0600 )edit