/** * @param image - the Image (as an inputStream * @see FaceScenarios#findSingleFace(String) * @return Face */ @NotNull public Face findSingleFace(@NotNull InputStream image) { List<Face> faces = faceTaskBuilder.detectFace(true, true, FaceAttributes.ALL, image).withResult(); if (Utils.isEmpty(faces) || faces.size() > 1) throw new SingleFaceNotFoundException(Utils.isEmpty(faces) ? 0 : faces.size(), "a single face was not present"); return faces.get(0); }
/** * Find a faces within a local image * * @param image the image URL * @return the found faces */ @NotNull public Emotion findEmotionSingleFace(@NotNull String image) { List<Emotion> emotions = emotionBuilder.emotionRecognition(image).withResult(); if (Utils.isEmpty(emotions) || emotions.size() > 1) throw new SingleFaceNotFoundException(Utils.isEmpty(emotions) ? 0 : emotions.size(), "a single face was not present"); return emotions.get(0); }
/** * Find a single face within a given url * * @param imageUrl the url to find the single face. * @return the found face * @throws SingleFaceNotFoundException If a single face is not found */ @NotNull public Face findSingleFace(@NotNull String imageUrl) { List<Face> faces = faceTaskBuilder.detectFace(true, true, FaceAttributes.ALL, imageUrl).withResult(); if (Utils.isEmpty(faces) || faces.size() > 1) throw new SingleFaceNotFoundException(Utils.isEmpty(faces) ? 0 : faces.size(), "a single face was not present"); return faces.get(0); }
/** * Find a single face with emotion within a given url * * @param imageUrl the url to find the single face with emotion. * @return the found face with emotion * @throws SingleFaceNotFoundException thrown if a single face is not found */ @NotNull public Emotion findEmotionFromSingleFace(@NotNull String imageUrl) { List<Emotion> emotions = emotionBuilder.emotionRecognition(imageUrl).withResult(); if (Utils.isEmpty(emotions) || emotions.size() > 1) throw new SingleFaceNotFoundException(Utils.isEmpty(emotions) ? 0 : emotions.size(), "a single face was not present"); return emotions.get(0); }
/** * Find a single face with emotion within a given url * * @param image the local image to find the single face with emotion * @return the found face with emotion * @throws SingleFaceNotFoundException if a single face is not found */ @NotNull public Emotion findEmotionFromSingleFace(@NotNull InputStream image) { List<Emotion> emotions = emotionBuilder.emotionRecognition(image).withResult(); if (Utils.isEmpty(emotions) || emotions.size() > 1) throw new SingleFaceNotFoundException(Utils.isEmpty(emotions) ? 0 : emotions.size(), "a single face was not present"); return emotions.get(0); }
public static void validateExclusive(List collection, String str, ParameterValidationException toThrow) { if ((Utils.isEmpty(collection) && Utils.isBlank(str)) || (Utils.isNotEmpty(collection) && Utils.isNotBlank(str))) throw toThrow; } }