License Plate detection Haar cascade

I’m trying to use the OpenMV (& micropython) on the Arduino Portenta H7 + vision shield board. I managed to convert and install the russian plate haar cascade

 #Load Haar Cascade
carplate_cascade = image.HaarCascade('/haarcascade_russian_plate_number.cascade', stages=25)
clock = time.clock()             

 img = sensor.snapshot()         # Take a picture and return the image.

#Find objects.
detects = img.find_features(carplate_cascade, threshold=1,scale_factor=0.75)

#Draw objects
for x,y,w,h in detects:
    #draw image on top of it


The code seems to run and when I move it around & i have adjusted the different threshold values. I think it detects it because when i picture it over the license plate, the script stops and i get this in the output of the serial terminal

>>> {"width":60, "height":20, "n_stages":20, "n_features":212, "n_rectangles":433}

How would i draw the rectangle around the detected area? i figured img.draw_rectangle would work but it doesn’t seem to show any rectangles. The aim is to next extract out this detected portion before passing it through another model for segmentation (there’s an OpenCV find_contours method just that I have to see if it works in OpenMV) and finally digit recognition.

Can you print what x,y,w,h are in the loop?

sorry for the late reply! It seems like it’s just crashing on this line

 carplate_cascade=image.HaarCascade('/haarcascade_russian_plate_number.cascade', stages=25)


I replaced the print statement with ‘test’ and it outputs that so it seems like it’s crashing on that print? is there a possible reason for it?

I found an older thread (implement own Haar-Cascade - #8 by fabianhummel) and it’s similar problem as fabianhummel had, printing out the same output. The conversion script ran fine without issues (i tried it on another cascade that had 16 stages and it produced the following error):

UPDATE: for those facing similar issue, i managed to find out where the problem was - in the scaling & threshold values. Seems like a scale_factor <1.0 would cause it to crash. I’ve tried it at scale of 1.2 and detecting on a bigger sized image and it works