Noob question about ofPixels

I’m trying to get the color from an ofPixels object

ofPixels camPixels = cam.getPixels(); ofColor col = camPixels.getColor(x,y);

It works but I get this error in the log?

[warning] returning color not supported yet for UNKOWN format
[ error ] ofPixels: format doesn’t support channels

Hi, it seems that you are getting an unknown pixel type from your camera. Which camera are you using? are you using with it an addon? the pixel type of the ofPixels object that the cam object returns has an unknown pixel type which finally leads to the crash.
you could also access the raw pixel data and extract color info from there.

camPixels.getData()

Hi, I’m using the cam from my MacBook

No addons.

Did you try the included examples?
OFFolder/examples/video/videoGrabberExample
OFFolder/examples/video/asciiVideoExample

if these work then you have a problem in your code.

Best

Ok, it seems like it was due to the allocation … I used OF_IMAGE_COLOR and apparently it has to be OF_PIXELS_RGB?

I’m a bit confused by all the different modes possible there …

Why were you allocating the ofPixels object? that is done internally by the camera grabber.
Are you doing anything else with the ofPixels object anywhere else?

As of the confusion that you have, OF_IMAGE_COLOR is for ofImage objects and OF_PIXELS_RGB and is for ofPixels objects. It’s quite straight forwards. Although, the ofImage class contains an ofPixels instance, which might be what generates the confusion.
best

OK, that makes sense, the IMAGE and the PIXELS … maybe COLOR and RGB confused me … anyway, oF is definitely much more complex and complicated than Processing! :stuck_out_tongue_winking_eye: But yes, it’s also much more powerful.

Ah, ok, so I don’t need to allocate ofPixels in setup? Unlike ofTexture?

Usually I’m only loading ofPixels into a texture to draw it. But sometimes I need to get the pixels from it somewhere else in the code. But I’m still trying to figure out all the differences between ofPixels, ofTextures and ofImage …

Yes it is way much more powerful than processing.

If you are getting the ofPixels from somewhere else (like cam.getPixels()) theres no need to allocate them as you will get a copy of the pixels inside the cam object. Kind of the same goes for ofTextures.

take a look at this. It might be useful.

BTW, read it in github so it gets rendered correctly.

best