getCameraImagePredictionList method
Future<List<double> >
getCameraImagePredictionList(
- CameraImage cameraImage, {
- int? rotation,
- List<
double> mean = torchVisionNormMeanRGB, - List<
double> std = torchVisionNormSTDRGB, - CameraPreProcessingMethod cameraPreProcessingMethod = CameraPreProcessingMethod.imageLib,
- PreProcessingMethod preProcessingMethod = PreProcessingMethod.imageLib,
Retrieves a list of predictions for a camera image.
Takes a cameraImage
as input. Optional parameters include rotation
, mean
, std
,
cameraPreProcessingMethod
, and preProcessingMethod
.
Returns a Future that resolves to a List of double values representing the predictions.
Throws an Exception if unable to process the image bytes.
Implementation
Future<List<double>> getCameraImagePredictionList(CameraImage cameraImage,
{int? rotation,
List<double> mean = torchVisionNormMeanRGB,
List<double> std = torchVisionNormSTDRGB,
CameraPreProcessingMethod cameraPreProcessingMethod =
CameraPreProcessingMethod.imageLib,
PreProcessingMethod preProcessingMethod =
PreProcessingMethod.imageLib}) async {
// Perform preprocessing based on the chosen camera pre-processing method
if (cameraPreProcessingMethod == CameraPreProcessingMethod.imageLib) {
Uint8List? bytes =
await ImageUtilsIsolate.convertCameraImageToBytes(cameraImage);
if (bytes == null) {
throw Exception("Unable to process image bytes");
}
// Retrieve the image predictions for the preprocessed image bytes
return await getImagePredictionList(bytes,
mean: mean, std: std, preProcessingMethod: preProcessingMethod);
}
// Retrieve the image predictions for the camera image planes
return await getImagePredictionListFromBytesList(
cameraImage.planes.map((e) => e.bytes).toList(),
cameraImage.width,
cameraImage.height,
mean: mean,
std: std);
}