帧间差分法实现运动物体检测,在彩色图转换灰度图出现错误
-
# Untitled - By: Administrator - 周四 5月 11 2023 import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() lastfram=None while(True): clock.tick() img = sensor.snapshot() img = image.rgb_to_grayscale(img) img=img.binary(50) if lastfram is None: lastfram = img.copy() continue diff=image.difference(lastfram,img) blobs=diff.find_blobs() count=len(blobs) lastfram=img.copy() print(clock.fps())
求问整个程序有什么错误
-
img = image.rgb_to_grayscale(img)
改为
img.to_grayscale()