/** * This operation generates a thumbnail image with the user-specified width and height. * <p>By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. * <p>Smart cropping helps when you specify an aspect ratio that differs from that of the input image * * @param width Width of the thumbnail. It must be between 1 and 1024. Recommended minimum of 50. * @param height Height of the thumbnail. It must be between 1 and 1024. Recommended minimum of 50. * @param smartCrop Boolean flag for enabling smart cropping. * @param imageUrl URL of input image. * @return a built {@link GetThumbnailAction} * @see <a href="https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fb">MS Cognitive Docs (Computer Vision - Get Thumbnail)</a> */ @NotNull public GetThumbnailAction getThumbnail(int width, int height, boolean smartCrop, @NotNull String imageUrl) { Validation.validateInt(width, 1024, new ParameterValidationException("width", "It must be between 1 and 1024. Recommended minimum of 50.")); Validation.validateInt(height, 1024, new ParameterValidationException("height", "It must be between 1 and 1024. Recommended minimum of 50.")); return new GetThumbnailAction(cognitiveContext, width, height, smartCrop, imageUrl); }
/** * Identify unknown faces from an person group. * <p> * For each face in the faceIds array, Face Identify will compute similarity for the face among all faces within a person group (given by personGroupId), and returns candidate person(s) for that face ranked by similarity confidence. The person group should be trained to make it ready for identify. See more in Person Group - Train Person Group. * <p> * Remarks: * <p> * The algorithm allows more than one face to be isIdentified, but the no more than 10 faces. * Each person in the person group could have more than one face, but no more than 64 faces. * Identification works well for frontal faces and near-frontal faces. * Number of candidates returned is restricted by maxNumOfCandidatesReturned. If no person is isIdentified, the candidate returned will be an empty array. * Try Face - Find Similar when you need to identify similar faces from a face list instead of a person group. * * @param faceIds Query faces' IDs. The length of faceIds is between [1, 10]. * @param personGroupId Target person group's ID * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @return a built {@link IdentifyFacesAction} * @see <a href="https://dev.projectoxford.ai/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239">MS Cognitive Docs (Face - Identify)</a> */ public IdentifyFacesAction identifyFaces(List<String> faceIds, String personGroupId, int maxNumOfCandidatesReturned) { Validation.validateArray(faceIds, 1, 10, new ParameterValidationException("faceIds", "length must be between 1 & 10")); Validation.validateInt(maxNumOfCandidatesReturned, 5, new ParameterValidationException("maxNumOfCandidatesReturned", "maxNumOfCandidatesReturned must be between 1 & 5")); return new IdentifyFacesAction(cognitiveContext, faceIds, personGroupId, maxNumOfCandidatesReturned); }
/** * Find similar - looking faces for a query face from a list of candidate faces (given by a face list or a face ID array) and return similar face IDs ranked by similarity. * The candidate face list has a limitation of 1000 faces. * * @param faceId Query face. The faceId comes from the {@link FaceTaskBuilder#detectFace(boolean, boolean, EnumSet, InputStream)} . * @param faceIds A candidate face list. Face list simply represents a list of faces, reference Face List - Create a Face List for more detail. faceListId and faceIds should not be provided at the same time. * @param faceListId A face ID array of candidate faces. Length of faceIds should between [1, 1000]. Parameter faceListId and faceIds should not be provided at the same time. * @param maxNumOfCandidates Only top maxNumOfCandidatesReturned most similar faces will be returned. maxNumOfCandidatesReturned ranges between [1, 20]. * @return a built {@link FindSimilarFacesAction} * @see <a href="https://dev.projectoxford.ai/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237">MS Cognitive Docs (Face - Find Similar)</a> */ public FindSimilarFacesAction findSimilarFace(String faceId, List<String> faceIds, String faceListId, int maxNumOfCandidates) { Validation.validateArray(faceIds, 0, 1000, new ParameterValidationException("faceIds", "length must be between 1 & 1000")); Validation.validateInt(maxNumOfCandidates, 20, new ParameterValidationException("maxNumOfCandidates", "length must be between 1 & 20")); Validation.validateExclusive(faceIds, faceListId, new ParameterValidationException("faceIds", "must only supply either faceListId OR a faceId (pass null or empty collection)")); return new FindSimilarFacesAction(cognitiveContext, faceId, faceIds, faceListId, maxNumOfCandidates); } }