logo

在图像子窗口中,用边缘检测报错

2019-05-10 19:45
R
_1m6e

想在物体附近进行边缘检测,所以先剪切了图像,可是出现了报错

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
threshold = [150, 250] # Middle L, A, B values.
while(True):
    clock.tick()
    img = sensor.snapshot()
    for blob in img.find_blobs([threshold], pixels_threshold=100, area_threshold=100, merge=True, margin=10):
            #img.draw_rectangle(blob.rect())
            img = sensor.set_windowing([blob.cx(),blob.cy(),blob.w(),blob.h()])
            img.find_edges(image.EDGE_SIMPLE , threshold=(50, 80))
            print(blob.x(),blob.y())
be74e2f7-4bfd-4820-bfd8-48f124035a98.png
2019-05-11 00:23
I
网红小智智 星瞳科技

sensor.set_windowing不会返回图像

I
网红小智智 星瞳科技

sensor.set_windowing([blob.cx(),blob.cy(),blob.w(),blob.h()])

img = sensor.snapshot()