View Single Post
  #1   Spotlight this post!  
Unread 02-04-2016, 19:16
simon-andrews's Avatar
simon-andrews simon-andrews is offline
Registered User
FRC #4761 (Robockets)
Team Role: Programmer
 
Join Date: Feb 2015
Rookie Year: 2015
Location: Reading, MA
Posts: 16
simon-andrews is an unknown quantity at this point
Re: How can angle offset of a shooter be calculated from pixel offset?

Quote:
Originally Posted by Oblarg View Post
Pixel displacement should be strictly proportional to angular error, since the camera is effectively a point. To convince yourself of this, draw a picture of the shooter and the target (top view, camera at the origin).

Figure out the lateral FOV of the camera in degrees, and calculate proportional to that using the known width of the image in pixels.
Quote:
Originally Posted by lethc View Post
If your camera is mounted solidly then you should be able to interpolate the offset angle of your shooter by using the first option (how many pixels away from the middle the goal is). This isn't necessarily the best way to solve the problem but it works and it's really easy. Is that all you're asking?
Sorry, I worded my original post poorly and wasn't clear. This method actually is what I was doing originally, with this code:

Code:
def get_offsets(bb_leftside_x, bb_width, img_width):
	middle = bb_leftside_x + (bb_width / 2)
	pixel_offset = middle - img_width / 2
	angle_offset = pixel_offset * (26.5 / (img_width / 2)) # Raspberry Pi camera module FOV is 53 degrees
	ret = {
		"pixel_offset": pixel_offset,
		"angle_offset": angle_offset,
	}
	return ret
What I need to get is an angle that can be fed directly into the turntable as an amount to turn.

https://imgur.com/RelZro4
__________________

GitHub | StackOverflow
Reply With Quote