二值化,边缘检测后,线段无法检测?
-
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)
-
终端里有检测出的线段啊。