Skip to content

Unable to Detect Poses on Recorded Video using InputImage.fromBytes() #628

Closed as not planned
@HasithMbiz

Description

@HasithMbiz

Poses are drawing on the live camera feed without an issue. But I want to draw poses on a recorded video. I can take snapshots of the video frames as bytes (Uint8List). Then what should I pass as InputImageMetadata. I tried pass default values similar to what is applied from the CameraImage to the InputImage during live camera in my device. Like below,

final inputImage = InputImage.fromBytes(
      bytes: imageBytes,
      metadata: InputImageMetadata(
        size: const Size(1280, 720),
        rotation: InputImageRotation.rotation270deg,
        format: InputImageFormat.nv21,
        bytesPerRow: 1280,
      ),
    );

But then I encounter the following error when process the image.

final poses = await _poseDetector.processImage(inputImage);

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Image dimension, ByteBuffer size and format don't match. Please check if the ByteBuffer is in the decalred format., null, java.lang.IllegalArgumentException: Image dimension, ByteBuffer size and format don't match. Please check if the ByteBuffer is in the decalred format.
at com.google.android.gms.common.internal.Preconditions.checkArgument(com.google.android.gms:play-services-basement@@18.3.0:2)
at com.google.mlkit.vision.common.InputImage.(com.google.mlkit:vision-common@@17.3.0:10)
at com.google.mlkit.vision.common.InputImage.fromByteArray(com.google.mlkit:vision-common@@17.3.0:2)
at com.google_mlkit_commons.InputImageConverter.getInputImageFromData(InputImageConverter.java:36)
at com.google_mlkit_pose_detection.PoseDetector.handleDetection(PoseDetector.java:52)
at com.google_mlkit_pose_detection.PoseDetector.onMethodCall(PoseDetector.java:38)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7355)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:914)
)

How can I use Uint8List to detect the poses. I did get the poses by using the InputImage.fromFile intead of InputImage.fromBytes. but saving Uint8List into a file take more time and not efficient. Can anyone suggest a solution for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions