test own Haar-Cascade

Hi,

currently I am trying to creat a trafficsign-recognition haarcascade to my MV-cam. I used data from GTSRB(German Traffic Sign Benchmarks) and after using openCV and (https://github.com/openmv/openmv/blob/m … cascade.py) script I have get the trafficsign-recognition.cascade. but Then I import in MV-cam

the cascade script is on the internal flash drive

trafficsign_cascade = image.HaarCascade(“/trafficsign.cascade”, stages=15)

while (True):
clock.tick()

Capture snapshot

img = sensor.snapshot()

Find objects.

Note: Lower scale factor scales-down the image more and detects smaller objects.

Higher threshold results in a higher detection rate, with more false positives.

objects = img.find_features(trafficsign_cascade, threshold=1, scale_factor=1.35)

Draw objects

for r in objects:
img.draw_rectangle(r)


But my script just does nothing. It gets the snapshots, but recognized nothing. Does anyone have any experience in making MV-cam own haar-cascades?
What’s more ,I use the opencv own data(for example: haarcascade_eye.xml) transform to haarcascade_eye.cascade and also test again,but just like the above that recognized nothing. So,I might be something wrong but I don’t realize.
Should I used the data that snapshots from MV-cam to train xml again? Or just because the parameter I choose to use opencv train is inapposite.(the image size,-nstages .etc )

best regards
cascade_made.zip (3.48 MB)

Hi, your cascade has only 2 stages I expected much more, which makes think it probably won’t work so I tested it with OpenCV on a pos image and it doesn’t detect it:

import numpy as np
import cv2 as cv

cascade = cv.CascadeClassifier('trafficsign/trafficsign.xml')
img = cv.imread('trafficsign/pos/00000_00000.jpg')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
objs = cascade.detectMultiScale(gray, 1.05, 1)

for (x,y,w,h) in objs:
    cv.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
    roi_gray = gray[y:y+h, x:x+w]
    roi_color = img[y:y+h, x:x+w]

cv.imshow('img',img)
cv.waitKey(0)
cv.destroyAllWindows()

Also it’s probably best to use a window where w == h (ex. 30x30).

Really thanks a lot,I will try again