优化
This commit is contained in:
@@ -59,6 +59,7 @@ import com.sw.plate.utils.arcface.face.model.CompareResult
|
||||
import com.sw.plate.utils.arcface.face.model.FacePreviewInfo
|
||||
import com.sw.plate.utils.arcface.face.model.RecognizeConfiguration
|
||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel.REGISTER_STATUS_READY
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
@@ -109,7 +110,7 @@ class MainScreenPresentation(
|
||||
private var lastFaceTrackId: Int = -1 // 上一次的人脸信息
|
||||
var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
|
||||
|
||||
// var isKeepFaceState = true
|
||||
// var isKeepFaceState = true
|
||||
var isKeepFaceState = false
|
||||
|
||||
var currentUserId: String? = null
|
||||
@@ -162,7 +163,12 @@ class MainScreenPresentation(
|
||||
isGoStep1 = false
|
||||
activity.runOnUiThread {
|
||||
Timber.tag(TAG).e("切回step1")
|
||||
step1FoodRecognizing()
|
||||
if (mealPickupMode == 0) {
|
||||
//即放即取
|
||||
step1FoodRecognizing()
|
||||
} else {
|
||||
//秤上菜品不足,请补充
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,6 +401,7 @@ class MainScreenPresentation(
|
||||
|
||||
private var isLoadUnbilledMode = false
|
||||
private val df by lazy { DecimalFormat("#.##") }
|
||||
|
||||
/**
|
||||
* 餐品识别成功,不计费模式
|
||||
*/
|
||||
@@ -402,6 +409,20 @@ class MainScreenPresentation(
|
||||
if (currentUserId.isNullOrBlank()) {
|
||||
return
|
||||
}
|
||||
//todo 清除人脸数据
|
||||
// binding.dualCameraFaceRectView.clearFaceInfo()
|
||||
// clearLeftFaceData()
|
||||
// facePreviewInfoList?.clear()
|
||||
// recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY)
|
||||
|
||||
// pauseCamera()
|
||||
|
||||
// resumeCamera()
|
||||
|
||||
// TODO: 如何清除人脸数据重新识别
|
||||
// stopCamera()
|
||||
// setupArcCamera()
|
||||
|
||||
isLoadUnbilledMode = true
|
||||
Timber.tag(TAG).d("loadUnbilledMode")
|
||||
binding.calorieInclude.root.gone()
|
||||
@@ -419,7 +440,8 @@ class MainScreenPresentation(
|
||||
binding.nutritionInclude.tvUserName.text = userNutrition?.name.maskName()
|
||||
val recommendCalorie = userNutrition?.recommendCalorie ?: 0.0
|
||||
|
||||
binding.nutritionInclude.tvRecommendHeat.text = "推荐热量:${df.format(recommendCalorie)}kcal"
|
||||
binding.nutritionInclude.tvRecommendHeat.text =
|
||||
"推荐热量:${df.format(recommendCalorie)}kcal"
|
||||
// binding.nutritionInclude.tvRecommendHeat.text = "推荐热量:${recommendCalorie.removeTrailingZeros()}kcal"
|
||||
//updateWeight(lastWeight / 1000)
|
||||
// -------------------------------------------------
|
||||
@@ -428,6 +450,9 @@ class MainScreenPresentation(
|
||||
binding.root.postDelayed({
|
||||
isLoadUnbilledMode = false
|
||||
}, 10000)
|
||||
|
||||
//上次已经识别过人脸
|
||||
step3ShowRecognizeResult(currentUserId!!)
|
||||
}
|
||||
|
||||
private var isFirstOpen = true
|
||||
@@ -643,7 +668,7 @@ class MainScreenPresentation(
|
||||
?: 0.0)) / 2,
|
||||
userNutrition?.maxCalorie ?: 0.0,
|
||||
)
|
||||
val calorieIndex = UserNutritionUtils.findCalorieIndex(energy.grain, calorieArray)
|
||||
val calorieIndex = UserNutritionUtils.findCalorieIndex(energy.calorie, calorieArray)
|
||||
include.customKcalColumn.setImageDrawable(true, calorieIndex)
|
||||
var maxKcal = userNutrition?.maxCalorie ?: 1.0
|
||||
Timber.tag(TAG).d("maxKcal = $maxKcal")
|
||||
@@ -737,12 +762,16 @@ class MainScreenPresentation(
|
||||
step1FoodRecognizing()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
fun stopCamera() {
|
||||
rgbCameraHelper?.release()
|
||||
rgbCameraHelper = null
|
||||
irCameraHelper?.release()
|
||||
irCameraHelper = null
|
||||
recognizeViewModel.destroy()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
stopCamera()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
@@ -760,6 +789,7 @@ class MainScreenPresentation(
|
||||
|
||||
recognizeViewModel.onPreviewFrame(ByteArray(1382400), true)
|
||||
}
|
||||
|
||||
private var recognizeTime = 0L
|
||||
private fun initArcViewModel() {
|
||||
recognizeViewModel.setLiveType(livenessType)
|
||||
@@ -1159,11 +1189,13 @@ class MainScreenPresentation(
|
||||
return
|
||||
}
|
||||
createOrder(notEnoughOneBlock = {
|
||||
if (mealPickupMode == 0) {
|
||||
currentStep = 2
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
}
|
||||
}){
|
||||
// if (mealPickupMode == 0) {
|
||||
currentStep = 2
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
// }
|
||||
}) {
|
||||
// TODO: 测试人脸识别问题--------------------
|
||||
//recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY)
|
||||
if (MyApp.DEBUG) {
|
||||
ToastUtils.showToast("订单已生成")
|
||||
}
|
||||
@@ -1182,7 +1214,7 @@ class MainScreenPresentation(
|
||||
}
|
||||
}
|
||||
|
||||
fun createOrder(notEnoughOneBlock: ()-> Unit={}, block: ()-> Unit) {
|
||||
fun createOrder(notEnoughOneBlock: () -> Unit = {}, block: () -> Unit) {
|
||||
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||
val eatWeight = if (mealPickupMode == 0) {
|
||||
//即放即取
|
||||
@@ -1214,7 +1246,7 @@ class MainScreenPresentation(
|
||||
)
|
||||
}
|
||||
|
||||
private fun clearLeftFaceData() {
|
||||
public fun clearLeftFaceData() {
|
||||
facePreviewInfoList?.let {
|
||||
recognizeViewModel.clearLeftFace(facePreviewInfoList!!)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user