Close

Great Question on Camera Angles and Positioning (from Discord)

A project log for PiTrac - The DIY Golf Launch Monitor

Launch monitor using low-cost Raspberry pi and camera hardware to determine ball launch speed, angles and spin

james-pilgrimJames Pilgrim 6 days ago0 Comments

So a great question on the Discord server was:

The following picture from the camera calibration instructions shows why it is relatively easy to hit PiTrac with the golf ball in the default camera configuration – because the Camera 1 looks “back” at the ball, which means PiTrac is further ahead of the ball.  And sometimes in harm’s way…


(Oh – and yes – I’ve hit the prototype PiTrac with the ball lots of times.  The poor thing has long suffered from my poor golf skills).

Summary Answer:

The really short answer is YES – we should be able to change the camera angles so that Camera 1 looks straight out (and down), and then Camera 2 looks to the left (in the picture above), basically down-range.  The angles and relative positions of the cameras in the system are presented as configuration values in the golf_sim_config.json file.  PiTrac is designed to be flexible (especially since it’s experimental).  If you switched the cameras around and calibrated them correctly and pushed the resulting position/angle information into the .json file, the system should still work.  And in this case, you would move the PiTrac back to be more or less even with where the teed-up ball is.  Although I’m sure I could hit some wild shot that will still nail the PiTrac right in the…ball-watching camera.

Even better would be if both cameras could look straight out, as we’ll discuss in a moment.  But we’re not quite there yet in terms of processing speed.

More Detailed Answer:

Let’s look at the current camera setup first.  With the Camera 2 (the strobed camera) facing straight out from the monitor as it is now, the camera is looking at the ball in flight basically perpendicularly (from the side).  In that case, we get images that look like:


In this configuration, the size of the ball is mostly constant, and should be affected only by the Z-axis position of the ball.  And the Z-Axis movement is going to determine the horizontal (side-to-side) launch angle, HLA.  By Z-axis, I mean straight out from the monitor, as suggested by the first picture, above.

But if Camera 2 is facing more down-range, closer to the angle of ball flight, the perspective changes, of course.  In that case, the same shot shown above will look more like this:


Here, the X-axis (left-right as the camera sees it) is more compressed, and the imaged size of the ball decreases with distance, because the ball is getting further from Camera 2 as it flies.  This alternate camera positioning (especially if taken to the extreme) creates a few challenges:

  1. Especially at shallow VLA (vertical launch angles), there is more ball overlap because the camera is sort of looking at the ball from behind.  In an extreme case, the strobed ball imprints might all overlap and look like concentric circles as the ball flies downrange. 
  2. The increased overlap may make it more difficult to find two good, clear, images to use in the spin-analysis, so spin accuracy could decrease.
  3. Because of the compressed X-axis, HLA accuracy may decrease, because there are not as many pixels through which to measure HLA.  And at the (current) low resolution of the Pi GS camera, a single pixel error could mean mis-locating the ball by several millimeters or more.
  4. The compressed X-axis also means that calculating the distance the ball moved between strobe pulses will likely be less accurate.  And that will affect the ball speed measurement, and that, of course, is an important metric for a launch monitor.

Positioning the Camera 2 so that it is looking straight out at the ball in flight was an attempt to maximize the accuracy of speed and VLA measurement, as well as the number of good, non-overlapped images for spin analysis.  Although it does so at the expensive of HLA accuracy, because the perceived radius of the ball (which is determined by the Z-axis position) is pretty touchy, and small errors in circle-detection can create larger errors in HLA determination.

However, it’s certainly possible that moving the cameras a little bit in the way @Merrygrin suggests won’t affect accuracy that much, but would still allow the system to be moved a little more from harm’s way.  We’ll have to experiment with that once we get things stable in the builder community, and hopefully some of our contributors will do the same.

A related question is why not just have both cameras point straight out?  This would make it really simple to switch between left- and right-handed golfers as well as allowing the safer positioning of the monitor.  There are a couple current problems with this:

  1. Even with 500 FPS (2ms between images), the golf ball could (in a worst case, when it moves right after the last image is taken by the camera) move 20 centimeters downrange.  And with additional processing latency, it could be even further downrange by the time the Pi 1 system calculates the pixel differences between the most-recent frame and the prior frame and opens the Pi 2 camera shutter and starts sending strobe pulses.  By that time, the ball may have already moved out of the field of view.
  2. By positioning Camera 2 right where the ball is, it effectively cuts the field of view in half.  The area to the left of the ball (from the camera’s perspective, for right-handed golfers) is wasted, because the ball only goes from the middle of the image to the right. 
  3. For the same reason as for #2, above, this configuration effectively reduces the resolution of the camera in half for the pixels that can “see” the ball in flight.

That said, I’m optimistic we’ll get to a point where the cameras can be straight out some day.  And I’ve noticed that even now, if you set the ball too far back (to the right, looking at the PiTrac), the processing is fast enough on the Pi 5 that we’re actually sometimes getting errors at low ball speeds because many of the strobe flashes occur before the ball even gets within sight of the Camera 2.  For example: 


With all that said, we’d love to hear about people’s thoughts, ideas, musings, etc. on this subject!

Discussions