Go to Post I haven't been this excited since I was 12 years old and it was x-mas eve. - wilsonmw04 [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 Rating: Thread Rating: 3 votes, 3.67 average. Display Modes
  #1   Spotlight this post!  
Unread 20-01-2011, 13:07
bsudduth bsudduth is offline
Registered User
None #2751
 
Join Date: Oct 2009
Location: Clemson, SC
Posts: 6
bsudduth is an unknown quantity at this point
Vision Tracking in Java

(Note - I originally posted this in the NI LabView forum. I copied and pasted it over here as I would think it would get more visibility in the Programming forum.)

I am trying to help Team 2751 to do vision tracking for the first time this year. We program our robot using Java, and I am curious how much of the NI Image Processing library is really available to us. A few questions to anyone kind enough to answer:

1. Other than getting the settings from the color thresholding operation, how much of the NI Vision Assistant algorithm prototyping can be transferred to Java? For example, I did some template matching in the Vision Assistant that works well. I can, of course, save the script for inclusion in VI. Is it possible to access VI from Java?

2. In the Javadoc reference, the package to access NI's nvision library is edu.wpi.first.wpilibj.image. It only has the following classes referenced in documentation:
BinaryImage
ColorImage
CurveOptions
EllipseDescriptor
EllipseMatch
HSLImage
Image
MonoImage
ParticleAnalysisReport
RegionOfInterest
RGBImage
ShapeDetectionOptions

These classes appear to be there to support the Java sample machine vision projects from last year. Are other NI image processing functions available through wpilibj or is it just based on the people writing wrapper classes for the functions that are needed?

3. According to the WPI Robotics Library Users Guide - which is ostensibly for Java and C++ - there is reference to the FRC Vision API Specification document, which gets installed with WindRiver. Is it only available in WindRiver? Do I really have to install the IDE for C++ that I don't need since I am using Java NetBeans?

The snippet of information I see in the Library Users Guide says that the FRC Vision Interface includes high level calls for color tracking through TrackingAPI.cpp. It also says programmers may call into the low level library by using nvision.h. Are the trackingAPI and/or the low level calls available to Java? The Java VM we have doesn't support JNI - which is the typical way to make calls to C-libraries.

In summary, it looks like for image processing, LabView has the most support, followed by WindRiver C++, with Java bringing up the rear. From reading this forum, however, I see that several of you are using Java. Are the issues I raise here really not that big of a deal? How did you overcome them?

Any answers and guidance to getting started would be most appreciated. Thanks for your help and good luck during the build season.

Barry Sudduth
Team 2751
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2011, 02:43
EdenA EdenA is offline
Programmer & Driver
AKA: Anthony Eden
FRC #1540 (The Flaming Chickens)
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Portland, Oregon
Posts: 10
EdenA is an unknown quantity at this point
Re: Vision Tracking in Java

Those were nearly the exact set of observations we made while using Java this year, before switching to C++. Basically, the Java WPILib does not expose any nivision.h (imaq*) functions, and consequently makes it very difficult to do any effective image processing in Java. One of the options we could have taken was to generate Java wrappers for all those functions, but since I don't know Java that well and it would have been a pain to expose everything, we decided to switch to C++.

If you know C++, I would recommend switching if image processing is one of your requirements.
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2011, 08:04
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: Vision Tracking in Java

I'm not sure if more of the IMAQ functions were wrapped this year. Being open source, if one team does it and submits it, all teams could use it, so I'd think it would have happened by now. Anyway, for the vision I did this year, I only used one function not in the list. I used Color Threshold as well.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 28-01-2011, 14:24
EdenA EdenA is offline
Programmer & Driver
AKA: Anthony Eden
FRC #1540 (The Flaming Chickens)
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Portland, Oregon
Posts: 10
EdenA is an unknown quantity at this point
Re: Vision Tracking in Java

Quote:
Originally Posted by Greg McKaskle View Post
I'm not sure if more of the IMAQ functions were wrapped this year. Being open source, if one team does it and submits it, all teams could use it, so I'd think it would have happened by now. Anyway, for the vision I did this year, I only used one function not in the list. I used Color Threshold as well.

Greg McKaskle
I think you're making some incorrect presumptions here.

