修改菜品识别逻辑
This commit is contained in:
@@ -70,6 +70,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
private var lastWeight: Double = 0.0
|
private var lastWeight: Double = 0.0
|
||||||
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
private var lastPhotoUri: Uri? = null // 最后拍照的图片
|
||||||
private var debouncer = Debouncer(2000)
|
private var debouncer = Debouncer(2000)
|
||||||
|
private var isRecognitionFood = true
|
||||||
|
|
||||||
override fun getViewModel(): BaseViewModel {
|
override fun getViewModel(): BaseViewModel {
|
||||||
return viewModel
|
return viewModel
|
||||||
@@ -128,6 +129,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
position: Int,
|
position: Int,
|
||||||
id: Long
|
id: Long
|
||||||
) {
|
) {
|
||||||
|
isRecognitionFood = true
|
||||||
presentation?.updateMealPickupMode(position)
|
presentation?.updateMealPickupMode(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +191,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
checkedItem!!.photoUri = lastPhotoUri
|
checkedItem!!.photoUri = lastPhotoUri
|
||||||
updateCurrentFood(checkedItem)
|
updateCurrentFood(checkedItem)
|
||||||
lastPhotoUri = null
|
lastPhotoUri = null
|
||||||
|
LightManager.closeRedLight()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +210,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
Timber.d("registerDataChange weight = $weight")
|
Timber.d("registerDataChange weight = $weight")
|
||||||
presentation?.updateWeight(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 {
|
debouncer.debounce {
|
||||||
LightManager.openRedLight()
|
LightManager.openRedLight()
|
||||||
LightManager.openGreenLight()
|
LightManager.openGreenLight()
|
||||||
@@ -435,6 +444,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearFoodList() {
|
||||||
|
adapter.updateData(listOf())
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
SensorScaleUtils.closeScale()
|
SensorScaleUtils.closeScale()
|
||||||
presentation?.dismiss()
|
presentation?.dismiss()
|
||||||
|
|||||||
@@ -180,6 +180,8 @@ class SecondaryScreenPresentation(
|
|||||||
pauseCamera()
|
pauseCamera()
|
||||||
binding.tvBottomTip.visibility = View.VISIBLE
|
binding.tvBottomTip.visibility = View.VISIBLE
|
||||||
itemUserNutritionBinding.clNutritionData.visibility = View.GONE
|
itemUserNutritionBinding.clNutritionData.visibility = View.GONE
|
||||||
|
|
||||||
|
activity.clearFoodList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,7 +191,7 @@ class SecondaryScreenPresentation(
|
|||||||
Timber.d("step2")
|
Timber.d("step2")
|
||||||
currentStep = 2
|
currentStep = 2
|
||||||
LightManager.closeRedLight()
|
LightManager.closeRedLight()
|
||||||
LightManager.openGreenLight()
|
// LightManager.openGreenLight()
|
||||||
dinnerTypeInfo = null
|
dinnerTypeInfo = null
|
||||||
userNutritionData = null
|
userNutritionData = null
|
||||||
recognitionWeight = 0.0
|
recognitionWeight = 0.0
|
||||||
@@ -759,7 +761,7 @@ class SecondaryScreenPresentation(
|
|||||||
* @param facePreviewInfoList RGB画面的实时人脸信息
|
* @param facePreviewInfoList RGB画面的实时人脸信息
|
||||||
*/
|
*/
|
||||||
private fun drawPreviewInfo(facePreviewInfoList: MutableList<FacePreviewInfo?>) {
|
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) {
|
if (rgbFaceRectTransformer != null) {
|
||||||
val rgbDrawInfoList: MutableList<DrawInfo?>? = recognizeViewModel.getDrawInfo(
|
val rgbDrawInfoList: MutableList<DrawInfo?>? = recognizeViewModel.getDrawInfo(
|
||||||
facePreviewInfoList,
|
facePreviewInfoList,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class FaceRectTransformer {
|
|||||||
rect.bottom *= verticalRatio;
|
rect.bottom *= verticalRatio;
|
||||||
|
|
||||||
Rect newRect = new Rect();
|
Rect newRect = new Rect();
|
||||||
L.e("cameraDisplayOrientation " + cameraDisplayOrientation + " === " + cameraId);
|
// L.e("cameraDisplayOrientation " + cameraDisplayOrientation + " === " + cameraId);
|
||||||
switch (cameraDisplayOrientation) {
|
switch (cameraDisplayOrientation) {
|
||||||
case 0:
|
case 0:
|
||||||
if (cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
if (cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user