logo

请问在灰度图中如何调用histogram.get_threhsold函数?

2020-07-08 14:09
C
cif1

请问在灰度图中如何调用histogram.get_threhsold函数?

2020-07-08 16:17
I
网红小智智 星瞳科技

发现了一个拼写错误,get_threhsold改为get_threshold。会更改文档。

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) # or RGB565.
sensor.set_framesize(sensor.QVGA)
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()
    # Gets the grayscale histogram for the image into 8 bins.
    # Bins defaults to 256 and may be between 2 and 256.
    
    histogram = img.get_histogram(bins=8)
    print(histogram.get_threshold())
    print(clock.fps())