For the first week of build season, I spent a lot of time searching the WPILib docs looking for image processing functions. All I found were some thresholding functions, particle analysis reports, and some detect ellipses off to the side. I was looking for a real image processing library, like OpenCV. We wanted to explore techniques like flickering lights on and off to identify the targets. We were using Java. So, I spent literally days trying to figure out how to achieve what I wanted to. Finally, after going through the source code of WPILib in C++, I found functions that started with "imaq" and then found nivision.h. I learned by reading through the source code that the undocumented Image pointers returned by WPILib functions went with these functions. Even then, I wasn't sure they would work. They could be completely unrelated. This was completely by chance.

Teams should not be expected to have to go through this, or be able to. This is not the standard that teams who are just learning how to program should be able to reach. If we want teams to actually do some real programming, instead of having fun calling a few cute functions to see what happens, then those who actually have control of how this library is made need to see this as simply inadequate.

Last edited by EdenA : 28-01-2011 at 14:34.
Reply With Quote
  #5   Spotlight this post!  
Unread 28-01-2011, 16:08
Bot190's Avatar
Bot190 Bot190 is offline
Registered User
FRC #0166 (ChopShop)
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2009
Location: Merrimack NH
Posts: 105
Bot190 will become famous soon enough
Re: Vision Tracking in Java

I would like to ask what specifically you are trying to do. NI makes an Machine Vision Library, that they left FIRST teams use. Many of the functions in the library have C++ and I assume Java wrappers. For more information on what the imaq* functions do I would refer you to the NIVisionCVI.chm file found in the documents folder for WindRiver. I'm not sure where, or if its given with the Java install.

If you give us a better idea of what you are trying to accomplish, we might be able to give you more help.
__________________

Reply With Quote
  #6   Spotlight this post!  
Unread 28-01-2011, 16:22
EdenA EdenA is offline
Programmer & Driver
AKA: Anthony Eden
FRC #1540 (The Flaming Chickens)
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Portland, Oregon
Posts: 10
EdenA is an unknown quantity at this point
Re: Vision Tracking in Java

Quote:
Originally Posted by Bot190 View Post
I would like to ask what specifically you are trying to do. NI makes an Machine Vision Library, that they left FIRST teams use. Many of the functions in the library have C++ and I assume Java wrappers. For more information on what the imaq* functions do I would refer you to the NIVisionCVI.chm file found in the documents folder for WindRiver. I'm not sure where, or if its given with the Java install.

If you give us a better idea of what you are trying to accomplish, we might be able to give you more help.
No Java wrappers for 98% of the functions (e.g. no imaqXor(), and no imaqGetPixel())

Last edited by EdenA : 28-01-2011 at 16:31.
Reply With Quote
  #7   Spotlight this post!  
Unread 28-01-2011, 17:27
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: Vision Tracking in Java

I would suggest moving image processing to the driver station PC. Connect the camera to the bridge and get pictures from <ip>/axis-cgi/jpg/image.cgi?resolution=320x240. Then you can use what you want.

To send/receive data back to the cRIO, look at Connector[.open()], SocketConnection, HttpConnection, DataInputStream, and DataOutputStream (on the cRIO side, that is).

Last edited by sjspry : 28-01-2011 at 18:02.
Reply With Quote
  #8   Spotlight this post!  
Unread 28-01-2011, 22:23
Bot190's Avatar
Bot190 Bot190 is offline
Registered User
FRC #0166 (ChopShop)
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2009
Location: Merrimack NH
Posts: 105
Bot190 will become famous soon enough
Re: Vision Tracking in Java

After looking into it more, I would have to agree with parts of your first post. I imagine labview has direct support for all of the imaging functions, and C++ seems to have pretty good support for all of the functions. Some of those functions have wrappers to make their use easier.

After looking at the Java libraries, it would appear that the entire NIvision library is available, but like I said, it takes a little more effort, as there aren't wrappers for all of the functions. I would direct you to NativeLibrary.getDefaultInstance().getFunction(); for more info on using the other functions in the library.
__________________

Reply With Quote
  #9   Spotlight this post!  
Unread 29-01-2011, 06:33
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: Vision Tracking in Java

The NI Vision libraries are commercially available with a C and LV interface and documentation. NI has no Java libraries to donate. When Java was introduced for the cRIO, the plan was for Java classes to wrap the C entry points. This apparently was not completed. The libraries are open source, and as I said, I'd have thought they would be more complete by now.

Greg McKaskle
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 12:59.

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