use of com.amplifyframework.predictions.models.LabelType in project amplify-android by aws-amplify.
the class AWSPredictionsService method detectLabels.
/**
* Delegate to {@link AWSRekognitionService} to detect labels.
* @param type the type of labels to detect
* @param imageData the image data
* @param onSuccess triggered upon successful result
* @param onError triggered upon encountering error
*/
public void detectLabels(@NonNull IdentifyAction type, @NonNull ByteBuffer imageData, @NonNull Consumer<IdentifyResult> onSuccess, @NonNull Consumer<PredictionsException> onError) {
final LabelType labelType;
try {
labelType = getLabelType(type);
} catch (PredictionsException error) {
onError.accept(error);
return;
}
rekognitionService.detectLabels(labelType, imageData, onSuccess, onError);
}
use of com.amplifyframework.predictions.models.LabelType in project amplify-android by aws-amplify.
the class IdentifyLabelsConfiguration method fromJson.
/**
* Construct an instance of {@link IdentifyLabelsConfiguration} from
* plugin configuration JSON object.
* @param configurationJson the plugin configuration
* @return the configuration for label identification
* @throws JSONException if identify configuration is malformed
*/
@Nullable
public static IdentifyLabelsConfiguration fromJson(@NonNull JSONObject configurationJson) throws JSONException {
if (!configurationJson.has(CONFIG_NAME)) {
return null;
}
JSONObject identifyLabelsJson = configurationJson.getJSONObject(CONFIG_NAME);
String typeString = identifyLabelsJson.getString("type");
String networkPolicyString = identifyLabelsJson.getString("defaultNetworkPolicy");
final LabelType type = LabelType.valueOf(typeString);
final NetworkPolicy networkPolicy = NetworkPolicy.fromKey(networkPolicyString);
return new IdentifyLabelsConfiguration(type, networkPolicy);
}
Aggregations