with get_pixel i get the same three RGB mean values ?

Discussion related to "under the hood" OpenMV topics.
User avatar
chrisPyres66
Posts: 52
Joined: Mon Jul 16, 2018 9:22 am
Location: France

with get_pixel i get the same three RGB mean values ?

Postby chrisPyres66 » Tue Oct 09, 2018 3:36 am

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.

Code: Select all

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 ?
User avatar
kwagyeman
Posts: 2462
Joined: Sun May 24, 2015 2:10 pm

Re: with get_pixel i get the same three RGB mean values ?

Postby kwagyeman » Tue Oct 09, 2018 12:19 pm

Nyamekye,
User avatar
chrisPyres66
Posts: 52
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: with get_pixel i get the same three RGB mean values ?

Postby chrisPyres66 » Wed Oct 10, 2018 2:33 am

Thanks, i do this but does that mean get_pixel is depreciated ?
User avatar
iabdalkader
Posts: 630
Joined: Sun May 24, 2015 3:53 pm

Re: with get_pixel i get the same three RGB mean values ?

Postby iabdalkader » Wed Oct 10, 2018 6:56 pm

chrisPyres66 wrote:
Wed Oct 10, 2018 2:33 am
Thanks, i do this but does that mean get_pixel is depreciated ?
get_stats will be much faster since it's implemented in C.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests