Reputation: 3
I'm currently working on a Flutter project where I need to integrate Python code for facial recognition. Specifically, I want to utilize the face_recognition library within my Python code. My requirements are as follows
Below is an example snippet of the Python code I intend to use:
import face_recognition
import sys
def faceRecFun(image1_path, image2_path):
try:
image1 = face_recognition.load_image_file(image1_path)
image2 = face_recognition.load_image_file(image2_path)
face_encoding1 = face_recognition.face_encodings(image1)[0]
face_encoding2 = face_recognition.face_encodings(image2)[0]
results = face_recognition.compare_faces([face_encoding1], face_encoding2)
return results[0]
except Exception as e:
return False
if __name__ == "__main__":
# Check if the correct number of arguments are provided
if len(sys.argv) != 3:
print(False)
sys.exit(1)
if sys.argv[1] == "" or sys.argv[2] == "" :
print(False)
sys.exit(1)
arg1 = sys.argv[1]
arg2 = sys.argv[2]
print(faceRecFun(str(arg1), str(arg2)))
# # # Example usage:
# image1_path = "C:/Documents/Scraps/Asset/0.jpeg"
# image2_path = "C:/Documents/Scraps/Asset/1.jpeg"
# faces_match = faceRec.faceRecFun(image1_path, image2_path)
# print("Faces match:", faces_match)
I need to call the above function from my flutter project and will send two paths of image which contain single face in it. That will return True or False based on the similarity.
String result=await faceRecFun(file.path,file1.path);
I would appreciate any guidance or examples on how to achieve this integration and whether it's feasible to utilize the face_recognition library within a Flutter project.
Or it is okay if any other way available on this. Like a flutter package or library. But the comparison should be proper.
Thank you in advance for your assistance!
Upvotes: 0
Views: 307