Below is the simplified code, where you can define the number of line and column which define the number of areas where the lbp is defined and checked.
I tested the M7 and H7 camera, and both get problem if i increase the number of line and column.
With openmv 2.2.0 :
For M7 (rev 3.4.1), in VGA :
- 1 line and 1 column works
- 1 line and 2 column works
- 2 line and 1 column does not work
- 2 line and 2 column does not work
It stops at the lbp save step.
For H7 (rev 3.4.1), in VGA :
- 3 lines and 3 columns works but disconnect
import sensor, image
# Reset sensor
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=1000)
# Variable to define
nline = 4
ncolumn = 4
thres = 15000
stext = 2
# Size definition
zoneW = sensor.width()
zoneH = sensor.height()
wcolumn = int(zoneW / ncolumn)
hline = int(zoneH / nline)
# Save lbp features
mode = "save" #0
if mode == "save" :
print("save -------------")
img = sensor.snapshot()
for i in range(0,nline) :
for j in range(0,ncolumn) :
dn = img.find_lbp( (int(j*wcolumn), int(i*hline), int(wcolumn), int(hline)) )
n = i*ncolumn+j
filename = "lbp" + str(n) + ".lbp"
if image.save_descriptor(dn, "%s" % filename) == False :
print("Error : ", filename)
print("check -------------")
while (True):
img = sensor.snapshot()
OK = 0
for i in range(0, nline) :
for j in range(0, ncolumn) :
d1 = img.find_lbp( ( int(j*wcolumn), int(i*hline), int(wcolumn), int(hline) ) )
filename = "lbp%d.lbp" % int(i*ncolumn+j)
dn = image.load_descriptor("%s" % filename)
dist = image.match_descriptor(dn, d1)
img.draw_string(int(j*wcolumn), int(i*hline) + 10, "%d" % dist, color=(0,0,0), scale=stext)
if dist < thres :
OK += 1
if OK > 0 :
print( "O_Ok : %d" % OK)
else :
print("Nok")
It seems to be a memory problem, but i dont know how free memory.
Thanks for help,