Go to Post FIRST games are complex and rely on design and intellectual capability much more than the average sport. - Chris is me [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-01-2014, 06:55
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
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:

getInts

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?
__________________
In life, what you give, you keep. What you fail to give, you lose forever...

Last edited by Mr. Lim : 16-01-2014 at 07:03.
Reply With Quote
  #2   Spotlight this post!  
Unread 16-01-2014, 11:22
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
Re: ColorImage to an array of ints?

Quote:
Originally Posted by Mr. Lim View Post
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:

getInts

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.
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi