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
@@ -32,6 +32,21 @@ class CameraViewModel : ViewModel() {
private val _recordingState = MutableStateFlow<RecordingState>(RecordingState.Idle)
val recordingState: StateFlow<RecordingState> = _recordingState.asStateFlow()
// Whether live pose detection/overlay is on. Only meant to change while
// recordingState is Idle -- the UI disables the toggle otherwise (see
// BowlingCameraActivity#renderRecordingState) since the recording
// pipeline picks its pose mode once at start.
private val _poseEnabled = MutableStateFlow(false)
val poseEnabled: StateFlow<Boolean> = _poseEnabled.asStateFlow()
// Latest per-frame joint angles, for the overlay's angle-label text now
// and for frame-by-frame swing analysis/logging later. Null whenever
// there's no current pose result to derive them from (pose off, no
// frame processed yet, or a frame with no landmarks that met the
// confidence bar -- see PoseAngleCalculator).
private val _poseAngles = MutableStateFlow<PoseAngles?>(null)
val poseAngles: StateFlow<PoseAngles?> = _poseAngles.asStateFlow()
private val _permissionsGranted = MutableStateFlow(false)
val permissionsGranted: StateFlow<Boolean> = _permissionsGranted.asStateFlow()
@@ -47,6 +62,15 @@ class CameraViewModel : ViewModel() {
_permissionsGranted.value = granted
}
fun onPoseToggled(enabled: Boolean) {
_poseEnabled.value = enabled
if (!enabled) _poseAngles.value = null
}
fun onPoseAnglesUpdated(angles: PoseAngles) {
_poseAngles.value = angles
}
fun onRecordingStarting() {
_recordingState.value = RecordingState.Starting
}