Go to Post There is no offseason. - Jeff Rodriguez [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 10-01-2012, 23:33
jimBatch201 jimBatch201 is offline
Registered User
FRC #0134
 
Join Date: Jan 2012
Location: United States
Posts: 3
jimBatch201 is an unknown quantity at this point
Tracking in JAVA?

Ive read several posts regarding the white papers, which I've read, and other math based solutions to tracking which I understand. How am I supposed to actually measure the targets in my code? I found all the stuff regarding the images themselves but how do I analyze the images in my code?
Reply With Quote
  #2   Spotlight this post!  
Unread 12-01-2012, 18:42
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: Tracking in JAVA?

What point are you at? Do you have an image from the camera? If you are more specific, we can tell you what the next step is
Reply With Quote
  #3   Spotlight this post!  
Unread 12-01-2012, 22:32
shoffing's Avatar
shoffing shoffing is offline
WINriver C++
AKA: Steve Hoffing
FRC #1647
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Shamong, New Jersey, America
Posts: 10
shoffing is an unknown quantity at this point
Re: Tracking in JAVA?

So I've been messing around with it for a bit and so far all I managed to get is this:

Code:
try {
    ColorImage img = camera.getImage();

    // Do the threshold
    BinaryImage bImg = img.thresholdHSL(0, 255, 0, 20, 239, 255);

    //Do convex hull???

    for(int i = 0; i < bImg.getNumberParticles(); i++)
    {
        ParticleAnalysisReport report = bImg.getParticleAnalysisReport(i);

        // Identify the vision targets in here using the reports
    }

    // Work with the vision targets

} catch (AxisCameraException ex) {
    ex.printStackTrace();
} catch (NIVisionException ex) {
    ex.printStackTrace();
}
But the binary image needs to be modified before it gets the particle analysis report. More specifically, a convex hull operation needs to be used to turn the hollow rectangles into filled ones (and ensuring they only show up as single particles instead of potentially multiple). At least, that's what it says to do in the Vision Tracking PDF. However, functionality of the convex hull operation appears to have not been implemented, I found this line in NIVision.java, line 521:

Code:
//IMAQ_FUNC int           IMAQ_STDCALL imaqConvexHull(Image* dest, Image* source, int connectivity8);
That's the function I want! But it's commented out! Why? Does anybody know of any ways to do a convex hull operation in java? Or is there a work around?

This is the first year our team is attempting camera tracking, by the way.

http://www.wbrobotics.com/javadoc/ed...e-summary.html
__________________
---
Team 1647's Software "thing" for 2011
Death-Spin autonomous mode is my favorite.
Reply With Quote
  #4   Spotlight this post!  
Unread 13-01-2012, 09:24
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: Tracking in JAVA?

Yea im stuck too, this is my first year using vision tracking
Reply With Quote
  #5   Spotlight this post!  
Unread 13-01-2012, 12:38
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: Tracking in JAVA?

Quote:
Originally Posted by ProgrammerMatt View Post
Yea im stuck too, this is my first year using vision tracking
If you don't tell us what's wrong we can't help Where are you stuck?
Reply With Quote
  #6   Spotlight this post!  
Unread 13-01-2012, 14:32
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: Tracking in JAVA?

Quote:
Originally Posted by JewishDan18 View Post
If you don't tell us what's wrong we can't help Where are you stuck?
I m stuck with actually analyzing the images so far i have a line doing this

Code:
ColorImage image = AxisCamera.getInstance().getImage();
Bye the way team 20? we won WPI with you a year ago remember team GUS 228
Reply With Quote
  #7   Spotlight this post!  
Unread 13-01-2012, 15:21
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: Tracking in JAVA?

Quote:
Originally Posted by ProgrammerMatt View Post
I m stuck with actually analyzing the images so far i have a line doing this

Code:
ColorImage image = AxisCamera.getInstance().getImage();
Bye the way team 20? we won WPI with you a year ago remember team GUS 228
Haha yes, I remember, it was an awesome regional. I wish we were going back, but we're doing GSR and CT this year.

So from there, you have an image object. I would recommend printing out the height and width of the image, to make sure your camera is hooked up properly. From there, the traditional route is to threshold the image to get a binary image which should ideally contain only the rectangle. From there, WPILib has a rectangle detection function, which should work for basic stuff. From there, you get the height and width, and can do a bunch of trigonometry to figure out how far away it is. I would start by figuring out the thresholding functions; play around with them and see what they do. If you have any questions, please ask!
Reply With Quote
  #8   Spotlight this post!  
Unread 13-01-2012, 15:34
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: Tracking in JAVA?

Quote:
Originally Posted by JewishDan18 View Post
Haha yes, I remember, it was an awesome regional. I wish we were going back, but we're doing GSR and CT this year.

So from there, you have an image object. I would recommend printing out the height and width of the image, to make sure your camera is hooked up properly. From there, the traditional route is to threshold the image to get a binary image which should ideally contain only the rectangle. From there, WPILib has a rectangle detection function, which should work for basic stuff. From there, you get the height and width, and can do a bunch of trigonometry to figure out how far away it is. I would start by figuring out the thresholding functions; play around with them and see what they do. If you have any questions, please ask!
Ok so play with the thresh holds but is there a way i can see it realtime while running it?

and where is the rectangle detector i could not find it.

Sorry im a real noob on java i havent had much teaching.
Reply With Quote
  #9   Spotlight this post!  
Unread 13-01-2012, 23:17
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: Tracking in JAVA?

I have no experience with it, but the Labview code lets you play with threshold values as you operate the camera. You should check the Labview subforum for this; there are some people from NI who know much much more about it than me.

I'm sorry, but the "detect rectangles" code is only in C++ and labview... I'm relatively sure that if sample code is posted like it is most years, it will contain rectangle detection code (that is, if sample code is posted). Once you find a nice threshold, you should look at the particle reports, since those are what you will be analyzing. You can get the bounding rectangle of a piece of the image, and know the expected area filled (since you know the width of the tape), and can compare that to the particle filled area...but i would concentrate on the thresholding for now

Everyone is a noob sometime, that's what these forums (and FIRST) are for
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 00:41.

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