Go to Post They were designed that way so they would be compatible with the water-based ga.... oops, sorry, we aren't supposed to say anything about that. Never mind. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-01-2012, 18:17
JacobGH JacobGH is offline
Registered User
FRC #1849
 
Join Date: Nov 2011
Location: Bethesda, MD
Posts: 18
JacobGH is an unknown quantity at this point
Java image processing - accessing pixel data

Am I missing something huge? The ColorImage class in Java doesn't seem to do much image processing on it's own - you have to use its method to extract a MonoImage. But then, a MonoImage can only do one thing - find ellipses with the build in method. Is there any way to access individual pixel values? It would be nice to have methods, like blob detection (which labview has) but at least we could develop things like that if we had access to pixel data.

Any help would be appreciated.
  #2   Spotlight this post!  
Unread 13-01-2012, 18:24
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 990
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Java image processing - accessing pixel data

It looks like Java currently exposes a very limited set of the NI Vision library through JNA. I'm really hoping that FIRST is planning on giving us an update that wraps some of the functions necessary to find rectangles (like the ones in the Vision whitepaper), I don't think they would leave all the Java teams to do that on their own. If they don't have something up by mid next week, I will probably try and get some of them wrapped and will certainly post the modified NIVision.java if I'm successful.

Alternatively you can use the SmartDashboard Installer and program a SmartDashboard extension to do vision processing on the laptop with OpenCV. I'm hoping to get both running to compare framerates and latency.
  #3   Spotlight this post!  
Unread 13-01-2012, 18:43
JacobGH JacobGH is offline
Registered User
FRC #1849
 
Join Date: Nov 2011
Location: Bethesda, MD
Posts: 18
JacobGH is an unknown quantity at this point
Re: Java image processing - accessing pixel data

I was thinking about trying to wrap more of the functions myself. How exactly would you do that in the code?

And how do I program a smartdashboard extension to do vision processing? I had no idea you could do that. Are there instructions?
  #4   Spotlight this post!  
Unread 13-01-2012, 18:48
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 990
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Java image processing - accessing pixel data

Quote:
Originally Posted by JacobGH View Post
I was thinking about trying to wrap more of the functions myself. How exactly would you do that in the code?

And how do I program a smartdashboard extension to do vision processing? I had no idea you could do that. Are there instructions?
I was planning on trying to follow the pattern of existing wrapped functions and using the C++ versions of the files to figure out the parameters.

The SmartDashboard Vision stuff looks new and the docs don't look done yet, but you can see what is there starting on page 85 of the WPILib Cookbook (Can be found in the Documents section of the WPILib project at firstforge.wpi.edu)
  #5   Spotlight this post!  
Unread 15-01-2012, 17:22
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: Java image processing - accessing pixel data

To get the fun functions, you need to threshold into a binary image first.

I've been doing some work with the wrappers, and have done a few myself. I posted the code for the convex hull here:

http://www.chiefdelphi.com/forums/sh...ad.php?t=99536
  #6   Spotlight this post!  
Unread 15-01-2012, 22:06
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Java image processing - accessing pixel data

It is possible to do it. The Image class has a pointer to the jpeg image in memory named "Image". It is a public field and did not catch that it was there the first 2 years. You just decode that data into raw bytes and then you can access as you want to as "pixels".
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
  #7   Spotlight this post!  
Unread 16-01-2012, 00:53
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: Java image processing - accessing pixel data

Quote:
Originally Posted by davidthefat View Post
It is possible to do it. The Image class has a pointer to the jpeg image in memory named "Image". It is a public field and did not catch that it was there the first 2 years. You just decode that data into raw bytes and then you can access as you want to as "pixels".
This is far, far easier said than done. A jpeg image is by its nature compressed. To access the data, you would need to decompress it, which would take a very long time to do. Instead of only accessing the pixels you need, you would have to access all of them. You can read a little more about it here

https://en.wikipedia.org/wiki/JPEG
  #8   Spotlight this post!  
Unread 16-01-2012, 18:21
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Java image processing - accessing pixel data

Quote:
Originally Posted by JewishDan18 View Post
This is far, far easier said than done. A jpeg image is by its nature compressed. To access the data, you would need to decompress it, which would take a very long time to do. Instead of only accessing the pixels you need, you would have to access all of them. You can read a little more about it here

https://en.wikipedia.org/wiki/JPEG
And that is what I was going with. It is not as easy as it sounds.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
  #9   Spotlight this post!  
Unread 17-01-2012, 00:14
sjspry sjspry is offline
Registered User
FRC #1984
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Kansas
Posts: 125
sjspry has a spectacular aura aboutsjspry has a spectacular aura aboutsjspry has a spectacular aura about
Re: Java image processing - accessing pixel data

If all you can access is the compressed image, then no. You can not access the image data. I ported a JPEG decoder to the cRIO last year, and it did not go well (it worked, but very slowly). I used to think it might work better if done in C++, but now that I know the cRIO has an onboard FPGA, I would bet that it does the decoding.
  #10   Spotlight this post!  
Unread 17-01-2012, 15:43
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: Java image processing - accessing pixel data

It's worth mentioning that we've found that calling certain NI C/C++ functions from Java is very slow. I find it surprising that it hasn't yet been mentioned that the image classes, namely BinaryImage has a very useful set of methods beyond finding ellipses - the particle report methods. Each "blob" in a binary image is considered a particle, and the particle report allows you to access important properties of each particle, like its position, size, number of pixels in the particle, etc.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.
  #11   Spotlight this post!  
Unread 17-01-2012, 19:26
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,753
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Java image processing - accessing pixel data

The jpeg decoder on the cRIO is part of IMAQ. It is pretty standard consortium code and does not run on the FPGA, but runs on theFreescale processor.

Greg Mckaskle
  #12   Spotlight this post!  
Unread 17-01-2012, 22:57
JewishDan18's Avatar
JewishDan18 JewishDan18 is offline
Registered User
FRC #1700
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2007
Location: Sunnyvale, CA
Posts: 185
JewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to beholdJewishDan18 is a splendid one to behold
Re: Java image processing - accessing pixel data

Quote:
Originally Posted by Patrickwhite View Post
It's worth mentioning that we've found that calling certain NI C/C++ functions from Java is very slow. I find it surprising that it hasn't yet been mentioned that the image classes, namely BinaryImage has a very useful set of methods beyond finding ellipses - the particle report methods. Each "blob" in a binary image is considered a particle, and the particle report allows you to access important properties of each particle, like its position, size, number of pixels in the particle, etc.
Which functions in particular are you having slow results from? I got slow results from the getOrderedParticleAnalysisReports, but the slowdown was on the java end.
  #13   Spotlight this post!  
Unread 17-01-2012, 23:04
Patrickwhite's Avatar
Patrickwhite Patrickwhite is offline
May the North be with you
FRC #0610 (The Coyotes)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Toronto
Posts: 88
Patrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of lightPatrickwhite is a glorious beacon of light
Re: Java image processing - accessing pixel data

I tossed together a quick sample that retrieved the image from the camera, did a threshold, a convex hull operation, and got the particles, and sorted them by area. The first three of those were done with the BlockingFunction protoyped methods. The whole operation was clocking in at around 400ms with nothing else running on the robot.
__________________
while(!going.isTough());
tough.exit();

What will we do tonight, Warfa?
The same thing we do every night, Patrick. Sit and wait for Electrical.
  #14   Spotlight this post!  
Unread 18-01-2012, 08:32
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,753
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Java image processing - accessing pixel data

What size image was this, and did it include decoding the image?

Greg McKaskle
Closed Thread


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 18:45.

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