This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1// CameraView snippet — the parts of the CameraX setup that the kima app must include 2// to consume the rect 4:3 model. Adapt the surrounding code to whatever the kima app's 3// camera setup looks like. 4// 5// Source: posedetection/src/androidMain/kotlin/com/performancecoachlab/posedetection/camera/CameraView.android.kt 6// (Lines 286-289 in the R&D project, plus the AspectRatio import) 7 8import androidx.camera.core.AspectRatio // ← REQUIRED for the new line 9import androidx.camera.core.ImageAnalysis 10 11// ... inside whatever Composable / Activity sets up the CameraX use cases ... 12 13val imageAnalysis = ImageAnalysis.Builder() 14 .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) 15 .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888) 16 .setTargetAspectRatio(AspectRatio.RATIO_4_3) // ← THE CRITICAL ADDITION 17 .build() 18 .also { analysis -> 19 analysis.targetRotation = currentRotation.intValue 20 analysis.setAnalyzer(executor) { imageProxy -> 21 // ... process imageProxy → bitmap → detector ... 22 } 23 } 24 25// Notes: 26// 27// - `setTargetAspectRatio` is a hint, not a hard guarantee. CameraX picks the closest 28// available 4:3 mode for the device — typically 1280×960, 1440×1080, or 2048×1536. 29// Different devices = different exact resolutions but always 4:3 aspect. 30// 31// - If a device truly cannot deliver 4:3, CameraX falls back to its default. The 32// detector's letterbox math handles aspect mismatches gracefully, so this is at 33// worst a "wastes pixels on padding" case, not a crash. 34// 35// - The newer CameraX way to do the same thing is `ResolutionSelector.Builder() 36// .setAspectRatioStrategy(AspectRatioStrategy.RATIO_4_3_FALLBACK_AUTO_STRATEGY) 37// .build()`. Either works. Use whichever matches your CameraX version. 38// 39// - DO NOT use `setTargetResolution(Size(W, H))` — it's deprecated and the device 40// may not honor exact pixel dimensions. The aspect ratio is what matters.