logo

二值化,边缘检测后,线段无法检测?

2020-07-13 16:03
R
fip3
edcecaa9-ba3e-457f-9cec-54f0fe0b7b44.jpg
enable_lens_corr = False

import sensor, image, time

sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.VGA)   # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
clock = time.clock()                # Create a clock object to track the FPS.
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking



while(True):
    clock.tick()                    # Update the FPS clock.
    img = sensor.snapshot()         # Take a picture and return the image.
    img = img.binary([(255, 50)])




    img.find_edges(image.EDGE_SIMPLE,threshold =(255, 255))


    if enable_lens_corr: img.lens_corr(1.8) 
    for l in img.find_line_segments(merge_distance = 0, max_theta_diff = 5):
        img.draw_line(l.line(),color = (255,0,0))
        print(l)
2020-07-14 13:40
I
网红小智智 星瞳科技
0da24aa0-9cb5-4e8f-beba-cddb754f4bc7.jpg

终端里有检测出的线段啊。