logo

OSError :Image is not mutable

2021-11-07 11:14
4
hae6

回复: [求教一下OSError :Image is not mutable是什么问题](/topic/4835/求教一下image-is-not-mutable是什么问题)

sensor.set_framesize(sensor.VGA)使用QVGA不报错

import sensor, image, time, lcd
from pyb import UART
import json

green_threshold   = (22, 54, -22, 8, -38, -10)#15:03正版
#green_threshold   = (28, 56, -25, -3, -27, -3)#15:10 left盗版

sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.VGA) # 使用 QQVGA 速度快一些
sensor.skip_frames(time = 10) # 跳过2000s,使新设置生效,并自动调节白平衡
sensor.set_auto_gain(False) # 关闭自动自动增益。默认开启的,在颜色识别中,一定要关闭白平衡。
sensor.set_auto_whitebal(False)#关闭白平衡。白平衡是默认开启的,在颜色识别中,一定要关闭白平衡
lcd.init() # Initialize the lcd screen.

clock = time.clock() # 追踪帧率

uart = UART(3, 115200)

while(True):
    clock.tick() # Track elapsed milliseconds between snapshots().
    img = sensor.snapshot() # 从感光芯片获得一张图像
    blobs = img.find_blobs([green_threshold], pixels_threshold=200, area_threshold=200)
    if blobs:
        for b in blobs:
            img.draw_rectangle(b[0:4], color = (255, 0, 0))
            x = b.x()
            y = b.y()
            #print(x, y, end = ',')
            data = bytearray([x,y])
            uart.write(data)
    else:
        print(0)
    img.to_rgb565(roi=(96,40,128,160))
    lcd.display(img)
e0e2434d-773a-4f1b-b2e5-9e8c61cec97d.png
2021-11-07 12:52
I
网红小智智 星瞳科技

VGA分辨率太大了,OpenMV4放不下,是jpeg压缩格式,不能运行图像算法。