Go to Post I always love the optimism of [build] week 1. - Donut [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 07-01-2012, 21:52
bhasinl bhasinl is offline
Registered User
FRC #1884 (Griffins)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: London
Posts: 6
bhasinl is an unknown quantity at this point
Tracking Rectangles

For this year's game, it seems to be necessary to locate the backboards programatically in both the "hybrid" and tele-op periods. I found a paper from Team 1511 that helps determine a robot's position relative to a vision target (see: http://www.chiefdelphi.com/media/papers/2324).

I feel like most of the math and thought behind that paper would translate well to this scenario too. The only problem is finding the rectangles accurately in an image using the camera or Kinect. I was wondering if any teams had any tips on how to do this with the camera, since we haven't really tried camera-tracking since we played with CircleTrackerDemo two years ago. Unfortunately, most of the CircleTrackerDemo code seems specific to ellipses only. Any ideas on how to do rectangles with a camera? Perhaps some code we can use?

If that isn't possible, an alternative would be using the Kinect. Although I'm sort of clueless when it comes to shape tracking (outside of human shapes) with the Kinect.

Thank you for your help, and I appreciate any input you may have.
Reply With Quote
  #2   Spotlight this post!  
Unread 07-01-2012, 22:08
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: Tracking Rectangles

http://users.cecs.anu.edu.au/~nmb/papers/06-PRD.pdf
http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm
http://www.inf.ufrgs.br/~crjung/rese...paper_1125.pdf

Go knock yourself out.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #3   Spotlight this post!  
Unread 08-01-2012, 10:52
bhasinl bhasinl is offline
Registered User
FRC #1884 (Griffins)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: London
Posts: 6
bhasinl is an unknown quantity at this point
Re: Tracking Rectangles

Looks like a lot of complicated math to work through, but that's to be expected. I am interested in how your first link does perspective rectangle detection, but it doesn't seem to include any mathematical descriptions. There are some vague mentions of finding the vanishing points and the unit vector field pointing in the direction of vanishing lines, but nothing specific.

There's currently a rectangle processing VI or something like that for LabView programers. I'm hoping that could be ported to Java (and/or C++) soon, since we moved on from LabView a long while back. Is there any word on this?

I was also wondering how other teams accomplished tracking of retro-reflective tape (in circular and rectangular shapes) for Logomotion in Java. From an electronic point of view, a cluster of LEDs around the camera seems necessary. However, programmatically, was it necessary to do Hough Transforms? If so, is there a more concise description of these transforms we can access? Perhaps how to take the transformed image and use it to determine the edges of a rectangle? Thanks as always.
Reply With Quote
  #4   Spotlight this post!  
Unread 08-01-2012, 11:18
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,748
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: Tracking Rectangles

I can't find the white paper on the NI site yet, but one should be posted soon that covers several approaches. One approach uses simple particle analysis to identify the ones most like hollow rectangles. Another approach is to use the line or rectangle geometric fit routines -- which are Hough implementations under the hood.

The paper actually uses NI Vision Assistant for most of the exploration, but does refer to the LV example when it comes to scoring and position/distance calculation. The LV example will also run directly on your computer, so your cRIO can run whatever, and the laptop can pull images directly from the camera that is on the switch.

Greg McKaskle
Reply With Quote
  #5   Spotlight this post!  
Unread 08-01-2012, 11:55
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 588
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Tracking Rectangles

I posted a copy of Greg's the Whitepaper here:

http://firstforge.wpi.edu/sf/docman/...ib/docman.root

This has a lot of good information about finding and tracking the 2012 vision targets.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #6   Spotlight this post!  
Unread 08-01-2012, 13:39
bhasinl bhasinl is offline
Registered User
FRC #1884 (Griffins)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: London
Posts: 6
bhasinl is an unknown quantity at this point
Re: Tracking Rectangles

Thank you Brad, this is perfect. Just three questions/comments for anyone:

1) On the PDF under the "Measurements" section concerning distance (page 9), it says that the blue rectangle width is 11.4 ft but half the blue rectangle width is 6.7 ft. I don't know who wrote this, but that seems like a typo.

2) Does the particle processing method only accurately find rectangles when it encounters them head on? Is the edge detection method necessary to find rectangles distorted by perspective?
  • I'm assuming it's possible to use the edge detection method in Java by taking the NI Vision Assistant's generated C code and translating it (hopefully).

3) Are there any pointers you can give on how to process camera images on the laptop instead of the cRIO? We've never tried this before, but it seems worth doing.

Thank you again for your help.

Last edited by bhasinl : 08-01-2012 at 13:40. Reason: Clarification
Reply With Quote
  #7   Spotlight this post!  
Unread 08-01-2012, 15:07
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Tracking Rectangles

I have to wonder if you read these papers before you suggested them. Expecting somebody with high school education (assuming bhasinl has completed high school in the first place) to read through these papers without your own practical insight and reasoning for posting them seems a little pointless.
Reply With Quote
  #8   Spotlight this post!  
Unread 08-01-2012, 15:11
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: Tracking Rectangles

Quote:
Originally Posted by basicxman View Post
I have to wonder if you read these papers before you suggested them. Expecting somebody with high school education (assuming bhasinl has completed high school in the first place) to read through these papers without your own practical insight and reasoning for posting them seems a little pointless.
I was just trying to help, but I was merely trying to demonstrate the complexity of the issue. It is just not merely telling the cRio to find a rectangle and that there are many things going behind the scene.

Personally, these types of papers are actually fun to read. Even if you only understand quarter of the math, the more you try, you start getting a bigger picture. I think it is more beneficial to butt your head and try going through this way first before using code already provided. It really builds character IMHO.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #9   Spotlight this post!  
Unread 08-01-2012, 15:28
bhasinl bhasinl is offline
Registered User
FRC #1884 (Griffins)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: London
Posts: 6
bhasinl is an unknown quantity at this point
Re: Tracking Rectangles

