googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.6k stars 2.94k forks source link

unable to detect face using google_mlkit_face_detection: ^0.11.0 #855

Closed Jayakumar-AndroidDev closed 3 months ago

Jayakumar-AndroidDev commented 4 months ago

Unable to detect face using google_mlkit_face_detection: ^0.11.0 `void faceDetect(CameraImage image) { final writeBuffer = WriteBuffer();

for (final plan in image.planes) {
  writeBuffer.putUint8List(plan.bytes);
}

final bytes = writeBuffer.done().buffer.asUint8List();

final size = Size(
  image.width.toDouble(),
  image.height.toDouble(),
);

const rotation = InputImageRotation.rotation0deg;

final format = InputImageFormatValue.fromRawValue(image.format.raw) ??
    InputImageFormat.nv21;

final metaData = InputImageMetadata(
  size: size,
  rotation: rotation,
  format: format,
  bytesPerRow: image.planes[0].bytesPerRow,
);

final inputImage = InputImage.fromBytes(
  bytes: bytes,
  metadata: metaData,
);

final option = FaceDetectorOptions(
  enableClassification: true,
  enableContours: true,
  enableLandmarks: true,
  enableTracking: true,
);

final faceDetector = FaceDetector(options: option);

faceDetector.processImage(inputImage).then(
  (detectedFace) {
    debugPrint('detected_face:- ${detectedFace.length}');
  },
);

} `

jackqdyulei commented 3 months ago

Seems you are using the flutter API(not maintained by Google). Please consider to post your question here:

https://github.com/flutter-ml/google_ml_kit_flutter