getImagePrediction static method

Future<List> getImagePrediction({
  1. required File image,
  2. int inputWidth = kInputWidth,
  3. int inputHeight = kInputHeight,
  4. List<double> mean = kNormMean,
  5. List<double> std = kNormStd,
  6. double minScore = kMinScore,
})

Get the inference result of a static image.

Using the image file image (required) for inference, the image size for inference inputWidth, inputHeight, the mean mean and standard deviation std for image normalization, the threshold of the inference result minScore, and get the inference result.

The format is List of { "rect": { "left": double, "top": double, "right": double, "bottom": double }, "mask": Uint8List, "keypoints": [[double, double], [double, double], [double, double], [double, double], ...], "confidenceInClass": double, "detectedClass": String }.

"mask" and "keypoints" do not exist on some models.

Implementation

static Future<List> getImagePrediction({
  required File image,
  int inputWidth = kInputWidth,
  int inputHeight = kInputHeight,
  List<double> mean = kNormMean,
  List<double> std = kNormStd,
  double minScore = kMinScore,
}) async {
  final List prediction = await _channel.invokeMethod(
    'predictImage',
    {
      'image': image.readAsBytesSync(),
      'inputWidth': inputWidth,
      'inputHeight': inputHeight,
      'mean': mean,
      'std': std,
      'minScore': minScore,
    },
  );

  return prediction;
}