Angle update

This commit is contained in:
2026-08-12 12:46:33 +08:00
parent 18fe809d4a
commit e05aca3312
10 changed files with 244 additions and 74 deletions
@@ -145,8 +145,15 @@ class CameraXController(
val analyzer = PoseAnalyzer(
isFrontCamera = { currentLensFacing == CameraSelector.LENS_FACING_FRONT },
onResult = { result ->
latestPoseFrame = result
callback.onPoseResult(result)
// Inference is async (see PoseAnalyzer): a call already
// in flight when setPoseDetectionEnabled(false) runs
// clearAnalyzer() can still land here afterward. Drop
// it, or it redraws a stale skeleton right after the
// live overlay was cleared.
if (poseDetectionEnabled) {
latestPoseFrame = result
callback.onPoseResult(result)
}
},
onError = { e -> callback.onPoseDetectorError(e.message ?: "Pose detector error") }
)
@@ -240,8 +247,11 @@ class CameraXController(
* Attaches/detaches the pose analyzer from the analysis stream, and
* turns skeleton compositing into the recorded video on/off, without
* needing a full unbind/rebind of the camera use cases. Cheap and
* synchronous, so it's safe to call right before [startRecording] to
* pick the mode for that recording (plain video vs. with pose baked in).
* synchronous, so it's safe to call live from a preview-time toggle;
* whatever this is set to when [startRecording] is called becomes that
* recording's pose mode (plain video vs. with pose baked in) and stays
* fixed for its duration -- callers are expected to stop offering the
* toggle while a recording is in progress.
*/
fun setPoseDetectionEnabled(enabled: Boolean) {
poseDetectionEnabled = enabled