Last active
November 23, 2020 22:38
-
-
Save cyrusbehr/c52e307f02fca414648dc514b0dd3838 to your computer and use it in GitHub Desktop.
Sample using synchronization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ app.route('/identify', methods=['POST']) | |
def identify(): | |
# Generate the template first | |
# Call create_load_collection after generating template so mutex is locked for shortest amount of time | |
res = sdk.set_image(image_path) | |
res, v1 = sdk.get_largest_face_feature_vector() | |
# Now that we have generated the template, lock the mutex | |
mutex.lock() | |
res = sdk.create_load_collection(collection_id + '_' + namespace) | |
res, found, candidate = sdk.identify_top_candidate(v1, MINIMUN_RAW_IDENTIFY_THRESHOLD) | |
mutex.unlock() | |
# Now safe to ulock mutex | |
@ app.route('/enroll', methods=['POST']) | |
def enroll(): | |
# Generate the template first | |
# Call create_load_collection after generating template so mutex is locked for shortest amount of time | |
res = sdk.set_image(image_path) | |
res, v1 = sdk.get_largest_face_feature_vector() | |
# Now that we have generated the template, lock the mutex | |
mutex.lock() | |
res = sdk.create_load_collection(collection_id + '_' + namespace) | |
res, UUID = sdk.enroll_template(faceprint, label) | |
mutex.unlock() | |
# Now safe to ulock mutex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment