Go to Post 50 years from now, the FRC will still be waiting and hoping for a water game. That's my prediction. - TheBoulderite [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 20-01-2012, 17:26
rp181 rp181 is offline
Registered User
FRC #0662
 
Join Date: Jan 2011
Location: US
Posts: 5
rp181 is an unknown quantity at this point
Quadrilateral of Best Fit

Our team is attempting to have functioning vision. At this point, we have an algorithm to detect blobs, compute the convex hull of the blobs, and calculate the area score and AR score.

Assuming I can pick out which polygon represents the square, how do I go about extracting the 4 corners of it? The computed polygon has around 20 vertices every time, and in order to do the necessary calculations, I need the 4 vertices of a quadrilateral that best describes the shape.

How would i go about this?
  #2   Spotlight this post!  
Unread 20-01-2012, 17:59
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Quadrilateral of Best Fit

Assuming your computed polygon actually is a quadrilateral, and the larger number of vertices is simply due to slight camera error, you could run an algorithm that groups nearby vertices into a single point, creating 4 points that are a rough quadrilateral.
__________________
Attending: MN Duluth Regional
  #3   Spotlight this post!  
Unread 20-01-2012, 18:19
CodeYeti's Avatar
CodeYeti CodeYeti is offline
FRC Addict
AKA: Matt Coffin
FRC #0662 (Rocky Mountain Robotics)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Colorado
Posts: 81
CodeYeti is an unknown quantity at this point
Re: Quadrilateral of Best Fit

I guess you could check the angle between each of the vertices and cherrypick out the vertex with the angle closest to 180 and repeat until there are only 4 vertices left. Just an idea though. I haven't actually tried that.
  #4   Spotlight this post!  
Unread 20-01-2012, 18:36
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Quadrilateral of Best Fit

I think it will be easier to find a solution if you think in terms of slope and intercept, instead of x and y.

This might help (or terrify): http://www.cse.unr.edu/~bebis/CS791E...esentation.pdf
  #5   Spotlight this post!  
Unread 20-01-2012, 18:48
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: Quadrilateral of Best Fit

One of the things you might attempt is to visit the vertices and connect lines that almost touch and are almost the same slope. This will eliminate collinear line segments.

Years ago I implemented some decimation routines for a pen plotter. The algorithm involved looking at a progression of points and determining if they were within an error cone that extended from the first point. The purpose was to only transmit the points needed to draw the shape and leave out the points that barely wiggled the pen or were just segments of a straight line.

To find a corner, a similar routine could identify points roughly shared between two segments where the angle is between say 60 and 120 degrees.

Finally, while this will help to eliminate collinear points, you will then want to determine if it is a quadrilateral. Sounds like a fun challenge.

Greg McKaskle
  #6   Spotlight this post!  
Unread 20-01-2012, 19:04
rp181 rp181 is offline
Registered User
FRC #0662
 
Join Date: Jan 2011
Location: US
Posts: 5
rp181 is an unknown quantity at this point
Re: Quadrilateral of Best Fit

I think eliminating co-linear segments and certain vertices is the hint I needed. After that, I believe looking at the angles will work.

I tried to simply measure the angle between points and pick the best one, but it was almost good. I believe the jaggedness of the line resulted in a false positive. If two points are very close and differ by a small amount, the angle gets very steep very quickly, with resolution limited by the pixels.

Has anyone else gotten good vision tracking in Java done? Another problem we are finding is an excessive glare, making the target unrecognizable. Hopefully, it will be different with competition lighting (very low ceilings in our build space).
  #7   Spotlight this post!  
Unread 20-01-2012, 19:23
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: Quadrilateral of Best Fit

Can you share the images with the glare? I'd love to give it a shot.

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:54.

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