K230 yolo 识别例程中,怎么修改摄像头参数以及AI推理输入图片参数,使其采集二值化的图像,并将二值化图像推给AI进行推理呢

Viewed 121

0231f121cf751a0945c2110f4c278c24.png7c16020d950f5760af8dd3d45d9b5fa2.png 我尝试修改pipeline中的初始化函数和getframe函数均没有办法在ide上显示二值化的图像,有没有办法修改呢?

3 Answers

image.png
设置为Sensor.GRAYSCALE

我测试了不行,具体请看下面,请问还有别的方法吗

# PipeLine初始化函数
def create(self,sensor=None,hmirror=None,vflip=None,fps=30):
    with ScopedTiming("init PipeLine",self.debug_mode > 0):
        os.exitpoint(os.EXITPOINT_ENABLE)
        nn.shrink_memory_pool()
        # 初始化并配置sensor
        brd=os.uname()[-1]
        if brd=="k230d_canmv_bpi_zero":
            self.sensor = Sensor(fps=fps) if sensor is None else sensor
        elif brd=="k230_canmv_lckfb":
            self.sensor = Sensor(fps=fps) if sensor is None else sensor
        else:
            self.sensor = Sensor() if sensor is None else sensor
        self.sensor.reset()
        if hmirror is not None and (hmirror==True or hmirror==False):
            self.sensor.set_hmirror(hmirror)
        if vflip is not None and (vflip==True or vflip==False):
            self.sensor.set_vflip(vflip)
        # 通道0直接给到显示VO,格式为YUV420
        self.sensor.set_framesize(w = self.display_size[0], h = self.display_size[1])
        **self.sensor.set_pixformat(Sensor.GRAYSCALE)**
        # 通道2给到AI做算法处理,格式为RGB888
        self.sensor.set_framesize(w = self.rgb888p_size[0], h = self.rgb888p_size[1], chn=CAM_CHN_ID_2)
        # set chn2 output format
        **self.sensor.set_pixformat(Sensor.GRAYSCALE, chn=CAM_CHN_ID_2)**

        # OSD图像初始化
        **self.osd_img = image.Image(self.display_size[0], self.display_size[1], image.GRAYSCALE)**

        sensor_bind_info = self.sensor.bind_info(x = 0, y = 0, chn = CAM_CHN_ID_0)
        Display.bind_layer(**sensor_bind_info, layer = Display.LAYER_VIDEO1)

我修改了加粗的几处,并不能实现黑白采图的效果,IDE上不显示摄像头画面的同时,停止程序运行还会卡住image.png

image.png
你试试这个例子呢,我01板子运行这个没问题

这个是可以用的,没问题,我用的是东山Π的板子