ColorImage to an array of ints?

We are having difficulty trying to access the raw image data inside of a ColorImage.

Ideally, we’d like to get an array of ints such as:

int]] frame = new int[320][240];

that holds RGB values of each pixel in each element.

We know that a ColorImage has a Pointer to the image data, and that Pointers have a getInts method.

We’ve tried getInts to populate our array, but we keep getting OutOfBoundsExceptions. I have a few questions about the parameters for this method:


public void getInts(long offset,
int] ints,
int low,
int number)

Should the offset be 0? I’m assuming the image’s Pointer is pointing to the beginning of the image data.

Is the image data even stored as ints? Or should I be getting some other type instead? bytes? How exactly is image data stored in a ColorImage obtained from an Axis Camera? My assumption is a sequence of ints, each representing an RGB value for each pixel. I could be very wrong. Is this image still compressed at this stage? Is there a method call to decode it into some kind of bitmap close to what I’ve described above?

When I try and getSize of the image’s Pointer, it returns 0? Is this Pointer improperly constructed? No matter what I try and get (bytes, ints, single values, or arrays) using this Pointer, I get an OutOfBoundsException. If I construct a new Pointer at the same address, with some arbitrary size, I can get values, but it doesn’t look like any kind of RGB data I recognize.

How can we get access to raw image data?

I’m trying to understand what you are doing. I assume you are going to check in your array of values to see if a pixel is a certain color (maybe for the hot goal), yes, no?

Breakdown of a color image: As I am sure you are aware, color images are in the format RGB, red blue green (or bgr if you’re using opencv, don’t ask me why). Say your resolution is 320 x 240. Great. What does that really mean? The image is 3 channels deep. It has a red, green, and blue channel, all with size 320 x 240.

So what I think is happening is that you are trying to get the value of a pixel at (x,y) when there are 3 values really.

If this is the problem, there are two solutions that I can think of: One would be to simply split the image into 3 so each channel gets its own image. But, that triples the amount of data the program has to sort through, which isn’t very efficient, especially considering that you already have the data.

The second would be try to call the value of the pixel, like you were attempting, but choose what channel you want to take the value from.