/** * write out the faces gender and age (formatted '%Gender, Age %.1f') * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face the face. * @param colourPalette the colors to use * @param insets any Insets to take into consideration(e.g. border thickness). * @return this */ public ImageOverlayBuilder writeGenderAndAge(Face face, CognitiveJColourPalette colourPalette, @NotNull Insets insets) { return writeGenderAndAge(face, colourPalette, insets, RectangleTextPosition.TOP_OF); }
/** * Draw the rectangle and displays all @{@link Emotion} for the face. * * @param emotion all found emotions. * @return this */ @NotNull public ImageOverlayBuilder outlineEmotionOnImage(@NotNull Emotion emotion) { return outlineEmotionOnImage(emotion, RectangleTextPosition.RIGHT_OF); }
/** * @param image - the image (as a {@link File}) * @return ImageOverlayBuilder * @see ImageOverlayBuilder#builder(String) */ @NotNull public static ImageOverlayBuilder builder(@NotNull File image) { ImageOverlayBuilder imageOverlayBuilder; try { imageOverlayBuilder = new ImageOverlayBuilder(ImageIO.read(image)); } catch (IOException e) { throw new ImageNotFoundException(image); } return imageOverlayBuilder; }
public static void main(String[] args) throws IOException { FaceScenarios faceScenarios = new FaceScenarios(getProperty("azure.cognitive.subscriptionKey"), getProperty("azure.cognitive.emotion.subscriptionKey")); ImageOverlayBuilder imageOverlayBuilder = ImageOverlayBuilder.builder(CANDIDATE_1); imageOverlayBuilder.verify(CANDIDATE_2, faceScenarios.verifyFaces(CANDIDATE_1, CANDIDATE_2)).launchViewer(); } }
public static void main(String[] args) throws IOException { FaceScenarios faceScenarios = new FaceScenarios(getProperty("azure.cognitive.subscriptionKey"), getProperty("azure.cognitive.emotion.subscriptionKey")); ImageOverlayBuilder.builder(IMAGE_URL) .outlineEmotionsOnImage(faceScenarios .findEmotionFaces(IMAGE_URL)).launchViewer(); } }
/** * write out the faces' {@link FaceAttributes} * * @param face - the face. * @return this */ @NotNull public ImageOverlayBuilder writeFaceAttributes(@NotNull Face face) { return writeFaceAttributes(face, CognitiveJColourPalette.GRAY); }
/** * Outlines a face on the base image with defaults; * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face - the face. * @return this */ @NotNull public ImageOverlayBuilder outlineFaceOnImage(@NotNull Face face) { return outlineFaceOnImage(face, RectangleType.CORNERED); }
/** * write out the faces age (formatted 'Age %.1f') to the top of the face rectangle. * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face - the face. * @return this */ @NotNull public ImageOverlayBuilder writeAge(@NotNull Face face) { return writeAge(face, RectangleTextPosition.TOP_OF); }
/** * Merges another image onto the base image (to the right) * * @param mergeImage the image to be merged * @return this */ @NotNull public ImageOverlayBuilder mergeImage(@NotNull BufferedImage mergeImage) { return mergeImage(mergeImage, MergeImagesFilter.Position.RIGHT); }
/** * tags identified faces. * * @param identificationSet a set of identifications. * @return this */ @NotNull public ImageOverlayBuilder identify(@NotNull IdentificationSet identificationSet) { return identify(identificationSet, RectangleTextPosition.TOP_OF); }
@NotNull public ImageOverlayBuilder outFaceLandmarksOnImage(@NotNull Face face) { return outFaceLandmarksOnImage(face, BorderWeight.THICK); }
/** * Draw the rectangle and outline the dominant @{@link Emotion} * * @param emotion the emotion * @return this */ @NotNull public ImageOverlayBuilder outlineDominantEmotionOnImage(@NotNull Emotion emotion) { return outlineDominantEmotionOnImage(emotion, RectangleTextPosition.TOP_OF); }
/** * @param image - the image (as a {@link BufferedImage}) * @return ImageOverlayBuilder * @see ImageOverlayBuilder#builder(String) */ @NotNull public static ImageOverlayBuilder builder(@NotNull BufferedImage image) { return new ImageOverlayBuilder(image); }
/** * write out the faces gender and age (formatted '%Gender, Age %.1f') to the top of the face rectangle. * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face the face. * @param colourPalette the color to paint the text * @return this */ @NotNull public ImageOverlayBuilder writeGenderAndAge(@NotNull Face face, @NotNull CognitiveJColourPalette colourPalette) { return writeGenderAndAge(face, colourPalette, DEFAULT_BORDER_WEIGHT); }
/** * write out the faces' {@link FaceAttributes} * * @param colourPalette the colour options for the text * @param faces - the faces to write attributes for. * @return this */ public ImageOverlayBuilder writeFaceAttributes(@NotNull List<Face> faces, @NotNull CognitiveJColourPalette colourPalette) { return writeFaceAttributes(faces, colourPalette, RectangleTextPosition.RIGHT_OF); }
/** * Outlines face on the base image with defaults; * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face - the faces. * @param rectangleType - the rectangle type. * @return this */ @NotNull public ImageOverlayBuilder outlineFaceOnImage(@NotNull Face face, @NotNull RectangleType rectangleType) { return outlineFaceOnImage(face, rectangleType, DEFAULT_BORDER_WEIGHT); }
/** * write out the faces age (formatted 'Age %.1f') to the top of the face rectangle. * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face the face. * @param textPosition location of the text boundary * @return this */ @NotNull public ImageOverlayBuilder writeAge(@NotNull Face face, @NotNull RectangleTextPosition textPosition) { return writeAge(face, CognitiveJColourPalette.randomColour(), textPosition); }
/** * Create a new {@link ImageOverlayBuilder} from the base Image attached. * * @param image - the image (as a url {@link String} ) * @return a new {@link ImageOverlayBuilder} * @throws ImageNotFoundException - if the image can't be found. */ @NotNull public static ImageOverlayBuilder builder(@NotNull String image) { try { return new ImageOverlayBuilder(ImageIO.read(new URL(image))); } catch (IOException e) { throw new ImageNotFoundException(image); } }
/** * write out the faces gender and age (formatted '%Gender, Age %.1f') to the top of the face rectangle. * ({@link ImageOverlayBuilder#outlineFaceOnImage(Face, RectangleType, BorderWeight, CognitiveJColourPalette)} * * @param face - the face. * @return this */ @NotNull public ImageOverlayBuilder writeGenderAndAge(@NotNull Face face) { return writeGenderAndAge(face, CognitiveJColourPalette.randomColour()); }
/** * write out the faces' {@link FaceAttributes} * * @param face the face. * @param colourPalette the colour to use * @return this */ @NotNull public ImageOverlayBuilder writeFaceAttributes(@NotNull Face face, @NotNull CognitiveJColourPalette colourPalette) { return writeFaceAttributes(face, colourPalette, RectangleTextPosition.RIGHT_OF); }