first pass of consolidating search in DBox for existing person, and then using the results to add override force match to that person, and WORKING version of adding refimg to existing person too. Still does not kick off new AI scan at this point, and still need to re-format dbox to be easier to use and code for resetting DB contents, rescaning files from scratch and matching overrides back

This commit is contained in:
2022-07-10 15:21:31 +10:00
parent 1507addf38
commit 6b7694f382
5 changed files with 152 additions and 64 deletions

View File

@@ -263,24 +263,24 @@ $(document).ready( function()
} );
// quick wrapper function to make calling this ajax code simpler in SearchForPerson
function OverrideForceMatch( person_id, face_id, face_pos, type_id )
function OverrideForceMatch( person_id, key )
{
// we have type_id passed in, so dig the NMO out, and use that below (its really just for name, but in case we change that in the DB)
for( el in NMO )
{
if( NMO[el].type_id == type_id )
if( NMO[el].type_id == item[key].type_id )
{
fm_idx=el
break
}
}
ofm='&person_id='+person_id+'&face_id='+face_id
ofm='&person_id='+person_id+'&face_id='+item[key].id
$.ajax({ type: 'POST', data: ofm, url: '/override_force_match', success: function(data) {
objs[current].faces[face_pos].override={}
objs[current].faces[face_pos].override.who=data.person_tag
objs[current].faces[face_pos].override.distance='N/A'
objs[current].faces[face_pos].override.type_id=NMO[fm_idx].id
objs[current].faces[face_pos].override.type_name=NMO[fm_idx].name
objs[current].faces[item[key].which_face].override={}
objs[current].faces[item[key].which_face].override.who=data.person_tag
objs[current].faces[item[key].which_face].override.distance='N/A'
objs[current].faces[item[key].which_face].override.type_id=NMO[fm_idx].id
objs[current].faces[item[key].which_face].override.type_name=NMO[fm_idx].name
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
@@ -289,21 +289,42 @@ function OverrideForceMatch( person_id, face_id, face_pos, type_id )
} )
}
function AddRefImgTo( person_id, key )
{
d='&face_id='+item[key].id+'&person_id='+person_id+
'&file_eid='+current+'&refimg_data='+item[key].refimg_data
console.log( d )
$.ajax({ type: 'POST', data: d, url: '/add_refimg_to_person',
success: function(data) {
objs[current].faces[item[key].which_face].who=data.who
objs[current].faces[item[key].which_face].distance=data.distance
$('#dbox').modal('hide')
$('#faces').prop('checked',true)
DrawImg()
}
})
}
// function to facilitate adding a face match override to this "found" person
// uses Ajax to the f/e to get any person matching #stext's content (via any name/tag)
// and displays results in #search_person_results
function SearchForPerson(face_id, face_pos, type_id)
function SearchForPerson(content, key, face_id, face_pos, type_id)
{
console.log( 'type_id=' + item[key].type_id )
// make URI safe
who = encodeURIComponent( $('#stext').val() )
// call ajax to find ppl
$.ajax({ type: 'POST', data: null, url: '/find_persons/'+ who,
success: function(data) {
content='Click one of the link(s) below to manually connect this face as once-off connection to the person:<br><br>'
for( var key in data ) {
var person = data[key];
content+= '<a role=button class="link link-primary" onClick="OverrideForceMatch('+person.id+','
+face_id+','+face_pos+','+type_id+')">'+person.firstname+' '+person.surname+' ('+person.tag+')</a><br>'
for( var el in data ) {
var person = data[el];
// NMO_1 is a non-match-override type_id==1 (or force match to existing person)
if( key == "NMO_1" )
content+= '<a role=button class="link link-primary" onClick="OverrideForceMatch('+person.id+',\''+key+'\')">'
+person.firstname+' '+person.surname+' ('+person.tag+')</a><br>'
if( key == 'no_match_new_refimg' )
content+= '<a role=button class="link link-primary" onClick="AddRefImgTo('+person.id+',\''+key+'\')">'
+person.firstname+' '+person.surname+' ('+person.tag+')</a><br>'
}
$('#search_person_results').html( content )
}
@@ -357,6 +378,23 @@ function AddNoMatchOverride(type_id, face_id, face_pos, type_id)
} )
}
function AddSearch( content, key, face_pos )
{
html='<h5>search for existing person:</h5>'
html+=`
<div class="input-group mb-3"><input type="text" class="form-control" id="stext" placeholder="tag/name">
<button id="search_person_btn" class="btn btn-outline-success" type="button"
onClick="SearchForPerson( `
html+= "'" + content + "', " + "'" +key+"'" + ', ' + item[key].id + ',' + face_pos + ',' + item[key].type_id
html+=`)">Search</button>
</div>
<div id="search_person_results">
</div>
<script>
$("#stext").keypress(function (e) { if (e.which == 13) { $("#search_person_btn").click(); return false; } } )
</script>`
return html
}
// function that is called when we click on a face in the viewer and we want to
// potentially override the non-match / match... it shows the face, and then
@@ -369,6 +407,7 @@ function FaceDBox(key, item)
div+='<div id="face_img"></div>'
$.ajax({ type: 'POST', data: null, url: '/get_face_from_image/'+item[key]['id'],
success: function(img_data) {
item[key].refimg_data=img_data
$('#face_img').html( '<img src="data:image/jpeg;base64,' + img_data + '"></img>' )
}
} )
@@ -394,7 +433,7 @@ function FaceDBox(key, item)
}
if ( key == 'no_match_new_refimg' )
{
div+='<h5>search for existing person: NOT YET</h5>'
div+=AddSearch( 'Click one of the link(s) below to add this face as a reference image to the person:<br><br>', key, face_pos );
}
if ( key == 'wrong_person' )
{
@@ -405,19 +444,7 @@ function FaceDBox(key, item)
{
if( item[key].name == 'Override: Manual match to existing person' )
{
div+='<h5>search for existing person:</h5>'
div+=
`
<div class="input-group mb-3"><input type="text" class="form-control" id="stext" placeholder="tag/name">
<button id="search_person_btn" class="btn btn-outline-success" type="button" onClick="SearchForPerson(`
div+= item[key]['id'] + ',' + face_pos + ',' + item[key].type_id
div+=`)">Search</button>
</div>
<div id="search_person_results">
</div>
<script>
$("#stext").keypress(function (e) { if (e.which == 13) { $("#search_person_btn").click(); return false; } } )
</script>`
div+=AddSearch( 'Click one of the link(s) below to manually connect this face as once-off connection to the person:<br><br>', key, face_pos );
}
else
{