Go to Post Reffing a FIRST event is unlike being an ump or a ref at any other event. Where else is a game invented each year and over 1000 teams play this game within 3 months of its birth? - Andy Baker [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

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-04-2016, 20:26
Oblarg Oblarg is offline
Registered User
AKA: Eli Barnett
FRC #0449 (The Blair Robot Project)
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2008
Location: Philadelphia, PA
Posts: 1,087
Oblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond reputeOblarg has a reputation beyond repute
Re: How can angle offset of a shooter be calculated from pixel offset?

Quote:
Originally Posted by simon-andrews View Post
No. That function isn't what I need because it doesn't return an angle that can be plugged into the turntable. The program I'm supposed to write should be able to look at an image and figure out "Alright, turntable. You need to turn 45 degrees if you want to be on-target."

If we look at this drawing from an earlier post, both lines (which represent pixel offsets) are 100px long. With the function from before, both would return the same angle offset since the function doesn't account for distance away from the target.
You're slightly confused.

Distance away from the target doesn't matter, that's precisely why you're measuring in angle (a dimensionless quantity) and not in distance.

Imagine the camera at the origin, pointing in the +y direction. Place your target off to the side somewhere. How far off-center your target will appear in pixels is proportional to the angle between the line from the origin to the target and the y axis, not to the distance from the point to the y axis. To see this, place one target at (1,1). Place another target at (1,2). These are the same distance from the y-axis, which is the centerline of the camera's FOV, but they will clearly appear at different distances from the center when viewed from the camera, because the camera is a point at the origin and only sees along rays that pass through it.

For an even better demonstration: Cover one of your eyes, align your other (open) eye with the center of your computer screen. Place your finger between your face and your computer screen, so that it overlaps with the edge of the screen in your vision. Notice that your finger is closer to the centerline between your eye and the center of the screen than the edge of the monitor is, despite the fact that they appear the same "distance" away in the 2d image that you see.

The fundamental confusion here is that you're thinking in terms of rays parallel to the center-line of the camera. But that's incorrect, because those rays never reach the camera. Think of the camera as a point, not as a screen. All the rays that the camera sees must pass through the point. Thinking this way, it is clear that "distance" in the image the camera sees corresponds to *angular* distance. To preserve apparent "distance" between two objects from the point of view of the camera, you must preserve their relative angular positions.
__________________
"Mmmmm, chain grease and aluminum shavings..."
"The breakfast of champions!"

Member, FRC Team 449: 2007-2010
Drive Mechanics Lead, FRC Team 449: 2009-2010
Alumnus/Technical Mentor, FRC Team 449: 2010-Present
Lead Technical Mentor, FRC Team 4464: 2012-2015
Technical Mentor, FRC Team 5830: 2015-2016

Last edited by Oblarg : 02-04-2016 at 20:51.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-04-2016, 21:00
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: How can angle offset of a shooter be calculated from pixel offset?

If you want to aim to the center of the target than obtain the center x of the target and rotate to it using the formulas postEd.

In the photo posted, the left edge of the target is roughly at x=0 (assuming a graph is overlayed) and the right boundary is at x=x for the "far" target and x=2x for the "near" target, meaning the centers would be at x=1/2x and x=x respectively. The "near" target will request twice as much turning.

Also please stop using the word turntable
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #3   Spotlight this post!  
Unread 04-04-2016, 14:48
GreyingJay GreyingJay is offline
Robonut
AKA: Mr. Lam
FRC #2706 (Merge Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Ottawa, Canada
Posts: 778
GreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond repute
Re: How can angle offset of a shooter be calculated from pixel offset?

Quote:
Originally Posted by Arhowk View Post
Also please stop using the word turntable
It's a Lazy Susan!
Reply With Quote
  #4   Spotlight this post!  
Unread 04-04-2016, 21:06
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: How can angle offset of a shooter be calculated from pixel offset?

It's fairly simple. It's (pixels from center) / (camera pixel width) * FOV
For example, your camera has a field of view (FOV) of 45 degrees, your camera width is 320 pixels, and your image is 16 pixels off center. Then the angle to aim is:

(320 pixles/16 pixels) * 45 degrees = 2.25 degrees

You can calibrate your exact camera FOV by pointing your camera at a white board and marking two points on the white board at the left and right edge of the camera image. Then measure the distance between the two points on the white board, and the distance between the white board and the camera. Then a little trig will give you the FOV.
__________________
-
An ounce of perception is worth a pound of obscure.
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 01:32.

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