cameo is a privacy-first, on-device Android application that analyzes portrait videos, identifies all unique faces across time, selects the sharpest representative shot for each person, and compiles them into a high-resolution, shareable collage.
- Extracts video frames using
MediaMetadataRetrieversampled at 160 ms intervals. - Automatically handles orientation adjustments based on video metadata rotation flags.
- Utilizes Google ML Kit's Face Detection API in Accurate Mode.
- Calculates multi-dimensional quality metrics for every face detected:
- Frontality Score: Evaluated from 3D head euler angles (yaw, pitch, roll).
- Eye Openness Score: Combined probability of left and right eyes open.
- Smile Score: Smiling probability multiplier.
- Sharpness Score: Laplacian variance computed across the facial crop region.
- Edge Integrity: Penalizes faces clipped near frame borders.
- Tracks faces across consecutive frames using spatial Intersection over Union (IoU) bounding box tracking.
- Groups individual face detections into continuous appearance segments.
- Crops portrait face regions with margins and resizes to
$112 \times 112$ pixels. - Normalizes pixel channels to
$[-1.0, 1.0]$ . - Runs inference through MobileFaceNet (
mobilefacenet.tflite) on TensorFlow Lite to produce a 192-dimensional vector. - Applies
$L_2$ vector normalization to standardize feature magnitudes.
- Computes mean embedding vectors for each appearance track.
- Performs centroid-linkage hierarchical clustering using Cosine Distance:
$$d(\mathbf{u}, \mathbf{v}) = 1 - \frac{\mathbf{u} \cdot \mathbf{v}}{|\mathbf{u}|_2 |\mathbf{v}|_2}$$ - Co-Occurrence Guard: Enforces strict frame co-occurrence and temporal overlap checks (minimum 80 ms window) to prevent distinct people present in the same segment from being merged.
-
Calibrated Threshold: Merges tracks with cosine distance
$\le 0.38\text{f}$ .
- Evaluates all frames within a person's identity cluster.
- Selects the frame maximizing the weighted quality formula:
$$\text{Score} = \text{Frontality} \times 0.35 + \text{EyesOpen} \times 0.30 + \text{Sharpness} \times 0.20 + \text{Smile} \times 0.10 + \text{BorderIntegrity} \times 0.05$$ - Generates a padded portrait crop optimized for collage placement.
- Dynamically arranges individual identity portraits into multiple selectable layout styles (Editorial Grid, Film Strip, Polaroid, and Full Bleed).
- Saves collages directly to device storage under
Pictures/cameo Collages/via AndroidMediaStore. - Integrates native Android share sheet via
FileProvider.
Cosine distance measures vector orientation rather than magnitude, making it invariant to lighting changes and exposure differences. Combined with
The threshold of 0.38 (corresponding to cosine similarity
- Android Studio Jellyfish (2023.3.1) or newer
- JDK 17+
- Android SDK 34
# Clone the repository
git clone https://github.com/cameo/cameo.git
cd cameo
# Build the Debug APK
./gradlew assembleDebugUpon a successful build, the compiled APK is located at:
app/build/outputs/apk/debug/app-debug.apk
Distributed under the Apache 2.0 License.