k230 运行颜色识别例程,图像含有拖影

Viewed 65

重现步骤

  1. 用 k230 运行颜色识别的例程 find_blobs.py
  2. 靠近绿色的物体
  3. 绿色物体轮廓出现拖影

期待结果和实际结果

图像应该是干净的,不含拖影。另外,运行人脸识别不含拖影

软硬件版本信息

CanMV-K230-V1.1
固件为CanMV-K230_micropython_v0.7_sdk_v1.6_nncase_v2.8.3.img.gz
657d3bf8011903762c95f53ef04c90a.jpg

错误日志

补充材料

image.png
运行的代码(例程find_blobs.py):

# Find Blobs Example
#
# This example shows off how to find blobs in the image.
import time, os, gc, sys

from media.sensor import *
from media.display import *
from media.media import *

DETECT_WIDTH = ALIGN_UP(320, 16)
DETECT_HEIGHT = 240

sensor = None

def camera_init():
    global sensor

    # construct a Sensor object with default configure
    sensor = Sensor(width=DETECT_WIDTH,height=DETECT_HEIGHT)
    # sensor reset
    sensor.reset()
    # set hmirror
    # sensor.set_hmirror(False)
    # sensor vflip
    # sensor.set_vflip(False)

    # set chn0 output size
    sensor.set_framesize(width=DETECT_WIDTH,height=DETECT_HEIGHT)
    # set chn0 output format
    sensor.set_pixformat(Sensor.RGB565)
    # use IDE as display output
    Display.init(Display.VIRT, width= DETECT_WIDTH, height = DETECT_HEIGHT,fps=100,to_ide = True)
    # init media manager
    MediaManager.init()
    # sensor start run
    sensor.run()

def camera_deinit():
    global sensor
    # sensor stop run
    sensor.stop()
    # deinit display
    Display.deinit()
    # sleep
    os.exitpoint(os.EXITPOINT_ENABLE_SLEEP)
    time.sleep_ms(100)
    # release media buffer
    MediaManager.deinit()

def capture_picture():

    fps = time.clock()
    while True:
        fps.tick()
        try:
            os.exitpoint()
            global sensor
            img = sensor.snapshot()

            # select color
            thresholds = [[0, 80, 40, 80, 10, 80]]      # red
            # thresholds = [[0, 80, -120, -10, 0, 30]]    # green
            # thresholds = [[0, 80, 30, 100, -120, -60]]  # blue
            # find all blobs,and draw rectangles
            blobs=img.find_blobs(thresholds ,pixels_threshold= 500)
            for blob in blobs:
                img.draw_rectangle(blob[0], blob[1], blob[2], blob[3], color = (255, 255, 0))

            # draw result to screen
            Display.show_image(img)
            img = None

            gc.collect()
            print(fps.fps())
        except KeyboardInterrupt as e:
            print("user stop: ", e)
            break
        except BaseException as e:
            print(f"Exception {e}")
            break

def main():
    os.exitpoint(os.EXITPOINT_ENABLE)
    camera_is_init = False
    try:
        print("camera init")
        camera_init()
        camera_is_init = True
        print("camera capture")
        capture_picture()
    except Exception as e:
        print(f"Exception {e}")
    finally:
        if camera_is_init:
            print("camera deinit")
            camera_deinit()

if __name__ == "__main__":
    main()
2 Answers

实测发现提高分辨率可以解决,但是提高分辨率摄像头的延迟会变高:
c48534e8618e419b8ca34f701a8ba4f.png
修改的代码(第10行):

DETECT_WIDTH = 800
DETECT_HEIGHT = 480

我的应用场景不允许有这么高的延迟,请问有没有别的解决拖影的方法?

这个需要你做系统的测量,查找在提升分辨率后,具体哪个模块耗时变大。是分析 还是图像传输。
另外,你最好是使用LCD屏或者HDMI来做显示,因为传输高清图片到IDE上显示,也要消耗额外时间