with get_pixel i get the same three RGB mean values ?

Dear all,

Here is my code where i try to get the three RGB mean values of a roi.
Unfortunately, i have alway the same three RGB mean values opposite to the RGB mean values written on the RGB color space charts under the image in openmv ide.

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=2000)

StartX=0
StartY=0
LengthX=640
HeightY=480

img=sensor.snapshot()

meanR=0
meanG=0
meanB=0

for i in range(StartX,StartX+LengthX):
   for j in range(StartY,StartY+HeightY):
      rgbtup=img.get_pixel(i,j,rgbtuple=True)
      meanR=meanR+rgbtup[0]
      meanG=meanG+rgbtup[1]
      meanB=meanB+rgbtup[2]
      
meanR=meanR/(LengthX*HeightY)
meanG=meanG/(LengthX*HeightY)
meanB=meanB/(LengthX*HeightY)

I miss something i suppose…
Thanks for help,

PS: i did not success to include print instruction in code ?

Please use the get_stats() method. image — machine vision — MicroPython 1.15 documentation

Thanks, i do this but does that mean get_pixel is depreciated ?

get_stats will be much faster since it’s implemented in C.