// CameraView snippet — the parts of the CameraX setup that the kima app must include
// to consume the rect 4:3 model. Adapt the surrounding code to whatever the kima app's
// camera setup looks like.
//
// Source: posedetection/src/androidMain/kotlin/com/performancecoachlab/posedetection/camera/CameraView.android.kt
// (Lines 286-289 in the R&D project, plus the AspectRatio import)

import androidx.camera.core.AspectRatio   // ← REQUIRED for the new line
import androidx.camera.core.ImageAnalysis

// ... inside whatever Composable / Activity sets up the CameraX use cases ...

val imageAnalysis = ImageAnalysis.Builder()
    .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
    .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
    .setTargetAspectRatio(AspectRatio.RATIO_4_3)   // ← THE CRITICAL ADDITION
    .build()
    .also { analysis ->
        analysis.targetRotation = currentRotation.intValue
        analysis.setAnalyzer(executor) { imageProxy ->
            // ... process imageProxy → bitmap → detector ...
        }
    }

// Notes:
//
// - `setTargetAspectRatio` is a hint, not a hard guarantee. CameraX picks the closest
//   available 4:3 mode for the device — typically 1280×960, 1440×1080, or 2048×1536.
//   Different devices = different exact resolutions but always 4:3 aspect.
//
// - If a device truly cannot deliver 4:3, CameraX falls back to its default. The
//   detector's letterbox math handles aspect mismatches gracefully, so this is at
//   worst a "wastes pixels on padding" case, not a crash.
//
// - The newer CameraX way to do the same thing is `ResolutionSelector.Builder()
//   .setAspectRatioStrategy(AspectRatioStrategy.RATIO_4_3_FALLBACK_AUTO_STRATEGY)
//   .build()`. Either works. Use whichever matches your CameraX version.
//
// - DO NOT use `setTargetResolution(Size(W, H))` — it's deprecated and the device
//   may not honor exact pixel dimensions. The aspect ratio is what matters.