I love challenges too and it was interesting to read and actually (somewhat) understand the problem of image processing better. Of course, I appreciate that it is quite a big feat, and know through experience that you can't tell the cRIO to just look for a rectangle. However, given that the NI Vision Assistant does a lot of what we need it to do in terms of image processing, it makes more sense to use that instead of writing code that does Hough transforms on images and looks for peaks. Thank you for the read though.

Going back to the issue, I was wondering if any teams could answer my third question from my post above: how is it possible to have the image processing happen on the laptop instead of the cRIO? We're replacing our Classmate this year so the performance gain could be significant. I read in the PDF that making this switch requires no change in code (or something along those lines). What does it require then?
Reply With Quote
  #10   Spotlight this post!  
Unread 08-01-2012, 15:43
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Tracking Rectangles

Quote:
Originally Posted by bhasinl View Post
how is it possible to have the image processing happen on the laptop instead of the cRIO? We're replacing our Classmate this year so the performance gain could be significant. I read in the PDF that making this switch requires no change in code (or something along those lines). What does it require then?
The code will be the same because the components you use in LabVIEW are abstracted for each library (IMAQ for the cRio/laptop and OpenCV for the laptop). For instance if you use some sort of rectangle detector block, LabVIEW will know whether to use IMAQ or OpenCV based on the target platform - your code remains the same.

If you're using your Classmate as the DS and want to do the processing on there, I assume you'd use the dashboard data (there should be examples in LabVIEW, there are in C++).

I'm still wondering how to do it between the cRio and a laptop on the robot.

EDIT:

Quote:
To take advantage of this and distribute the processing, you need to send the image from the robot to the dashboard laptop, process it, and then send the results back to the robot. Transmitting data and images also takes time, so the best location to process images depends on all of these factors. You may want to take measurements or experiment to determine the best approach for your team.
This is the quote from NI's document, so yes you'll have to use the dashboard data example.

Last edited by basicxman : 08-01-2012 at 15:47.
Reply With Quote
  #11   Spotlight this post!  
Unread 08-01-2012, 20:36
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,748
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: Tracking Rectangles

I was once good at head-math, but I guess things change. The formula is correct, you take half of the blue rectangle. The example values are wrong, half of 11.4 is 5.7, not 6.7.

As for running on the laptop. The LV example project does both. A LV project can have code for multiple devices or target devices. For simplicity, the FRC projects tend to have only one. The rectangular target processing project has roughly the same code with slight differences in how it is invoked under both the My Computer section of the project and the RT cRIO section. The tutorial goes into detail about how to Save As the RT section to run on the cRIO, but if you prefer, you can pretty easily integrate the My Computer VI into your dashboard, do the processing, and arrange for the values to be sent back to the robot via UDP or TCP.

If you prefer to use OpenCV, it should theoretically run both locations, but I'm not aware of any port of it for the PPC architecture. Both OpenCV and NI-Vision run on the laptop.

If I glossed over too many details, feel free to ask more detailed questions.

Greg McKaskle
Reply With Quote
  #12   Spotlight this post!  
Unread 09-01-2012, 11:34
Jay Meldrum's Avatar
Jay Meldrum Jay Meldrum is offline
Registered User
FRC #0067 (H.O.T.)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2003
Location: Michigan
Posts: 42
Jay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud ofJay Meldrum has much to be proud of
Re: Tracking Rectangles

Quote:
Originally Posted by Greg McKaskle View Post
Integrate the My Computer VI into your dashboard, do the processing, and arrange for the values to be sent back to the robot via UDP or TCP.
Greg: Are there any examples out there of the dashboard sending data via UDP or TCP data and example of the cRIO receiving UDP or TCP data using C++ code?


Pretty new to the whole FRC programming as a whole. Sorry if this is a "dumb" question.

Thanks,

Jay
Reply With Quote
  #13   Spotlight this post!  
Unread 09-01-2012, 12:18
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,748
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: Tracking Rectangles

The framework examples do a bit of this already, but for a limited protocol.

If you drill into the dashboard code, you will find that the camera loop does TCP port 80 communications to the camera. The Kinect loop does UDP from a localhost Kinect Server, and even the other loop gets its data from a UDP port from the robot.

For the robot side, there are C++ classes for building up a LabVIEW binary type and submitting it for low or high priority user data. I'm not that familiar with other portions of the framework which may directly use UDP or TCP.

Greg McKaskle
Reply With Quote
  #14   Spotlight this post!  
Unread 09-01-2012, 23:16
mikegrundvig mikegrundvig is offline
Registered User
FRC #2410 (Metal Mustangs)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 100
mikegrundvig is an unknown quantity at this point
Re: Tracking Rectangles

The whitepaper is extremely useful but the part I needed help with is actually what's glossed over the most. My understanding is that it's fully possible to determine both angle and distance from the target by the skew of the rectangle and the size. Here is a quote from the whitepaper:

"Shown to the right, the contours are fit with lines, and with some work, it is possible to identify the shared points and reconstruct the quadrilateral and therefore the perspective rectangle"

Except it stops there. Have any other reading or direction you can send us to take this the rest of the way? I'd really like our bot to be able to find it's location on the floor with the vision targets and unless we are straight-on, this is going to require handling the angle. Thanks!

-Mike
Reply With Quote
  #15   Spotlight this post!  
Unread 09-01-2012, 23:25
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Tracking Rectangles

But question is still how do you get the robot to track the rectangle like it would with a circle?
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 10:29.

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