logo

线段识别问题:在图像上画一条直线之后识别这条直线,设置阈值为什么没有作用?

2022-12-19 05:34
4
山东
4
山东
cfcc7c3c-6bd3-4b7a-b829-e2a1fabb1ab7.jpg
4
山东

请大神指教,怎样识别物体上画出的白色线段

2022-12-20 19:49
I
网红小智智 星瞳科技

可以识别:

enable_lens_corr = False # turn on for straighter lines...

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

# All lines also have `x1()`, `y1()`, `x2()`, and `y2()` methods to get their end-points
# and a `line()` method to get all the above as one 4 value tuple for `draw_line()`.

while(True):
    clock.tick()
    img = sensor.snapshot()
    if enable_lens_corr: img.lens_corr(1.8) # for 2.8mm lens...

    # `merge_distance` controls the merging of nearby lines. At 0 (the default), no
    # merging is done. At 1, any line 1 pixel away from another is merged... and so
    # on as you increase this value. You may wish to merge lines as line segment
    # detection produces a lot of line segment results.

    # `max_theta_diff` controls the maximum amount of rotation difference between
    # any two lines about to be merged. The default setting allows for 15 degrees.
    
    img.draw_line(10,10,100,100,(0,0,0))
    

    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)

    print("FPS %f" % clock.fps())

另外你识别你画的直线做什么?这是已知的啊。