upload project

This commit is contained in:
ibnubatutah 2024-06-26 11:48:19 +07:00
parent e81d566892
commit e8b12c5610
2 changed files with 2 additions and 74 deletions

View File

@ -25,7 +25,6 @@ class RecipeDetectionViewModel extends BaseViewModel {
final _utensilUseCase = UtensilUseCase();
final buttonKey = GlobalKey();
Rxn<File> imageFile = Rxn<File>();
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<String> translateIngredients(List<Ingredient> 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<Uint8List> drawOnImage(List<Map<String, dynamic>> 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<Ingredient> 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;

View File

@ -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]);