logo

为什么颜色识别对应的那三个数值红色最大为100,而且绿色和蓝色的那个值变化很小呢,是我的这个机械坏了?还是什么原因呢??

2021-10-11 21:57
K
ovly

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)

7eb4f487-0bdb-4e47-9031-0a64b3c8328a.png
e981910a-4392-43f2-ae63-22f6fbbca37e.png
2021-10-12 18:15
I
网红小智智 星瞳科技

LAB不是红绿蓝。你在IDE的直方图里,选择LAB显示,就知道了。

https://baike.baidu.com/item/Lab%E9%A2%9C%E8%89%B2%E6%A8%A1%E5%9E%8B/3944053

2021-10-12 21:35
K
ovly

@kidswong999

那么请问一下,最下面的print函数那里不是帮那个RGB值打印出来吗?那么它怎么变成LAB了呢,或者我怎么帮这个lab的值通过什么函数把它转换成rgb呢?

2021-10-14 19:39
I
网红小智智 星瞳科技

@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

2021-10-14 20:03
K
ovly

@kidswong999

好嘞已经可以啦,麻烦您了