Windows OpenMV -> AttributeError...

Hi,

I work under win32XP, OPENMV1.3 and firmeware 2.0

I can not use the function:
Image.rgb_Lab (r, g, b) ine window tells me:
“AttributeError: ‘image’ object has no attibute ‘rgb_lab’”
This function is indicated in: image -machine vision
https://openmv.io/docs/library/omv.image.html#image.lab_to_rgb

Thank you for telling me an example that uses this function in the following way:

I want to monitor the colors of a pixel (pix (50,80):

TblRGB = (255,247.26)
TblLab = (0,0,0)
I = 50
J = 80

--------------------

Sensor.reset ()
Sensor.set_pixformat (sensor.RGB565)
Sensor.set_framesize (sensor.QVGA)

--------------------

Img = sensor.snapshot ()
TblRGB = img.get_pixel (i, j)
Img.rgb_to_lab ((tblRGB)).
Tab = img.get_pixel (i, j)
TblLab = img.rgb_to_lab ((tblRGB))

--------------------------------------

Print (str (tblLab))


thank you

Sorry a copy paste too fast, my code is:

I want to monitor the colors of a pixel (pix (50,80):

tblRGB = (255,247.26)
tblLab = (0,0,0)
i = 50
j = 80

--------------------

Sensor.reset ()
Sensor.set_pixformat (sensor.RGB565)
Sensor.set_framesize (sensor.QVGA)

--------------------

Img = sensor.snapshot ()
tblRGB = img.get_pixel (i, j)
tblLab = img.rgb_to_lab (tblRGB)

--------------------------------------

Print (str (tblLab ))


thank you

Hi, you have to call the rgb_to_lab on the image module.

So:

import image

image.rgb_to_lab()

https://openmv.io/docs/library/omv.image.html#image.rgb_to_lab

Um, I recommend that you use the get statistics function for this kind of thing:

https://openmv.io/docs/library/omv.image.html#image.image.statistics

e.g.

img.statistics(roi=(i,j,1,1)) # (x_pos, y_pos, width, height)

It gives you the color information for an area of color. Sorry for the output being a little difficult to index into. We’ll bind names to all the index in future firmware versions.

Thanks, but my first ligne is :

import sensor, image, time,pyb,os,math
from pyb import Pin

I wanted to simplify and I forget to mention the imports. The problem does not come from that.

By cons, I have noted the function img.statistics () and I will try to work with it.

thanks

re-Hi,

With your answer, I finally understood my mistake.
The function: image.rgb_to_lab (r, g, b) is independent.

When working on a picture called img, the image.rgb_to_lab () function does not change its name.

Img = sensor.snapshot ()

Here is a complete example of how

Import sensor, image

Sensor.reset ()
Sensor.set_pixformat (sensor.RGB565)
Sensor.set_framesize (sensor.QVGA)
Sensor.skip_frames (20)

TblRGB = (11,12,13)
TblLAB = (21,22,23)

I = 50
J = 80

While (True):

Img = sensor.snapshot ()

TblRGB = img.get_pixel (i, j)
TblLAB = image.rgb_to_lab (tblRGB)

Print ( “RGB” + str (j) + “” + (str (tblRGB)))
Print ( “LAB” + str (j) + “” + (str (tblLAB)))

Thank you for your help and soon