View Single Post
  #2   Spotlight this post!  
Unread 23-08-2013, 11:15
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: JavaCV Widget Questions

"x" and "y" coordinates usually refer to the location of a pixel in the camera image. There are different systems for the coordinate system, but usually "x" is horizontal (so it counts the number of columns) and starts with 0 at the left edge, and (image width-1) at the right edge. "y" is vertical (so it counts the number of rows) and usually starts with 0 at the top, and (image height-1) at the bottom.

Thus the origin (0,0) is usually in the top left of the camera image for computer graphics and computer vision applications (though some times you'll find code with the origin in the lower left).

Let's say your camera is mounted on your shooter, and the shooter is amazingly well calibrated. It always shoots discs straight down the middle of the camera image. If your image has a resolution of 640x480 (width x height), then your shooter is aiming at about (320, 240) for (x,y).

Now, if you detect that the center of the goal is to the left of the shooter - say, (100, 240) - then you know you need to turn the robot to the left to aim. If you can get the detected center of the goal in (close to) the exact same spot that your shooter fires, you know you'll have a high chance of making the shot.

Calculating distance is a little bit tougher. It will involve doing some trigonometry, since a standard RGB camera does not give you distance information directly. One way to do it (which we did to great effect in 2012) is to use the "y" component of the center of the goal. If you know your camera's height off the ground, the camera's angle with respect to the ground, the height of the goal, and the "y" component of the goal center, you can set up an inverse trigonometry problem to obtain the missing sides of a triangle. There are other ways to do it too (multiple cameras for stereo vision, or using the size of the goal to figure out distance), but I contend that using trigonometry is the most robust way for FRC (short of using a Kinect). Luckily, most frisbee shooters have a pretty flat arc, so you may not need to do this at all!

For your questions on variables, it depends which examples you are looking at. Here is an example I posted last year (gee, maybe I should update it with some new features from our 2013 version?): http://www.chiefdelphi.com/media/papers/2676? Feel free to ask away about anything in particular.

Last edited by Jared Russell : 23-08-2013 at 11:18.
Reply With Quote