修改菜品识别逻辑
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()
|
||||
|
||||
@@ -180,6 +180,8 @@ class SecondaryScreenPresentation(
|
||||
pauseCamera()
|
||||
binding.tvBottomTip.visibility = View.VISIBLE
|
||||
itemUserNutritionBinding.clNutritionData.visibility = View.GONE
|
||||
|
||||
activity.clearFoodList()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +191,7 @@ class SecondaryScreenPresentation(
|
||||
Timber.d("step2")
|
||||
currentStep = 2
|
||||
LightManager.closeRedLight()
|
||||
LightManager.openGreenLight()
|
||||
// LightManager.openGreenLight()
|
||||
dinnerTypeInfo = null
|
||||
userNutritionData = null
|
||||
recognitionWeight = 0.0
|
||||
@@ -759,7 +761,7 @@ class SecondaryScreenPresentation(
|
||||
* @param facePreviewInfoList RGB画面的实时人脸信息
|
||||
*/
|
||||
private fun drawPreviewInfo(facePreviewInfoList: MutableList<FacePreviewInfo?>) {
|
||||
Timber.d("drawPreviewInfo facePreviewInfoList = ${facePreviewInfoList.size}, rgbFaceRectTransformer = ${rgbFaceRectTransformer != null}")
|
||||
// Timber.d("drawPreviewInfo facePreviewInfoList = ${facePreviewInfoList.size}, rgbFaceRectTransformer = ${rgbFaceRectTransformer != null}")
|
||||
if (rgbFaceRectTransformer != null) {
|
||||
val rgbDrawInfoList: MutableList<DrawInfo?>? = recognizeViewModel.getDrawInfo(
|
||||
facePreviewInfoList,
|
||||
|
||||
@@ -77,7 +77,7 @@ public class FaceRectTransformer {
|
||||
rect.bottom *= verticalRatio;
|
||||
|
||||
Rect newRect = new Rect();
|
||||
L.e("cameraDisplayOrientation " + cameraDisplayOrientation + " === " + cameraId);
|
||||
// L.e("cameraDisplayOrientation " + cameraDisplayOrientation + " === " + cameraId);
|
||||
switch (cameraDisplayOrientation) {
|
||||
case 0:
|
||||
if (cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||
|
||||
Reference in New Issue
Block a user