actual image is now processed
This commit is contained in:
parent
8e1f765c52
commit
70616b7f94
|
|
@ -37,7 +37,7 @@ class PersonList(Resource):
|
||||||
arr = []
|
arr = []
|
||||||
for x in data:
|
for x in data:
|
||||||
arr.append(x.serialize())
|
arr.append(x.serialize())
|
||||||
|
session.close()
|
||||||
return flask.make_response(flask.jsonify({'data': arr}), 201)
|
return flask.make_response(flask.jsonify({'data': arr}), 201)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -46,15 +46,17 @@ class PersonList(Resource):
|
||||||
|
|
||||||
def get(self, id = None):
|
def get(self, id = None):
|
||||||
""" """
|
""" """
|
||||||
|
session = Session()
|
||||||
try:
|
try:
|
||||||
parser = reqparse.RequestParser()
|
parser = reqparse.RequestParser()
|
||||||
parser.add_argument('useFace', type=bool, required=False)
|
parser.add_argument('useFace', type=bool, required=False)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
session = Session()
|
|
||||||
|
|
||||||
# this indicates that the captured face should be use for identification / validation
|
# this indicates that the captured face should be use for identification / validation
|
||||||
if "useFace" in args and args["useFace"]:
|
if "useFace" in args and args["useFace"]:
|
||||||
|
Camera().post()
|
||||||
if id is not None:
|
if id is not None:
|
||||||
# validate
|
# validate
|
||||||
data = list(session.query(Person).filter_by(person_id=id))[0].serialize()
|
data = list(session.query(Person).filter_by(person_id=id))[0].serialize()
|
||||||
|
|
@ -82,9 +84,11 @@ class PersonList(Resource):
|
||||||
arr = []
|
arr = []
|
||||||
for x in data:
|
for x in data:
|
||||||
arr.append(x.serialize())
|
arr.append(x.serialize())
|
||||||
|
session.close()
|
||||||
|
|
||||||
return flask.make_response(flask.jsonify({'data': arr}), 200)
|
return flask.make_response(flask.jsonify({'data': arr}), 200)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
session.close()
|
||||||
print("error: -", e)
|
print("error: -", e)
|
||||||
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
|
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
|
||||||
|
|
||||||
|
|
@ -106,7 +110,7 @@ class PersonList(Resource):
|
||||||
session = Session()
|
session = Session()
|
||||||
data = session.query(Person).filter_by(person_id=id).delete()
|
data = session.query(Person).filter_by(person_id=id).delete()
|
||||||
session.commit()
|
session.commit()
|
||||||
|
session.close()
|
||||||
return flask.make_response(flask.jsonify({'data': data}), 204)
|
return flask.make_response(flask.jsonify({'data': data}), 204)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -114,10 +118,7 @@ class PersonList(Resource):
|
||||||
return flask.make_response(flask.jsonify({'error': str(e)}), 404)
|
return flask.make_response(flask.jsonify({'error': str(e)}), 404)
|
||||||
|
|
||||||
class Camera(Resource):
|
class Camera(Resource):
|
||||||
|
# provides the function used for the live streams
|
||||||
|
|
||||||
|
|
||||||
# provides th function used for the live streams
|
|
||||||
class VideoCamera(object):
|
class VideoCamera(object):
|
||||||
"""Video stream object"""
|
"""Video stream object"""
|
||||||
url = "http://192.168.178.56:8080/video"
|
url = "http://192.168.178.56:8080/video"
|
||||||
|
|
@ -132,7 +133,6 @@ class Camera(Resource):
|
||||||
ret, jpeg = cv2.imencode(ending, image)
|
ret, jpeg = cv2.imencode(ending, image)
|
||||||
return jpeg
|
return jpeg
|
||||||
|
|
||||||
|
|
||||||
def gen(self, camera):
|
def gen(self, camera):
|
||||||
"""Video streaming generator function."""
|
"""Video streaming generator function."""
|
||||||
while True:
|
while True:
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,18 @@ def initFaceRec():
|
||||||
known_faces.append(encoding)
|
known_faces.append(encoding)
|
||||||
known_names.append(name)
|
known_names.append(name)
|
||||||
|
|
||||||
def identifyFace(imgage):
|
session.close()
|
||||||
print('Processing unknown faces...')
|
|
||||||
image = face_recognition.load_image_file('C:/Users/ofjok/Desktop/1.png')
|
|
||||||
|
|
||||||
|
def identifyFace(image):
|
||||||
|
print('Processing unknown faces...')
|
||||||
|
#image = face_recognition.load_image_file('C:/Users/ofjok/Desktop/1.png')
|
||||||
|
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)
|
locations = face_recognition.face_locations(image, model=MODEL)
|
||||||
encodings = face_recognition.face_encodings(image, locations)
|
encodings = face_recognition.face_encodings(image, locations)
|
||||||
|
|
||||||
|
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
|
|
||||||
|
|
@ -80,5 +83,5 @@ def identifyFace(imgage):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
initFaceRec()
|
|
||||||
identifyFace("")
|
#identifyFace("")
|
||||||
Loading…
Reference in New Issue