made basic viewer now handle new marshmallowed data - faces, model_used, face_distance, etc.

This commit is contained in:
2025-10-03 21:28:25 +10:00
parent cd73c16545
commit 3c8babb619

View File

@@ -87,11 +87,12 @@ function DrawImg()
// if we have faces, the enable the toggles, otherwise disable them // if we have faces, the enable the toggles, otherwise disable them
// and reset model select too // and reset model select too
if( document.viewing.faces ) if( document.viewing.file_details.faces )
{ {
$('#faces').attr('disabled', false) $('#faces').attr('disabled', false)
$('#distance').attr('disabled', false) $('#distance').attr('disabled', false)
$('#model').val( Number(document.viewing.face_model) ) // first face is good enough as whole file has to have used same model
$('#model').val( document.viewing.file_details.faces[0].facefile_lnk.model_used )
} }
else else
{ {
@@ -102,33 +103,34 @@ function DrawImg()
} }
// okay, we want faces drawn so lets do it // okay, we want faces drawn so lets do it
if( $('#faces').prop('checked') && document.viewing.faces ) if( $('#faces').prop('checked') && document.viewing.file_details.faces )
{ {
faces=document.viewing.file_details.faces
// draw rect on each face // draw rect on each face
for( i=0; i<document.viewing.faces.length; i++ ) for( i=0; i<faces.length; i++ )
{ {
x = document.viewing.faces[i].x / ( im.width/canvas.width ) x = faces[i].face_left / ( im.width/canvas.width )
y = document.viewing.faces[i].y / ( im.height/canvas.height ) y = faces[i].face_top / ( im.height/canvas.height )
w = document.viewing.faces[i].w / ( im.width/canvas.width ) w = faces[i].w / ( im.width/canvas.width )
h = document.viewing.faces[i].h / ( im.height/canvas.height ) h = faces[i].h / ( im.height/canvas.height )
context.beginPath() context.beginPath()
context.rect( x, y, w, h ) context.rect( x, y, w, h )
context.lineWidth = 2 context.lineWidth = 2
// this face has an override so diff colour // this face has an override so diff colour
if( document.viewing.faces[i].override ) if( faces[i].override )
{ {
context.strokeStyle = 'blue' context.strokeStyle = 'blue'
DrawLabelOnFace( document.viewing.faces[i].override.who ) DrawLabelOnFace( faces[i].override.who )
} }
else else
{ {
context.strokeStyle = 'green' context.strokeStyle = 'green'
if( document.viewing.faces[i].who ) if( faces[i].refimg )
{ {
str=document.viewing.faces[i].who str=faces[i].refimg.person.tag
if( $('#distance').prop('checked') ) if( $('#distance').prop('checked') )
str += "("+document.viewing.faces[i].distance+")" str += "("+faces[i].refimg_lnk.face_distance.toFixed(2)+")"
DrawLabelOnFace( str ) DrawLabelOnFace( str )
} }
} }
@@ -223,32 +225,33 @@ $(document).ready( function()
item_list = { not_a_face: { name: "Not a face", which_face: '-1' } } item_list = { not_a_face: { name: "Not a face", which_face: '-1' } }
for( i=0; i<document.viewing.faces.length; i++ ) faces=document.viewing.file_details.faces
for( i=0; i<faces.length; i++ )
{ {
fx = document.viewing.faces[i].x / ( im.width/canvas.width ) fx = faces[i].face_left / ( im.width/canvas.width )
fy = document.viewing.faces[i].y / ( im.height/canvas.height ) fy = faces[i].face_top / ( im.height/canvas.height )
fw = document.viewing.faces[i].w / ( im.width/canvas.width ) fw = faces[i].w / ( im.width/canvas.width )
fh = document.viewing.faces[i].h / ( im.height/canvas.height ) fh = faces[i].h / ( im.height/canvas.height )
if( x >= fx && x <= fx+fw && y >= fy && y <= fy+fh ) if( x >= fx && x <= fx+fw && y >= fy && y <= fy+fh )
{ {
if( document.viewing.faces[i].override ) if( faces[i].override )
{ {
item_list['remove_force_match_override']={ 'name': 'Remove override for this face', 'which_face': i, 'id': document.viewing.faces[i].id } item_list['remove_force_match_override']={ 'name': 'Remove override for this face', 'which_face': i, 'id': faces[i].id }
} }
else if( document.viewing.faces[i].who ) else if( faces[i].refimg )
{ {
item_list['match']={ 'name': document.viewing.faces[i].who, 'which_face': i, 'id': document.viewing.faces[i].id } item_list['match']={ 'name': faces[i].refimg.person.tag, 'which_face': i, 'id': faces[i].id }
item_list['match_add_refimg']={ 'name': 'Add this as refimg for ' + document.viewing.faces[i].who, item_list['match_add_refimg']={ 'name': 'Add this as refimg for ' + faces[i].refimg.person.tag,
'person_id': document.viewing.faces[i].pid, 'who': document.viewing.faces[i].who, 'which_face': i, 'id': document.viewing.faces[i].id, } 'person_id': faces[i].refimg.person.id, 'who': faces[i].refimg.person.tag, 'which_face': i, 'id': faces[i].id, }
item_list['wrong_person']={ 'name': 'wrong person', 'which_face': i, 'id': document.viewing.faces[i].id } item_list['wrong_person']={ 'name': 'wrong person', 'which_face': i, 'id': faces[i].id }
} }
else else
{ {
item_list['no_match_new_person']={ 'name': 'Add as reference image to NEW person', 'which_face': i, 'id': document.viewing.faces[i].id } item_list['no_match_new_person']={ 'name': 'Add as reference image to NEW person', 'which_face': i, 'id': faces[i].id }
item_list['no_match_new_refimg']={ 'name': 'Add as reference image to EXISTING person', 'which_face': i, 'id': document.viewing.faces[i].id } item_list['no_match_new_refimg']={ 'name': 'Add as reference image to EXISTING person', 'which_face': i, 'id': faces[i].id }
for( var el in NMO ) { for( var el in NMO ) {
item_list['NMO_'+el]={'type_id': NMO[el].type_id, 'name': 'Override: ' + NMO[el].name, 'which_face': i, 'id': document.viewing.faces[i].id } item_list['NMO_'+el]={'type_id': NMO[el].type_id, 'name': 'Override: ' + NMO[el].name, 'which_face': i, 'id': faces[i].id }
} }
} }
delete item_list['not_a_face'] delete item_list['not_a_face']
@@ -282,11 +285,11 @@ function OverrideForceMatch( person_id, key )
} }
ofm='&person_id='+person_id+'&face_id='+item[key].id ofm='&person_id='+person_id+'&face_id='+item[key].id
$.ajax({ type: 'POST', data: ofm, url: '/add_force_match_override', success: function(data) { $.ajax({ type: 'POST', data: ofm, url: '/add_force_match_override', success: function(data) {
document.viewing.faces[item[key].which_face].override={} document.viewing.file_details.faces[item[key].which_face].override={}
document.viewing.faces[item[key].which_face].override.who=data.person_tag document.viewing.file_details.faces[item[key].which_face].override.who=data.person_tag
document.viewing.faces[item[key].which_face].override.distance='N/A' document.viewing.file_details.faces[item[key].which_face].override.distance='N/A'
document.viewing.faces[item[key].which_face].override.type_id=NMO[fm_idx].id document.viewing.file_details.faces[item[key].which_face].override.type_id=NMO[fm_idx].id
document.viewing.faces[item[key].which_face].override.type_name=NMO[fm_idx].name document.viewing.file_details.faces[item[key].which_face].override.type_name=NMO[fm_idx].name
$('#dbox').modal('hide') $('#dbox').modal('hide')
$('#faces').prop('checked',true) $('#faces').prop('checked',true)
@@ -305,8 +308,8 @@ function CreatePersonAndRefimg( key )
+'&refimg_data='+item[key].refimg_data +'&refimg_data='+item[key].refimg_data
$.ajax({ type: 'POST', data: d, url: '/match_with_create_person', $.ajax({ type: 'POST', data: d, url: '/match_with_create_person',
success: function(data) { success: function(data) {
document.viewing.faces[item[key].which_face].who=data.who document.viewing.file_details.faces[item[key].which_face].refimg.person.tag=data.who
document.viewing.faces[item[key].which_face].distance=data.distance document.viewing.file_details.faces[item[key].which_face].facefile_lnk.face_distance=data.distance
$('#dbox').modal('hide') $('#dbox').modal('hide')
$('#faces').prop('checked',true) $('#faces').prop('checked',true)
DrawImg() DrawImg()
@@ -320,8 +323,8 @@ function AddRefimgTo( person_id, key, search )
d='&face_id='+item[key].id+'&person_id='+person_id+'&refimg_data='+item[key].refimg_data+'&search='+search d='&face_id='+item[key].id+'&person_id='+person_id+'&refimg_data='+item[key].refimg_data+'&search='+search
$.ajax({ type: 'POST', data: d, url: '/add_refimg_to_person', $.ajax({ type: 'POST', data: d, url: '/add_refimg_to_person',
success: function(data) { success: function(data) {
document.viewing.faces[item[key].which_face].who=data.who document.viewing.file_details.faces[item[key].which_face].refimg.person.tag=data.who
document.viewing.faces[item[key].which_face].distance=data.distance document.viewing.file_details.faces[item[key].which_face].facefile_lnk.face_distance=data.distance
$('#dbox').modal('hide') $('#dbox').modal('hide')
$('#faces').prop('checked',true) $('#faces').prop('checked',true)
DrawImg() DrawImg()
@@ -369,15 +372,15 @@ function SearchForPerson(content, key, face_id, face_pos, type_id)
function RemoveOverrideForceMatch(face_pos) function RemoveOverrideForceMatch(face_pos)
{ {
if( document.viewing.faces[face_pos].override ) if( document.viewing.file_details.faces[face_pos].override )
who=document.viewing.faces[face_pos].override.who who=document.viewing.file_details.faces[face_pos].override.who
else else
who=document.viewing.faces[face_pos].who who=document.viewing.file_details.faces[face_pos].refimg.person.tag
d='&face_id='+document.viewing.faces[face_pos].id+'&person_tag='+who+'&file_eid='+current d='&face_id='+document.viewing.file_details.faces[face_pos].id+'&person_tag='+who+'&file_eid='+current
$.ajax({ type: 'POST', data: d, url: '/remove_force_match_override', $.ajax({ type: 'POST', data: d, url: '/remove_force_match_override',
success: function(data) { success: function(data) {
delete document.viewing.faces[face_pos].override delete document.viewing.file_details.faces[face_pos].override
$('#dbox').modal('hide') $('#dbox').modal('hide')
DrawImg() DrawImg()
CheckForJobs() CheckForJobs()
@@ -389,10 +392,10 @@ function RemoveOverrideForceMatch(face_pos)
function RemoveOverrideNoMatch(face_pos, type_id) function RemoveOverrideNoMatch(face_pos, type_id)
{ {
d='&face_id='+document.viewing.faces[face_pos].id+'&type_id='+type_id d='&face_id='+document.viewing.file_details.faces[face_pos].id+'&type_id='+type_id
$.ajax({ type: 'POST', data: d, url: '/remove_no_match_override', $.ajax({ type: 'POST', data: d, url: '/remove_no_match_override',
success: function(data) { success: function(data) {
delete document.viewing.faces[face_pos].override delete document.viewing.file_details.faces[face_pos].override
$('#dbox').modal('hide') $('#dbox').modal('hide')
DrawImg() DrawImg()
CheckForJobs() CheckForJobs()
@@ -407,11 +410,11 @@ function AddNoMatchOverride(type_id, face_id, face_pos, type_id)
d='&type_id='+type_id+'&face_id='+face_id d='&type_id='+type_id+'&face_id='+face_id
$.ajax({ type: 'POST', data: d, url: '/add_no_match_override', $.ajax({ type: 'POST', data: d, url: '/add_no_match_override',
success: function(data) { success: function(data) {
document.viewing.faces[face_pos].override={} document.viewing.file_details.faces[face_pos].override={}
document.viewing.faces[face_pos].override.who=NMO[type_id].name document.viewing.file_details.faces[face_pos].override.who=NMO[type_id].name
document.viewing.faces[face_pos].override.distance='N/A' document.viewing.file_details.faces[face_pos].override.distance='N/A'
document.viewing.faces[face_pos].override.type_id=type_id document.viewing.file_details.faces[face_pos].override.type_id=type_id
document.viewing.faces[face_pos].override.type_name=NMO[type_id].name document.viewing.file_details.faces[face_pos].override.type_name=NMO[type_id].name
$('#dbox').modal('hide') $('#dbox').modal('hide')
$('#faces').prop('checked',true) $('#faces').prop('checked',true)
DrawImg() DrawImg()
@@ -459,17 +462,17 @@ function FaceDBox(key, item)
div+='</div><div class="col-6">' div+='</div><div class="col-6">'
if ( key == 'remove_force_match_override' ) if ( key == 'remove_force_match_override' )
{ {
if( document.viewing.faces[face_pos].override.type_name == 'Manual match to existing person' ) if( document.viewing.file_details.faces[face_pos].override.type_name == 'Manual match to existing person' )
div+='<div class="row col-12">remove this override (force match to: ' + document.viewing.faces[face_pos].override.who + ')</div>' div+='<div class="row col-12">remove this override (force match to: ' + document.viewing.file_details.faces[face_pos].override.who + ')</div>'
else else
div+='<div class="row col-12">remove this override (no match)</div>' div+='<div class="row col-12">remove this override (no match)</div>'
div+='<div class="row">' div+='<div class="row">'
div+='<button class="btn btn-outline-info col-6" type="button" onClick="$(\'#dbox\').modal(\'hide\'); return false">Cancel</button>' div+='<button class="btn btn-outline-info col-6" type="button" onClick="$(\'#dbox\').modal(\'hide\'); return false">Cancel</button>'
div+='<button class="btn btn-outline-danger col-6" type="button" ' div+='<button class="btn btn-outline-danger col-6" type="button" '
if( document.viewing.faces[face_pos].override.type_name == 'Manual match to existing person' ) if( document.viewing.file_details.faces[face_pos].override.type_name == 'Manual match to existing person' )
div+='onClick="RemoveOverrideForceMatch(' +face_pos+ ')">Remove</button>' div+='onClick="RemoveOverrideForceMatch(' +face_pos+ ')">Remove</button>'
else else
div+='onClick="RemoveOverrideNoMatch(' +face_pos+','+document.viewing.faces[face_pos].override.type_id+ ')">Remove</button>' div+='onClick="RemoveOverrideNoMatch(' +face_pos+','+document.viewing.file_details.faces[face_pos].override.type_id+ ')">Remove</button>'
div+='</div>' div+='</div>'
} }
if ( key == 'no_match_new_person' ) if ( key == 'no_match_new_person' )