getImagePredictionList method

Future<List<ResultObjectDetection>> getImagePredictionList(
  1. Uint8List imageAsBytes, {
  2. double minimumScore = 0.5,
  3. double iOUThreshold = 0.5,
  4. int boxesLimit = 10,
  5. PreProcessingMethod preProcessingMethod = PreProcessingMethod.imageLib,
})

Returns a list of ResultObjectDetection for the given imageAsBytes.

The minimumScore, iOUThreshold, and boxesLimit parameters control the prediction quality. The preProcessingMethod parameter determines the method used for preprocessing the image.

If preProcessingMethod is PreProcessingMethod.imageLib, the image bytes are converted to a float buffer using ImageUtilsIsolate.convertImageBytesToFloatBuffer before making the prediction. Otherwise, the prediction is made directly using the image bytes.

Returns a list of ResultObjectDetection where each result has a score greater than or equal to minimumScore.

Implementation

Future<List<ResultObjectDetection>> getImagePredictionList(
    Uint8List imageAsBytes,
    {double minimumScore = 0.5,
    double iOUThreshold = 0.5,
    int boxesLimit = 10,
    PreProcessingMethod preProcessingMethod =
        PreProcessingMethod.imageLib}) async {
  if (preProcessingMethod == PreProcessingMethod.imageLib) {
    Uint8List data = await ImageUtilsIsolate.convertImageBytesToFloatBuffer(
        imageAsBytes, imageWidth, imageHeight, noMeanRGB, noSTDRGB);
    return (await ModelApi().getRawImagePredictionListObjectDetection(
            _index, data, minimumScore, iOUThreshold, boxesLimit))
        .whereNotNull()
        .toList();
  }
  return (await ModelApi().getImagePredictionListObjectDetection(
          _index,
          imageAsBytes,
          null,
          null,
          null,
          minimumScore,
          iOUThreshold,
          boxesLimit))
      .whereNotNull()
      .toList();
}