Image dimension, ByteBuffer size and format don't match. Please check if the ByteBuffer is in the declared format

80 Views Asked by At

Trying to detect poses with Google ML Kit, but when it comes to detecting poses I get this error, in the last line:

java.lang.IllegalArgumentException: Image dimension, ByteBuffer size and format don't match. Please check if the ByteBuffer is in the decalred format.

Pose detector:

final poseDetector = PoseDetector(
    options: PoseDetectorOptions(
      mode: PoseDetectionMode.single, 
      model: PoseDetectionModel.accurate,
    )
  );

Detect pose function:

void detePose(XFile file) async {
final myFile = File(file.path);
final Uint8List imageBytes = await myFile.readAsBytes();
final dimensions = await getImageDimensions(imageBytes);

int bytesperrow = dimensions['width'] * 4;
int width = dimensions['width'];
int height = dimensions['height'];
var format = dimensions['format'];

// print(format);

final inputImage = InputImage.fromBytes(
  bytes: imageBytes,
  metadata: InputImageMetadata(
    size: Size(
      width.toDouble(),
      height.toDouble()
    ),
    format: InputImageFormat.bgra8888,
    rotation: InputImageRotation.rotation0deg,
    bytesPerRow: bytesperrow
  )
);

final List<Pose> poses = await poseDetector.processImage(inputImage);

}

0

There are 0 best solutions below