It Has to Know the Exact Moment You Swing

It Has to Know the Exact Moment You Swing

It Has to Know the Exact Moment You Swing

Dev blog #5. No buttons, no hands, no caddie. Just a phone in the dirt that has to catch you in the act.

Picture how you actually use this thing. You set your phone on the ground behind the ball, you step in, you take your normal swing. At no point do you reach down and tap a screen. You can't. You're a little busy trying not to top it.

So the app is on its own back there. It has to notice, all by itself, the instant the ball leaves, every single time, without you babysitting it. A person watching would have zero trouble with this. Getting a phone lying in the grass to have the same "there it goes" reflex turned out to be a stack of separate problems, none of which I saw coming clearly until I was standing on the range swearing at one of them.

This is the whole interface. You and a ball. The phone has to do the rest on its own.

Problem one: where do you even look?

Your instinct is "just watch for the ball to move." But the camera is running at a high frame rate, which means a new frame every few milliseconds, and each frame is a big grid of pixels. Hunting across the entire frame for movement, that fast, forever, is exactly the kind of nonstop work that cooks the phone and falls behind. I learned that lesson the hard way in an erlier post.

So you can't watch everything. You watch a small patch. The app first finds the ball sitting at rest and then keeps its attention on just the little region right around it. That's a huge saving, but it buys you a new problem: to watch that small patch, you have to reliably find the ball first and lock onto it. And locking onto a golf ball is fussier than it sounds.

Problem two: locking on is fussier than it sounds

A golf ball at rest should be the easiest thing in the world to find. White, round, and sitting still. In practice the image is noisy, the light shifts, the ball can have a faint wobble, and frame to frame the picture flickers just enough that a naive "is the ball there? yes. there? no. there? yes" check strobes in and out like a bad lightbulb. If the app loses its lock every few frames, it can't trust that the ball is actually present, and it definitely can't tell the difference between "the ball is gone because you hit it" and "the ball is gone because my detection blinked."

On top of that, you move the ball constantly. On a mat you pull a fresh one over, you nudge it to a cleaner lie, you tee it slightly left. So a lock can't be a one-time thing pinned to one spot on the ground. It has to hold steady through the flicker, let go gracefully when you genuinely reposition, and quietly re-lock onto the ball's new position, all without you telling it anything. Getting that "stable but not stubborn" balance right was a real chunk of the work.

Problem three: catching it leave without jumping at every shadow

Now the app is locked on and watching its little patch. The ball goes. Easy, right? Except all kinds of things disturb that patch that are not the ball departing. The clubhead sweeps through it on the way down. A shadow crosses it. Your foot shifts. The light flickers again. A trigger that fires the instant "something changed near the ball" is a trigger that goes off constantly, for all the wrong reasons.

So the bar isn't "did the region change." It's "did the ball specifically leave its spot." Telling those apart, with confidence, in a handful of milliseconds, is most of the difficulty. (Telling a real, struck-and-flying departure from things like setting the club down or picking the ball up is a whole saga of its own, and it's the entire next post.)

Problem four: the timing knife-edge

Here's the part that ties back to the memory problem. The rolling buffer only holds a short window. So when the app decides the ball has left, it has to freeze the buffer at the right instant. Fire a touch too late and the impact frames have already aged out of the buffer and been thrown away, gone forever. Fire on a false alarm and you freeze a window full of nothing. The trigger has to be sensitive enough to catch the real departure and fast enough to grab it before the evidence rolls off the end. Sensitive and trigger-happy live very close together, and a lot of range time went into finding the seam between them.

Keeping up with you, and the little buzz

The last piece is rhythm. A real range session is pull, set, hit, repeat, and the app has to dissolve into that loop. So the moment it catches a swing, it also has to let go, find the next ball, and re-lock on its own, fast enough that it's ready before you've finished pulling the next one over. If re-arming lagged, or needed a tap, the whole hands-free promise would fall apart.

And because you're looking at the ball and not the screen, it tells you it got the shot with a chime. Hit, "ring", good, next one. That tiny bit of feedback matters way more than it should. It's the difference between trusting the phone and constantly crouching down to check whether it caught that one.

I'm keeping the actual how of all this behind the curtain, like the rest of the good stuff. But the problems are the honest part of the story, and the goal they all serve is simple: set it down, hit balls, hear the "ring", never think about the tech.

Next up: the messy reality of all this. Because it turns out the app didn't just catch my swings. It also "caught" me setting the club down, nudging the ball, and picking it up to go again.

Want to follow along? Pre-register and stick around. See you on the range.

0 comments

Leave a comment

Please note, comments need to be approved before they are published.