/** * 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); }
/** * 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 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 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 * @param borderWeight borderWeight to use * @return this */ @NotNull public ImageOverlayBuilder writeGenderAndAge(@NotNull Face face, @NotNull CognitiveJColourPalette colourPalette, @NotNull BorderWeight borderWeight) { return writeGenderAndAge(face, colourPalette, borderWeight.insets()); }
public static void main(String[] args) throws IOException { FaceScenarios faceScenarios = new FaceScenarios(System.getProperty("azure.cognitive.subscriptionKey"), System.getProperty("azure.cognitive.emotion.subscriptionKey")); ImageOverlayBuilder imageOverlayBuilder = ImageOverlayBuilder.builder(FILE_LOCATION_OF_US_PRESIDENT); Face face = faceScenarios.findSingleFace(FILE_LOCATION_OF_US_PRESIDENT); imageOverlayBuilder.outlineFaceOnImage(face, RectangleType.FULL, ImageOverlayBuilder.DEFAULT_BORDER_WEIGHT, CognitiveJColourPalette.POPPY).writeGenderAndAge(face, CognitiveJColourPalette.POPPY).launchViewer(); } }