robmarkcole / deepstack-python

Unofficial python API for DeepStack
https://deepstack.cc/
GNU General Public License v3.0
12 stars 11 forks source link

How to determine if face detect or face recognise? #14

Open robmarkcole opened 5 years ago

robmarkcole commented 5 years ago

Have 2 endpoints, but should I have one detect method with an optional arg ,or two seperate methods?

e.g. process_file(image_path, recognise=True) # default recognise=False uses detection

robmarkcole commented 4 years ago

The only difference with face recognition is that user_id is also returned. Handlign this in HA integration with:

def parse_faces(predictions):
    """Get recognised faces for the image_processing.detect_face event."""
    faces = []
    for entry in predictions:
        if not "userid" in entry.keys():
            break  # we are in detect_only mode
        if entry["userid"] == "unknown":
            continue
        face = {}
        face["name"] = entry["userid"]
        face[ATTR_CONFIDENCE] = round(100.0 * entry["confidence"], 2)
        faces.append(face)
    return faces