r/reactnative • • 3d ago

Article I built on-device face alignment with Expo + ML Kit for a timelapse app

I just shipped Becoming, an Expo app (SDK 57, React Native 0.86) that turns photos taken weeks apart into one steady timelapse. Everything runs on the phone: no server of mine, no account. A few things I learned building it:

**Faces.** ML Kit face detection gives the eyes, nose and mouth. I fit a similarity transform (scale, rotation, shift) from those points onto one fixed position, so every photo sits where the first one did. A photo that can't be aligned is reported, never passed through untouched: one unaligned frame is a visible jump, the exact thing the app exists to remove.

**Bodies.** For gym progress there's a small native module around ML Kit pose detection, anchored on the torso only: shoulders and hips. Arms move between photos (a hand on the hip one week, by your side the next) and would drag the whole frame sideways.

**Things with no landmarks.** Plants, rooms, a build: no detector finds anything there, so the camera shows yesterday's photo faded over the viewfinder and you line it up by eye.

**Flicker.** Every phone photo is exposed on its own, so at 10 frames a second the brightness strobes. Each frame gets a gain toward the run's median brightness, clamped, so one blown-out photo can't drag the whole video darker.

**Export.** Frames are drawn with React Native Skia (the looks are SkSL shaders) and encoded on the phone with react-native-skia-video. The memory lesson: Hermes counts every image Skia holds at its decoded size, so long exports hit the heap limit. Rendered frames now go to files instead of staying in memory.

The iPhone build is next, same codebase. Happy to go deeper on any of it.

Beard photos: Chris Radcliff (Flickr), CC BY-SA 2.0. I'm the developer.

9 Upvotes

7 comments sorted by

2

u/Mule_ME 3d ago

For anyone who wants to try it: it's called Becoming, Android for now, iPhone next.

https://play.google.com/store/apps/details?id=pics.becoming

2

u/Fresh-Ant-4299 3d ago

The torso-only anchor is a really nice detail, I wouldn't have thought about arms dragging the frame. And reporting unaligned photos instead of passing them through is the right call.

Since everything stays on the phone with no account, how do you handle backups or moving to a new phone? That's the part I keep thinking about with local-only apps.

1

u/Mule_ME 2d ago

Export a project as one file, or pick a folder the app keeps up to date. Copy it to the new phone, restore, and every edit comes back. Android's cloud backup is off on purpose, so would a monthly "export your project" reminder help, or just annoy you?

2

u/ZMech 2d ago

Flicking between a straight on and offset photo feels jarring. I thought that was going to be a without the app example. This would give better results if it also kept you facing straight on or the same direction each time.

1

u/Mule_ME 2d ago

Fair point. Those are real photos taken without the app, and lining up can move a face into place but can't turn a head back. When you shoot in the app, yesterday's photo fades over the viewfinder so you match the angle. Would you rather turned photos get dropped automatically, or flagged so you decide?

2

u/ZMech 2d ago

The faded face for alignment sounds great, a way better result than what you're currently demoing

1

u/Mule_ME 2d ago

Agreed. The demo is an old public beard series (Chris Radcliff, CC BY-SA), shot long before the app existed, so the next demo will be photos taken in the app with the fade on.