Go to Post Solutions are more likely to be implemented if you provide the solution along with the concern! - Jessica Boucher [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 13-02-2012, 22:16
jkudo jkudo is offline
Registered User
FRC #2168
 
Join Date: Feb 2011
Location: USA
Posts: 3
jkudo is an unknown quantity at this point
Image Processing - Getting an Angle

I've been scouring the forums all season for all image processing questions and answers and I appreciate everyone who has contributed to any of those forums. That being said, I now have a question of my own: is it possible to calculate an angle (camera to target) from the default available fields to Java users using the ParticleAnalysisReport?

I have reviewed the various simpler calculations to get an angle but they all require information that I don't think I am able to get through the currently wrapped NIVision methods. We were planning to compare the left and right side heights of the quadrilateral but I can't find an easy way to do this through the current Particle Report. I can't come up with any clever ways to manipulate the bounding rectangle information to come up with an angle to the target.

Any help would be appreciated! Thank you in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2012, 22:09
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Image Processing - Getting an Angle

This problem is actually one I tackled fairly early on in the build season - but its solution isn't exactly obvious.

ParticleAnalysisReport literally gives you everything you need in order to determine a vision target's horizontal angle, vertical angle, and even distance away; the only difficulty comes from finding the "calibration values" required to calculate each of these from what is given.

For the horizontal angle, you need one piece of data not provided in the particle report: the horizontal field of view of the camera. Every camera has a certain angle range at which it can see, and you can think of the image you receive as what you see when you look through a piece of paper rolled into a conic shape, with the field of view being the angle between the two sides of the paper.
This terrible ascii art of the camera's view might help you understand:
Code:
\        /
 \  FOV /
  \    /
   \  /
    \/
camera
So, onto the math... which is actually pretty simple. To find the absolute angle (from 0 to the field of view of the camera) from any given x value, you simply do this:
Code:
double absAngle = x/imgW*FOV;
where imgW is the width of the image (available in the particle report), FOV is the field of view, and x is whatever x value you want (the particle's center x, its left/right bounding box edges, etc.).

Now, having the absolute angle isn't actually that useful on its own. Your camera is looking forward, so why should you care about how many degrees from its left boundary anything is? What you do care about is how many degrees are between the camera's center (ie. the direction the robot is facing), and the angle you want to be facing (ie. the target). To do this, you calculate the relative angle, which is an even simpler calculation:
Code:
double relAngle = absAngle - FOV/2;
This maps it from a range of [0,FOV] to a range of [-FOV/2,FOV/2], with the direction the camera's facing at 0, right in the center.

You can apply this formula to different bits of data from the report to get different bits of information. For example, if you find the angles of the left and right sides of the target, you know a range of angles, all of which are technically on-target, instead of just having the angle of the center.

Just a couple notes of fields of view: first, they're usually available on a camera's data sheet, but I happen to know that the M1011's horizontal fov is 47 degrees and (I'm not as sure on this one) the 206's fov is 54 degrees. Secondly, cameras also have a vertical field of view. Although I'm fairly certain that it's proportional to the horizontal field of view by the same ratio as width to height, I haven't done all the math and can't guarantee that, so I'd suggest that you determine that empirically if you need it (there's a method to do that, but it's a bit wordy so I won't go into any more depth unless you ask me to).
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:50.

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