import sensor, image, time, json
from pyb import UART
from pyb import DAC
sensor.reset() # 初始化摄像头
sensor.set_pixformat(sensor.RGB565) # 格式为 RGB565.
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(10) # 跳过10帧,使新设置生效
sensor.set_auto_whitebal(False) # Create a clock object to track the FPS.
sensor.set_auto_gain(False) #关闭自动增益
ROI=(100,40,160,160) #图像中框的对应x,y,长,宽,
dac = DAC("P6") # Must always be "P6".
while(True):
img = sensor.snapshot() # Take a picture and return the image.
statistics=img.get_statistics(roi=ROI)
color_l=statistics.l_mode()
color_a=statistics.a_mode()
color_b=statistics.b_mode()
print(color_l,color_a,color_b) #将ROI中的对应RGB值显示出来
img.draw_rectangle(ROI)


LAB不是红绿蓝。你在IDE的直方图里,选择LAB显示,就知道了。
https://baike.baidu.com/item/Lab%E9%A2%9C%E8%89%B2%E6%A8%A1%E5%9E%8B/3944053
@kidswong999
那么请问一下,最下面的print函数那里不是帮那个RGB值打印出来吗?那么它怎么变成LAB了呢,或者我怎么帮这个lab的值通过什么函数把它转换成rgb呢?
@ovly https://forum.singtown.com/topic/5858/lab%E8%BD%ACrgb%E5%87%BD%E6%95%B0%E6%8A%A5%E9%94%99lab_to_rgb
@kidswong999
好嘞已经可以啦,麻烦您了