with viewer, unmatched face now has img data / thumbnail, so we know what it really looks like when we choose to override - still major WIP, tables.sql also has some override types, but not convinced I have design yet

This commit is contained in:
2022-02-06 23:21:23 +11:00
parent 8625b1d217
commit e9ab49c60a
5 changed files with 66 additions and 12 deletions

24
ai.py
View File

@@ -105,3 +105,27 @@ def unmatched_faces():
face.img = str(face.img)[2:-1]
return render_template("faces.html", faces=faces)
# this is called in Ajax, when we manually override a face that is currently unmatched load
# the original full image, find the current face's coords, grab pixels 10% larger and return
# it so we can show it in the dbox, and be able to pass it around for refimg creation (if needed)
@app.route("/get_face_from_image/<face_id>", methods=["POST"])
@login_required
def get_face_from_image(face_id):
face=Face.query.get(face_id)
f = Entry.query.join(File).join(FaceFileLink).filter(FaceFileLink.face_id==face_id).first()
tmp_locn=json.loads(face.locn)
x=tmp_locn[3]*0.95
y=tmp_locn[0]*0.95
x2=tmp_locn[1]*1.05
y2=tmp_locn[2]*1.05
im = Image.open(f.FullPathOnFS())
region = im.crop((x, y, x2, y2))
img_bytearray = io.BytesIO()
region.save(img_bytearray, format='JPEG')
img_bytearray = img_bytearray.getvalue()
face_img = base64.b64encode(img_bytearray)
face_img = str(face_img)[2:-1]
return face_img