getCameraImagePrediction method
Future<String>
getCameraImagePrediction(
- CameraImage cameraImage,
- int rotation, {
- List<
double> mean = torchVisionNormMeanRGB, - List<
double> std = torchVisionNormSTDRGB, - CameraPreProcessingMethod cameraPreProcessingMethod = CameraPreProcessingMethod.imageLib,
- PreProcessingMethod preProcessingMethod = PreProcessingMethod.imageLib,
Retrieves the top prediction label for a camera image.
Takes a cameraImage
and rotation
as input. Optional parameters include mean
, std
,
cameraPreProcessingMethod
, and preProcessingMethod
.
Returns a Future that resolves to a String
representing the top prediction label.
Implementation
Future<String> getCameraImagePrediction(CameraImage cameraImage, int rotation,
{List<double> mean = torchVisionNormMeanRGB,
List<double> std = torchVisionNormSTDRGB,
CameraPreProcessingMethod cameraPreProcessingMethod =
CameraPreProcessingMethod.imageLib,
PreProcessingMethod preProcessingMethod =
PreProcessingMethod.imageLib}) async {
// Retrieve the prediction list for the camera image
final List<double> prediction = await getCameraImagePredictionList(
cameraImage, rotation,
mean: mean,
std: std,
cameraPreProcessingMethod: cameraPreProcessingMethod,
preProcessingMethod: preProcessingMethod);
// Get the index of the maximum score from the prediction list
int maxScoreIndex = softMax(prediction);
// Return the label corresponding to the maximum score index
return labels[maxScoreIndex];
}