添加了模拟识别菜品功能

This commit is contained in:
zxj
2025-08-13 11:29:08 +08:00
parent e93550a24b
commit f055441340
5 changed files with 63 additions and 39 deletions
@@ -80,7 +80,7 @@ class SecondaryScreenPresentation(
private var recognitionTime: Long = 0L // 人脸识别时的时间
private var recognitionWeight: Double = 0.0 // 人脸识别时的重量
private var lastFaceTrackId: Int = -1 // 上一次的人脸信息
private var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
var mealPickupMode: Int = 0 // 取餐模式 0 即放即取 1 余量取餐
// 当前步骤
var currentStep: Int = 0
@@ -220,13 +220,7 @@ class SecondaryScreenPresentation(
if (currentStep == 1) {
step2(foodInfo)
} else {
binding.tvFoodName.text = foodInfo.foodName
GlideUtils.loadRoundCornerImage(
context,
url = currentFood!!.imgUrl,
imageView = binding.ivImg,
radius = 12
)
updateFoodInfo(foodInfo)
}
}
}
@@ -243,13 +237,7 @@ class SecondaryScreenPresentation(
ToastUtils.showToast("选中物品为空3")
return
}
binding.tvFoodName.text = currentFood!!.foodName
GlideUtils.loadRoundCornerImage(
context,
url = currentFood!!.imgUrl,
imageView = binding.ivImg,
radius = 12
)
updateFoodInfo(currentFood!!)
binding.flPreview.visibility = View.VISIBLE
binding.ivImg.visibility = View.VISIBLE
binding.flFace.visibility = View.INVISIBLE
@@ -260,6 +248,25 @@ class SecondaryScreenPresentation(
itemUserNutritionBinding.clNutritionData.visibility = View.VISIBLE
}
private fun updateFoodInfo(foodInfo: FoodInfo) {
binding.tvFoodName.text = foodInfo.foodName
if (foodInfo.photoUri != null) {
GlideUtils.loadRoundCornerImage(
context,
url = foodInfo.photoUri,
imageView = binding.ivImg,
radius = 12
)
} else {
GlideUtils.loadRoundCornerImage(
context,
url = foodInfo.imgUrl,
imageView = binding.ivImg,
radius = 12
)
}
}
fun updateWeight(weight: Double) {
lastWeight = weight * 1000 // 将千克转成克
Timber.d("updateWeight lastWeight = $weight")
@@ -769,7 +776,7 @@ class SecondaryScreenPresentation(
postUserData()
if (mealPickupMode == 0) {
step1()
}else{
} else {
step2(currentFood!!)
}
}