IDScan.net
Search Results for

    Show / Hide Table of Contents

    Facial Recognition Java

    Description

    The SDK allows you to capture faces, evaluate gender, age group, emotions, and create face templates to compare them and find similarity percentages.

    Face templates can be compared to each other, one-to-one, or one-to-many using a collection of templates.

    Recognition Type

    There are two types of recognition:

    Fast

    Fast Recognition type is recommended in cases where the fastest recognition is needed and the accuracy of recognition is not as important. For example, this recognition type is great for video processing.

    Quality

    Quality Recognition type requires more processing time but the result is more accurate.

    Note

    Each type of recognition is divided into separate redistributable packages.

    Analyze Faces

    // 1. Create service instance.
    FacialRecognitionService srv = FacialRecognitionService.createInstance("LICENSE_KEY");
    // 2. Find faces.
    List<Face> faces = srv.findFaces(input);
    // 3. Analyze faces.
    for(Face f : faces) {
        FaceAnalytics analytics = srv.analyzeFace(f);  
        ...
    }
    

    For analyze faces on the image you need:

    1. Create instance of the Facial Recognition Service by calling FacialRecognitionService.createInstance(String licKey). As a result, you will get an instance of the Facial Recognition Service that can be used to analyze faces on images.
    2. Find faces on the image by calling FacialRecognitionService.findFaces(Image image). As a result, you will get the set of faces that have been detected on the Image. Each entity in the set contains the basic information about the face such as position of eyes, position the face on the image and set of characteristic points.
    3. Analyze the faces by calling either FacialRecognitionService.analyzeFace(Face face) or FacialRecognitionService.analyzeFace(Face face, int flags). As a result, you will get advanced information about faces on the image such as emotions, age and gender.

    Matching Faces

    For matching faces you need build Templates and TemplateIndexes. With Templates you can match faces to each other. With TemplateIndexes you cat search one face in set of faces.

    // 1. Create service instance.
    FacialRecognitionService srv = FacialRecognitionService.createInstance("LICENSE_KEY");
    // 2. Find faces on the first photo.
    List<Face> faces1 = srv.findFaces(photo1);
    // 3. Find faces on the second photo.
    List<Face> faces2 = srv.findFaces(photo2);
    //4. Compare two faces.
    double distance = srv.compareFaces(faces1.get(0), faces2.get(0));
    

    For matching two faces each other you can either build Template for each face by calling FacialRecognitionService.buildTemplate(Face f) and then compare templates by calling compareFaces(Template first, Template second) or call compareFaces(Face first, Face second). In the second case templates for the faces will be built implicitly. As a result, you will get a normal distance between two faces in range [0.0, 1.0]. The 0.0 value means the faces are similar, 1.0 value means the faces are different.

    // 1. Create service instance.
    FacialRecognitionService srv = FacialRecognitionService.createInstance("LICENSE_KEY");
    // 2. Create index builder.
    TemplateIndexBuilder<String> indexBuilder = srv.buildIndex();
    // 3. Add faces to index.
    List<Face> faces = ...;
    for(Face f : faces) {
      indexBuilder.add(f, "Some Name");
    }
    // 4. Build index.
    TemplateIndex<String> index = indexBuilder.build();
    // 5. Search face in index.
    Face face = ...;
    FaceMatch<String> match = index.search(f);
    

    For searching face in set of faces you need:

    1. Create TemplateIndexBuilder by calling FacialRecognitionService.buildIndex();
    2. Add one or more faces to the index by calling either TemplateIndexBuilder<T>.add(Face face, T data) or TemplateIndexBuilder<T>.add(Template template, T data). In the second case template will be build implicitly.
    3. Build TemplateIndex by calling TemplateIndexBuilder<T>.build().
    4. Search the face in the index by calling either TemplateIndex<T>.search(Face face) or TemplateIndex<T>.search(Template template). As a result, you will get FaceMatch structure.
    Back to top IDScan.net IDScan.net GitHub