julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

read pixel color value camera V2

Mon May 08, 2017 9:38 am

Hello,

I'm looking for API in python to read the color value of a pixel (x,y).
thanks to your help.

julien

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: read pixel color value camera V2

Mon May 08, 2017 10:35 am

Its the official Pi Camera you are taling about ?

http://picamera.readthedocs.io/en/relea ... pirgbarray

julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

Re: read pixel color value camera V2

Mon May 08, 2017 12:09 pm

Hello,

How can I read pixel value at (x,y) with a black and white camera v2? not a rgb camera!
thanks to your help.

Julien

julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

Re: read pixel color value camera V2

Mon May 08, 2017 12:20 pm

I see
15.1. PiArrayOutput
class picamera.array.PiArrayOutput(camera, size=None)[source]
Base class for capture arrays.

This class extends io.BytesIO with a numpy array which is intended to be filled when flush() is called (i.e. at the end of capture).

array
After flush() is called, this attribute contains the frame’s data as a multi-dimensional numpy array. This is typically organized with the dimensions (rows, columns, plane). Hence, an RGB image with dimensions x and y would produce an array with shape (y, x, 3).

But how can I use it using array to read the value of my black and white pixel at (x,y) position in the image?
do you have a example in python to read pixel value at x,y?
thanks to your help.

Julien

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: read pixel color value camera V2

Mon May 08, 2017 12:22 pm

julien.launay wrote:How can I read pixel value at (x,y) with a black and white camera v2? not a rgb camera!
There is no black & white camera module.
And the NoIr camera is a normal colour cam with the IR filter removed

julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

Re: read pixel color value camera V2

Mon May 08, 2017 12:31 pm

I am looking for a API to use my black and white camera V2

I only found the API in color RGB
with PiCamera() as camera:
camera.resolution = (64, 64)
with PiRGBArray

thanks

Julien

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: read pixel color value camera V2

Mon May 08, 2017 12:34 pm

julien.launay wrote:I am looking for a API to use my black and white camera V2
See my reply above: a V2 (or any version) RPF black and white camera board does not exist...

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: read pixel color value camera V2

Mon May 08, 2017 12:37 pm

http://picamera.readthedocs.io/en/relea ... piyuvarray
The Y in YUV means Luminanse value.

julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

Re: read pixel color value camera V2

Mon May 08, 2017 1:08 pm

Hello,

I found.
with PiCamera() as camera:
camera.resolution = (64, 64)
with PiRGBArray(camera, size=(8, 8)) as stream:
camera.capture(stream, format='rgb', resize=(8, 8))
image = stream.array

juste use array and read pixel in the list, and it's working fine... ;)

julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

Re: read pixel color value camera V2

Mon May 08, 2017 3:16 pm

Hello,

All is working well.
But when I want to capture 640x480 it takes 20s! why is it so long?
is there a way to go faster?
thanks

Julien

julien.launay
Posts: 51
Joined: Wed Mar 30, 2016 5:22 am

Re: read pixel color value camera V2

Mon May 08, 2017 3:20 pm

Hello,

It's not the capture who takes time, but setting pixels on a canvas with tkinter! I use canvas.create_rectangle(). because I don't know how to set on pixel!

julien

Return to “Python”