-
Notifications
You must be signed in to change notification settings - Fork 197
Description
Hi everyone,
----------------CONTEXT----------------
Here is the context:
I would like to perform a pose estimation in Flutter using the tflite_flutter library (and pose_landmarks_detector.tflite model). To do this, I have loaded these libraries:
dependencies:
flutter:
sdk: flutter
image_picker: ^1.1.2
image: ^4.5.2
path_provider: ^2.0.15
provider: ^6.1.2
path: ^1.9.0
permission_handler: ^12.0.1
video_thumbnail: ^0.5.6
cupertino_icons: ^1.0.8
shared_preferences: ^2.2.4
camera: ^0.11.2
http: ^1.1.0
video_player: ^2.10.0
tflite_flutter: ^0.11.0
----------------WHERE I'M STUCK----------------
I'm stuck on the following point: I have a _runPose method that needs to be able to process a CameraImage image, pass the image through the tflite model, and generate the landmarks (33 points).
Future<void> _runPose(CameraImage image, Interpreter landmarker) async {
final cameraImageAsImage = ImageUtils.convertCameraImageToImage(image)!;
// Convert to Float32 and normalize
final imageMatrixFloat = List.generate(
cameraImageAsImage.height,
(y) => List.generate(cameraImageAsImage.width, (x) {
final pixel = cameraImageAsImage.getPixel(x, y);
return [pixel.r / 255.0, pixel.g / 255.0, pixel.b / 255.0];
}),
);
final output = {0: List.generate(1, (_) => List.filled(195, 0.0))};
landmarker.runForMultipleInputs([imageMatrixFloat], output);
If I print the imageMatrixFloat, landmarker.getInputTensor(0) and landmarker.getOutputTensor(0) I have smth like this



----------------ISSUE----------------
My issue is the following:
When I enter into runForMultipleInputs I have an error like
Exception has occurred. StateError (Bad state: failed precondition)
----------------CONCLUSION----------------
I hope that I put all the needed information. Iguess that the input or output (or both) I give to the method is not the good one but I'm a little bit lost with all of this and I have many conflicts if I want to use tflite_flutter_helper and so on... If someone has any advice it would be perfect :D
Thanks a lot!