I’m struggling and could use some help. I’m sure its probably simple…
Objective: detect Yellow lines.
Code: Use LAB thresholds to detect yellow and transform image into binary. This works rather well (outside light influence outcome). Pic 1.
Then I wan to use linear regression to find the line that matches best. This part goes wrong.
Even when I REVERT the image, results stay the same…
Code never finds a LINE. N/A
I prefer not to use gray scale as the color contrast is not helping to detect my yellow lines.
What is wrong in my code setup. Is it because I do not use area and pixel thresholds.
I also included pictures of what happens.
Pic 1: result without linear regression. Only binary threshold. => Clear lines
Pic 2: with regression. (used (1,1) as its binary image, so only use the “black” pixels. Or does this not work?)
Seems bottom of the frame is all messed up.
sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking clock = time.clock() while(True): clock.tick() img = sensor.snapshot() img.binary([(0, 100, -43, 16, -36, 11)], zero = False, to_bitmap=True) #Yellow and Green #img=img.invert() line = img.get_regression([(1,1)], robust = True) if (line): img.draw_line(line.line(), color = 127) print("FPS %f, mag = %s" % (clock.fps(), str(line.magnitude()) if (line) else "N/A"))