added delete
This commit is contained in:
parent
9e5d0bf889
commit
94d1c1156f
|
|
@ -38,6 +38,7 @@ class PersonList(Resource):
|
|||
for x in data:
|
||||
arr.append(x.serialize())
|
||||
session.close()
|
||||
fr.initFaceRec()
|
||||
return flask.make_response(flask.jsonify({'data': arr}), 201)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ def initFaceRec():
|
|||
dlib.DLIB_USE_CUDA=True
|
||||
print('Loading known faces...', dlib.DLIB_USE_CUDA)
|
||||
session = Session()
|
||||
# We oranize known faces as subfolders of KNOWN_FACES_DIR
|
||||
# Each subfolder's name becomes our label (name)
|
||||
for face, name in session.query(Person.face, Person.person_id).all():
|
||||
# Load an image
|
||||
nparr = np.fromstring(base64.b64decode(face), np.uint8)
|
||||
|
|
@ -41,7 +39,7 @@ def identifyFace(image):
|
|||
print('Identifying Face')
|
||||
nparr = np.fromstring(base64.b64decode(image), np.uint8)
|
||||
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
|
||||
#image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
||||
|
||||
locations = face_recognition.face_locations(image, model=MODEL)
|
||||
encodings = face_recognition.face_encodings(image, locations)
|
||||
|
||||
|
|
|
|||
|
|
@ -44,3 +44,16 @@ function postJSON(url, data, callback, fallback) {
|
|||
};
|
||||
xhr.send(data);
|
||||
};
|
||||
function deleteJSON(url, callback, fallback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('DELETE', url, false);
|
||||
xhr.onload = function () {
|
||||
var status = xhr.status;
|
||||
if (status < 400) {
|
||||
callback(null, xhr.response);
|
||||
} else {
|
||||
fallback();
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
|
|
@ -44,6 +44,7 @@
|
|||
width: 9rem;
|
||||
margin:0;
|
||||
padding:0;
|
||||
overflow: auto;
|
||||
}
|
||||
.card{
|
||||
margin-top:1rem;
|
||||
|
|
@ -76,7 +77,10 @@
|
|||
width:100%;
|
||||
|
||||
}
|
||||
|
||||
.card-text{
|
||||
overflow: contain;
|
||||
display: block;
|
||||
}
|
||||
.heroInfo{
|
||||
|
||||
}
|
||||
|
|
@ -94,6 +98,11 @@
|
|||
padding:0;
|
||||
}
|
||||
#middle-right .listIMG{
|
||||
width: 10rem;
|
||||
width: 15rem;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.btn-delete{
|
||||
float: right;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ selected = null
|
|||
var ml = document.getElementById('middle-left');
|
||||
var mr = document.getElementById('middle-right');
|
||||
personData = {}
|
||||
|
||||
state = null
|
||||
/**
|
||||
* Retrieves input data from a form and returns it as a JSON object.
|
||||
* @param {HTMLFormControlsCollection} elements the form elements
|
||||
|
|
@ -25,7 +25,7 @@ function focusPerson(id) {
|
|||
selected = id;
|
||||
$("#person" + id).removeClass('border-light').siblings().addClass('border-light')
|
||||
$("#person" + id).addClass('border-success').siblings().removeClass('border-success')
|
||||
renderPersonRight()
|
||||
|
||||
}
|
||||
|
||||
function loadPersonList(data) {
|
||||
|
|
@ -44,8 +44,7 @@ function loadPersonList(data) {
|
|||
<div class="personalInfo">
|
||||
Gender: ${item["gender"]} <br>
|
||||
YoB: ${item["yob"]} <br>
|
||||
Available FP: ${item["fingerprints"].length} <br>
|
||||
|
||||
<button type="button" class="btn btn-danger btn-delete" onclick="deletePerson(${item["person_id"]})">Delete</button>
|
||||
</div>
|
||||
|
||||
</p>
|
||||
|
|
@ -76,10 +75,10 @@ function enrole(){
|
|||
data = {"person": data}
|
||||
console.log(data)
|
||||
postJSON(rootKontext + "/api/v1/person/", JSON.stringify(data),
|
||||
function(){
|
||||
location.reload()
|
||||
},
|
||||
null
|
||||
function(){
|
||||
location.reload()
|
||||
},
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -137,3 +136,10 @@ function loadData() {
|
|||
);
|
||||
}
|
||||
|
||||
function deletePerson(id){
|
||||
deleteJSON(rootKontext + "/api/v1/person/"+id,
|
||||
function(){
|
||||
location.reload()
|
||||
},
|
||||
null)
|
||||
}
|
||||
BIN
test.sqlite
BIN
test.sqlite
Binary file not shown.
Loading…
Reference in New Issue