修改菜品识别逻辑
This commit is contained in:
@@ -70,6 +70,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
private var lastWeight: Double = 0.0
|
||||
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
||||
private var debouncer = Debouncer(2000)
|
||||
private var isRecognitionFood = true
|
||||
|
||||
override fun getViewModel(): BaseViewModel {
|
||||
return viewModel
|
||||
@@ -128,6 +129,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
isRecognitionFood = true
|
||||
presentation?.updateMealPickupMode(position)
|
||||
}
|
||||
|
||||
@@ -189,6 +191,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
checkedItem!!.photoUri = lastPhotoUri
|
||||
updateCurrentFood(checkedItem)
|
||||
lastPhotoUri = null
|
||||
LightManager.closeRedLight()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +210,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
Timber.d("registerDataChange weight = $weight")
|
||||
presentation?.updateWeight(weight)
|
||||
|
||||
if (weight - lastWeight > 0.1 && presentation?.mealPickupMode == 0) { // 大于100g
|
||||
// if (weight <= 0.005) {//检测到秤上没有东西,重新启动识别菜品
|
||||
// isRecognitionFood = true
|
||||
// }
|
||||
if (weight - lastWeight > 0.05 && isRecognitionFood) { // 大于50g
|
||||
if (presentation?.mealPickupMode == 1) {
|
||||
isRecognitionFood = false
|
||||
}
|
||||
debouncer.debounce {
|
||||
LightManager.openRedLight()
|
||||
LightManager.openGreenLight()
|
||||
@@ -435,6 +444,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
fun clearFoodList() {
|
||||
adapter.updateData(listOf())
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
SensorScaleUtils.closeScale()
|
||||
presentation?.dismiss()
|
||||
|
||||
Reference in New Issue
Block a user