diff --git a/lib/presentation/recipe_detection/view_model/recipe_detection_view_model.dart b/lib/presentation/recipe_detection/view_model/recipe_detection_view_model.dart index 29be1f8..a6cc019 100644 --- a/lib/presentation/recipe_detection/view_model/recipe_detection_view_model.dart +++ b/lib/presentation/recipe_detection/view_model/recipe_detection_view_model.dart @@ -25,7 +25,6 @@ class RecipeDetectionViewModel extends BaseViewModel { final _utensilUseCase = UtensilUseCase(); final buttonKey = GlobalKey(); - Rxn imageFile = Rxn(); RxnInt imageHeight = RxnInt(); RxnInt imageWidth = RxnInt(); @@ -87,11 +86,9 @@ class RecipeDetectionViewModel extends BaseViewModel { opacityShadow: 0.5, imageFilter: ImageFilter.blur(sigmaX: 8, sigmaY: 8), onFinish: () { - print("finish"); Session.set(SessionConstants.isAlreadyOnBoardingDetectIngredient, "yes"); }, - onClickTarget: (target) { - }, + onClickTarget: (target) {}, onClickTargetWithTapPosition: (target, tapDetails) {}, onClickOverlay: (target) {}, onSkip: () { @@ -202,7 +199,6 @@ class RecipeDetectionViewModel extends BaseViewModel { if (data != null) { imageFile.value = data; - // _startTimer(); _resetBounding(); _detectIngredients(); } @@ -225,36 +221,6 @@ class RecipeDetectionViewModel extends BaseViewModel { closeLoadingDialog(); updatePostProcess(); - - - // final result = await _vision.yoloOnImage( - // bytesList: byte, - // imageHeight: image.height, - // imageWidth: image.width, - // iouThreshold: 0.2, - // confThreshold: 0.2, - // classThreshold: 0.2, - // ); - - // print("DATA IS ${result.length}"); - // if (result.isNotEmpty) { - // } else { - // _timer?.cancel(); - // _stopwatch.stop(); - // _stopwatch.reset(); - // closeLoadingDialog(); - // showGeneralDialog(context: Get.context!, pageBuilder: (context, anim1, anim2) { - // return AlertDialog( - // title: const Text("Tidak ada bahan yang terdeteksi"), - // content: const Text("Silahkan coba lagi"), - // actions: [ - // TextButton(onPressed: () { - // Get.back(); - // }, child: const Text("OK")) - // ], - // ); - // }); - // } } @@ -275,10 +241,6 @@ class RecipeDetectionViewModel extends BaseViewModel { return ingredients.map((ingredient) => translateIngredient(ingredient, translationDict)).toList(); } - // List translateIngredients(List originalList) { - // return originalList.map((Ingredient item) => item.name?.replaceAll('carrot', 'wortel')).toList(); - // } - void incrementIngredientQuantity(int index) { detectedIngredients[index].quantity = (detectedIngredients[index].quantity ?? 0) + 1; @@ -295,43 +257,8 @@ class RecipeDetectionViewModel extends BaseViewModel { void removeIngredient(int index) { detectedIngredients.removeAt(index); detectedIngredients.refresh(); - - } - // Future drawOnImage(List> modelResults) async { - // final image = imageFile.value; - // if (image == null) { - // return Uint8List(0); - // } - // - // final imgBytes = image.readAsBytesSync(); - // final img = await decodeImageFromList(Uint8List.fromList(imgBytes)); - // - // final recorder = PictureRecorder(); - // final canvas = Canvas(recorder); - // canvas.drawImage(img, Offset.zero, Paint()); - // List detectedObject = - // drawBoxesOnCanvasAndReturnDetectedIngredient( - // canvas: canvas, - // screen: Size(img.width.toDouble(), img.height.toDouble()), - // modelResults: modelResults, - // imageHeight: imageHeight.value, - // imageWidth: imageWidth.value, - // ); - // - // detectedIngredients.value = translateIngredients(detectedObject, translationDict); - // - // // detectedIngredients.value = detectedObject; - // - // final picture = recorder.endRecording(); - // final imgWithBoxes = await picture.toImage(img.width, img.height); - // final ByteData? byteData = - // await imgWithBoxes.toByteData(format: ImageByteFormat.png); - // - // return byteData!.buffer.asUint8List(); - // } - void _showDraggableBottomSheet() { isShowDetectionResult.value = true; if (!draggableScrollableController.isAttached) return; diff --git a/lib/utils/detection/isolate_inference.dart b/lib/utils/detection/isolate_inference.dart index c8c3158..0bcd39f 100644 --- a/lib/utils/detection/isolate_inference.dart +++ b/lib/utils/detection/isolate_inference.dart @@ -95,6 +95,7 @@ class IsolateInference { if (xRight < xLeft || yBottom < yTop) { return 0; } + double intersectionArea = (xRight - xLeft) * (yBottom - yTop); double bbox1Area = (bbox1[2] - bbox1[0]) * (bbox1[3] - bbox1[1]); double bbox2Area = (bbox2[2] - bbox2[0]) * (bbox2[3] - bbox2[1]);