Read Pixel Color in Processing

I have a video stream coming into processing and I need to be able to read the colors of all the pixels in the stream. I have tried reading it as both a PImage and PGraphic, but the normal methods of loadPixels(), or even get() don’t seem to work, It only reads back 0’s. I was looking through the source and it does seem to use a Texture variable, but I still can’t manage to read the colors.

It displays fine, but I need to be able to scan/read the pixel array.

Hi @npuckett

sorry for the delay in response. I have been out of action for a week or so.

The reason for your trouble is that the Spout functions only update the texture of PImage or PGraphics. Pixel update has to be added to the library.

Until then you should be able to get the image pixels from a received PGraphics texture. I have made a possible solution for you to try here.

1 Like

This is perfect. Thanks for your help. I was writing it into a normal PGraphic instead of PGraphicOPENGL, so I couldn’t get the data out. You might consider adding this as an example for the processing library in the next release. I’m pretty familiar with processing and couldn’t get this to work and it is extremely useful.

Thanks again for taking the time.

Ok, it’s good that you have a solution.

The code additions really belong in the library but could be in an example as you say. The library is due for an update soon, so I will look into options.