openMV find_line_segments

m1 ai dock works for a few seconds but then freezes and not shows any error on IDE. My code:

import sensor, image, lcd

lcd.init(freq=15000000)

sensor.reset()

sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)

while(True):

img = sensor.snapshot()

for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 5):
    img.draw_line(l.line(), color = (255, 0, 0))

lcd.display(img)