sync with xtian
This commit is contained in:
parent
65e2394602
commit
c6af086495
11
sbin/ctl.sh
11
sbin/ctl.sh
@ -44,6 +44,8 @@ chmod +x var/gen.ukdi
|
|||||||
export ZZZ=5
|
export ZZZ=5
|
||||||
export UKDIHOST=`echo $UKDI_ukdi|tr '/:,' ' '| awk '{print $2}'`
|
export UKDIHOST=`echo $UKDI_ukdi|tr '/:,' ' '| awk '{print $2}'`
|
||||||
export UKDIPORT=`echo $UKDI_ukdi|tr '/:,' ' '| awk '{print $3}'`
|
export UKDIPORT=`echo $UKDI_ukdi|tr '/:,' ' '| awk '{print $3}'`
|
||||||
|
export YOLOHOST=`echo $UKDI_yolo|tr '/:,' ' '| awk '{print $2}'`
|
||||||
|
export YOLOPORT=`echo $UKDI_yolo|tr '/:,' ' '| awk '{print $3}'`
|
||||||
export CORE=$PWD/../core
|
export CORE=$PWD/../core
|
||||||
export UKDI=$PWD/../ukdi
|
export UKDI=$PWD/../ukdi
|
||||||
export YOLO=$PWD/../yoloserv
|
export YOLO=$PWD/../yoloserv
|
||||||
@ -57,7 +59,6 @@ EOF
|
|||||||
}
|
}
|
||||||
f_read_ukdi
|
f_read_ukdi
|
||||||
|
|
||||||
PORT=8099
|
|
||||||
ZZZ=5
|
ZZZ=5
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ echo "UKDI_yolo_devices = $UKDI_yolo_devices"
|
|||||||
for i in `echo $UKDI_yolo_devices| tr ',' ' '`
|
for i in `echo $UKDI_yolo_devices| tr ',' ' '`
|
||||||
do
|
do
|
||||||
case $i in
|
case $i in
|
||||||
"para_facematch") LLP="$LLP:$LIB_OPENVINO"
|
"paravision") LLP="$LLP:$LIB_OPENVINO"
|
||||||
PYP="$PYP:$PYP_OPENVINO:$PYP_PARAVISION"
|
PYP="$PYP:$PYP_OPENVINO:$PYP_PARAVISION"
|
||||||
;;
|
;;
|
||||||
"yolov5") LLP="$LLP:$LIB_OPENVINO"
|
"yolov5") LLP="$LLP:$LIB_OPENVINO"
|
||||||
@ -180,7 +181,7 @@ function f_apt_intox(){
|
|||||||
#### #### # # # # # #### ######
|
#### #### # # # # # #### ######
|
||||||
|
|
||||||
function f_test(){
|
function f_test(){
|
||||||
wget http://localhost:$PORT/process/
|
wget http://localhost:$YOLOPORT/process/
|
||||||
}
|
}
|
||||||
|
|
||||||
function f_start(){
|
function f_start(){
|
||||||
@ -189,14 +190,14 @@ function f_start(){
|
|||||||
echo $$ > var/yoloserv.pid
|
echo $$ > var/yoloserv.pid
|
||||||
while [ -e var/yoloserv.pid ]
|
while [ -e var/yoloserv.pid ]
|
||||||
do
|
do
|
||||||
python3 src/yoloserv.py $PORT $UKDI_yolo_indir $UKDI_yolo_outdir $WEIGHTS
|
python3 src/yoloserv.py $YOLOPORT $UKDI_yolo_indir $UKDI_yolo_outdir $WEIGHTS
|
||||||
sleep $ZZZ
|
sleep $ZZZ
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function f_stop(){
|
function f_stop(){
|
||||||
rm var/yoloserv.pid
|
rm var/yoloserv.pid
|
||||||
wget http://localhost:$PORT/shutdown
|
wget http://localhost:$YOLOPORT/shutdown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
#
|
#
|
||||||
# Paravision based face matcher
|
# Paravision based face matcher
|
||||||
#
|
#
|
||||||
|
import json
|
||||||
|
|
||||||
from paravision.recognition.exceptions import ParavisionException
|
from paravision.recognition.exceptions import ParavisionException
|
||||||
from paravision.recognition.engine import Engine
|
from paravision.recognition.engine import Engine
|
||||||
from paravision.recognition.sdk import SDK
|
from paravision.recognition.sdk import SDK
|
||||||
|
import paravision.recognition.utils as pru
|
||||||
#from openvino.inference_engine import Engineq
|
#from openvino.inference_engine import Engineq
|
||||||
|
|
||||||
#from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace, DeepID
|
#from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace, DeepID
|
||||||
@ -21,7 +23,7 @@ class Facematch(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Read an image from a file
|
# Read an image from a file
|
||||||
def load(self, imgpath):
|
def loadiii(self, imgpath):
|
||||||
if not os.path.exists(imgpath):
|
if not os.path.exists(imgpath):
|
||||||
print("File not found ",imgpath)
|
print("File not found ",imgpath)
|
||||||
return False
|
return False
|
||||||
@ -31,7 +33,7 @@ class Facematch(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# Assess the face that was read in
|
# Assess the face that was read in
|
||||||
def process(self):
|
def processiii(self):
|
||||||
# Get all faces metadata
|
# Get all faces metadata
|
||||||
print("Finding faces in %s" %(self.imgpath))
|
print("Finding faces in %s" %(self.imgpath))
|
||||||
faces = self.sdk.get_faces([self.image], qualities=True, landmarks=True, embeddings=True)
|
faces = self.sdk.get_faces([self.image], qualities=True, landmarks=True, embeddings=True)
|
||||||
@ -57,15 +59,17 @@ class Facematch(object):
|
|||||||
|
|
||||||
#
|
#
|
||||||
def load(self, dev1, dev2, id_image_filepath, photo_image_filepath):
|
def load(self, dev1, dev2, id_image_filepath, photo_image_filepath):
|
||||||
|
print("## loading images", dev1, dev2)
|
||||||
self.dev1 = dev1
|
self.dev1 = dev1
|
||||||
self.dev2 = dev2
|
self.dev2 = dev2
|
||||||
try:
|
try:
|
||||||
# Load images
|
# Load images
|
||||||
self.id_image = load_image(id_image_filepath)
|
self.id_image = pru.load_image(id_image_filepath)
|
||||||
self.photo_image = load_image(photo_image_filepath)
|
self.photo_image = pru.load_image(photo_image_filepath)
|
||||||
print("++++++++++++++++ ",self.id_image)
|
print("++++++++++++++++ ",self.id_image)
|
||||||
return True
|
return True
|
||||||
except:
|
except Exception as e:
|
||||||
|
print("uk oh loading failed ", e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,13 +25,13 @@ class yoloserv(object):
|
|||||||
device = None
|
device = None
|
||||||
imgdir = None
|
imgdir = None
|
||||||
outdir = None
|
outdir = None
|
||||||
face_detector = None
|
facedetector = None
|
||||||
life_detector = None
|
lifedetector = None
|
||||||
palm_detector = None
|
palmdetector = None
|
||||||
face_matcher = None
|
facematcher = None
|
||||||
palm_matcher = None
|
palmmatcher = None
|
||||||
ir_camera = None
|
ir_camera = None
|
||||||
|
devices = []
|
||||||
points = []
|
points = []
|
||||||
|
|
||||||
|
|
||||||
@ -47,59 +47,60 @@ class yoloserv(object):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
with open("/etc/ukdi.json","r") as f:
|
with open("/etc/ukdi.json","r") as f:
|
||||||
self.conf = json.loads(f.read())
|
self.conf = json.loads(f.read())
|
||||||
|
|
||||||
print("Init yoloserv: %s @ %s %s " % (self.conf["yolo_devices"], self.conf["yolo_indir"], self.conf["yolo_outdir"]) )
|
print("Init yoloserv: %s @ %s %s " % (self.conf["yolo_devices"], self.conf["yolo_indir"], self.conf["yolo_outdir"]) )
|
||||||
self.device_list = self.conf["yolo_devices"].split(",")
|
self.devices = self.conf["yolo_devices"].split(",")
|
||||||
self.imgdir = self.conf["yolo_indir"]
|
self.imgdir = self.conf["yolo_indir"]
|
||||||
self.outdir = self.conf["yolo_outdir"]
|
self.outdir = self.conf["yolo_outdir"]
|
||||||
|
|
||||||
# Object (face) matching
|
# Object (face) matching
|
||||||
if "para_facematch" in self.device_list:
|
if "paravision" in self.devices:
|
||||||
print("Loading paravision facematch...")
|
print("Loading paravision facematch...")
|
||||||
from para_facematch import Facematch
|
from para_facematch import Facematch
|
||||||
self.facematcher = Facematch()
|
self.facematcher = Facematch()
|
||||||
self.facematcher.init()
|
self.facematcher.init()
|
||||||
|
|
||||||
# Image acquisition
|
# Image acquisition
|
||||||
if "camera" in self.device_list:
|
if "camera" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading YUV standard camera...")
|
print("AAAAAAAAAAA Loading YUV standard camera...")
|
||||||
from camera import Camera
|
from camera import Camera
|
||||||
self.camera = Camera()
|
self.camera = Camera()
|
||||||
self.camera.init()
|
self.camera.init()
|
||||||
if "seek" in self.device_list:
|
if "seek" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading seek IR... [NOT YET IMPLEMETED]")
|
print("AAAAAAAAAAA Loading seek IR... [NOT YET IMPLEMETED]")
|
||||||
self.ircamera = Seek()
|
self.ircamera = Seek()
|
||||||
self.ircamera.init()
|
self.ircamera.init()
|
||||||
if "flir" in self.device_list:
|
if "flir" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading flir IR... [NOT YET IMPLEMETED]")
|
print("AAAAAAAAAAA Loading flir IR... [NOT YET IMPLEMETED]")
|
||||||
self.ircamera = Flir()
|
self.ircamera = Flir()
|
||||||
self.ircamera.init()
|
self.ircamera.init()
|
||||||
if "fjpalmvein" in self.device_list:
|
if "fjpalmvein" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading fjpalmvein... [NOT YET IMPLEMETED]")
|
print("AAAAAAAAAAA Loading fjpalmvein... [NOT YET IMPLEMETED]")
|
||||||
self.palmvein = self.FJPalmvein()
|
self.palmvein = self.FJPalmvein()
|
||||||
self.palmvein.init()
|
self.palmvein.init()
|
||||||
|
|
||||||
# Simple processing with opencv
|
# Simple processing with opencv
|
||||||
if "opencv" in self.device_list:
|
if "opencv" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading opencv...")
|
print("AAAAAAAAAAA Loading opencv...")
|
||||||
from opencv import OpenCV
|
from opencv import OpenCV
|
||||||
self.opencv = OpenCV()
|
self.opencv = OpenCV()
|
||||||
self.opencv.init()
|
self.opencv.init()
|
||||||
|
|
||||||
# Object detection
|
# Object detection
|
||||||
if "yolov5" in self.device_list:
|
if "yolov5" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading yolov5 object detection...")
|
print("AAAAAAAAAAA Loading yolov5 object detection...")
|
||||||
from yolov5 import Yolov5
|
from yolov5 import Yolov5
|
||||||
self.detector = Yolov5()
|
self.detector = Yolov5()
|
||||||
#self.detector.init(self.conf["yolo_indir"],self.conf["yolo_outdir"])
|
#self.detector.init(self.conf["yolo_indir"],self.conf["yolo_outdir"])
|
||||||
|
|
||||||
if "yolov8" in self.device_list:
|
if "yolov8" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading yolov8 object detection...")
|
print("AAAAAAAAAAA Loading yolov8 object detection...")
|
||||||
from yolov8 import Yolov8
|
from yolov8 import Yolov8
|
||||||
self.detector = Yolov8()
|
self.detector = Yolov8()
|
||||||
#self.detector.init(self.conf["yolo_indir"],self.conf["yolo_outdir"])
|
#self.detector.init(self.conf["yolo_indir"],self.conf["yolo_outdir"])
|
||||||
|
|
||||||
# Intoxication
|
# Intoxication
|
||||||
if "intox" in self.device_list:
|
if "intox" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading intoxivision...")
|
print("AAAAAAAAAAA Loading intoxivision...")
|
||||||
self.intox_detector = Intox()
|
self.intox_detector = Intox()
|
||||||
self.intox_detector.init()
|
self.intox_detector.init()
|
||||||
@ -158,10 +159,12 @@ class yoloserv(object):
|
|||||||
print ("Shutdown on client action")
|
print ("Shutdown on client action")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def facematch(self,dev1,dev2):
|
def facematch(self,dev1,dev2):
|
||||||
|
if self.facematcher is None:
|
||||||
|
return '{ "status":777244, "remark":"suitable yolo_device" }'
|
||||||
|
|
||||||
if self.conf["emulate_facematch"]:
|
if self.conf["emulate_facematch"]:
|
||||||
return '{ "status":0, "remark":"OK(Emulated)", "data":{"device1":"%s","device2":"%s","device1_qual":123,"device2_qual":234,"match_score":600} }' % (dev1,dev2)
|
return '{ "status":0, "remark":"OK(Emulated)", "data":{"device1":"%s","device2":"%s","device1_qual":123,"device2_qual":234,"match_score":600} }' % (dev1,dev2)
|
||||||
|
|
||||||
@ -176,21 +179,19 @@ class yoloserv(object):
|
|||||||
if self.conf["emulate_facematch"]:
|
if self.conf["emulate_facematch"]:
|
||||||
return '{ "status":0, "remark":"OK", "data":{} }'
|
return '{ "status":0, "remark":"OK", "data":{} }'
|
||||||
|
|
||||||
self.devices["facematch"].load(dev1, dev2, img1, img2)
|
self.facematcher.load(dev1, dev2, img1, img2)
|
||||||
status = self.devices["facematch"].get_faces()
|
status = self.facematcher.get_faces()
|
||||||
if status is not None:
|
if status is not None:
|
||||||
return '{ "status":777242, "remark":"face matching failed", "guilty_param":"facematch", "guilty_value":"%s" }' % (status)
|
return '{ "status":777242, "remark":"face matching failed", "guilty_param":"facematch", "guilty_value":"%s" }' % (status)
|
||||||
|
|
||||||
status = self.devices["facematch"].compute_scores()
|
status = self.facematcher.compute_scores()
|
||||||
if status is not None:
|
if status is not None:
|
||||||
return '{ "status":777243, "remark":"face scoring failed", "guilty_param":"facematch", "guilty_value":"%s" }' % (status)
|
return '{ "status":777243, "remark":"face scoring failed", "guilty_param":"facematch", "guilty_value":"%s" }' % (status)
|
||||||
|
|
||||||
jsonstr = self.devices["facematch"].get_scores()
|
jsonstr = self.facematcher.get_scores()
|
||||||
return '{ "status":0, "remark":"OK", "data":%s }' % (jsonstr)
|
return '{ "status":0, "remark":"OK", "data":%s }' % (jsonstr)
|
||||||
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 201133f7dac541fb5a6f52d727b994cc8799a6ee
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user