package com.example.livingai.domain.ml

import android.graphics.Bitmap
import android.graphics.Rect

/**
 * Interface for all distance estimators.
 */
interface DistanceEstimator {
    fun analyze(
        frame: FrameData,
        cameraInfo: CameraInfoData
    ): DistanceState
}

// FrameData is defined in FrameData.kt

/**
 * Singleton-provided camera intrinsics for metric calculations.
 */
data class CameraInfoData(
    val focalLengthPixels: Float,        // fx in pixels
    val sensorWidthPx: Int,
    val sensorHeightPx: Int,
    val principalPointX: Float,
    val principalPointY: Float,
    val distortionCoeffs: FloatArray? = null,
    val cameraModel: String? = null
)

/**
 * Output state describing computed distance and capture readiness.
 */
data class DistanceState(
    val distanceMeters: Float?,
    val recommendation: DistanceRecommendation,

    val isCameraTilted: Boolean,
    val isCameraRotated: Boolean,
    val isOrientationCorrect: Boolean,
    val isObjectCentered: Boolean,

    val readyToCapture: Boolean,
    val confidenceScore: Float = 0f
)

enum class DistanceRecommendation {
    MOVE_CLOSER,
    MOVE_AWAY,
    AT_OPTIMAL_DISTANCE,
    DISTANCE_UNKNOWN
}
