Merge branch 'master' of ssh://atlantean.ydns.eu:23/home/disp/git/repos/yoloserv
This commit is contained in:
commit
f2a66d2b98
@ -54,6 +54,8 @@ export YOLO=$PWD/../yoloserv
|
|||||||
cat<<EOF
|
cat<<EOF
|
||||||
UKDIHOST=$UKDIHOST
|
UKDIHOST=$UKDIHOST
|
||||||
UKDIPORT=$UKDIPORT
|
UKDIPORT=$UKDIPORT
|
||||||
|
YOLOHOST=$YOLOHOST
|
||||||
|
YOLOPORT=$YOLOPORT
|
||||||
CORE=$CORE
|
CORE=$CORE
|
||||||
UKDI=$UKDI
|
UKDI=$UKDI
|
||||||
EOF
|
EOF
|
||||||
@ -61,6 +63,8 @@ EOF
|
|||||||
f_read_ukdi
|
f_read_ukdi
|
||||||
|
|
||||||
ZZZ=5
|
ZZZ=5
|
||||||
|
mkdir -p $UKDI_yolo_indir
|
||||||
|
mkdir -p $UKDI_yolo_outdir
|
||||||
|
|
||||||
|
|
||||||
# Determina all the possible libs based on whats in UKDI_yolo_devices
|
# Determina all the possible libs based on whats in UKDI_yolo_devices
|
||||||
@ -72,6 +76,7 @@ modules/openvino/python3.10/dist-packages/openvino/inference_engine"
|
|||||||
PYP_PARAVISION="modules"
|
PYP_PARAVISION="modules"
|
||||||
PYP_DEEPFACE="modules"
|
PYP_DEEPFACE="modules"
|
||||||
PYP_YOLOV5="modules/yolov5-face_Jan1"
|
PYP_YOLOV5="modules/yolov5-face_Jan1"
|
||||||
|
LIB_SEEK="modules/seek/Seekware_SDK_3.6.0.0/lib/x86_64-linux-gnu/"
|
||||||
|
|
||||||
# WHich libs are loaded depends on the YOLO device list
|
# WHich libs are loaded depends on the YOLO device list
|
||||||
LLP="."
|
LLP="."
|
||||||
@ -89,6 +94,9 @@ do
|
|||||||
"deepface") LLP="$LLP:$LIB_DEEPFACE"
|
"deepface") LLP="$LLP:$LIB_DEEPFACE"
|
||||||
PYP="$PYP:$PYP_DEEPFACE"
|
PYP="$PYP:$PYP_DEEPFACE"
|
||||||
;;
|
;;
|
||||||
|
"seek") LLP="$LLP:$LIB_SEEK"
|
||||||
|
PYP="$PYP:src"
|
||||||
|
;;
|
||||||
"face_recognition") LLP="$LLP:$LIB_DEEPFACE"
|
"face_recognition") LLP="$LLP:$LIB_DEEPFACE"
|
||||||
PYP="$PYP:$PYP_DEEPFACE"
|
PYP="$PYP:$PYP_DEEPFACE"
|
||||||
;;
|
;;
|
||||||
|
|||||||
28
src/seek.py
28
src/seek.py
@ -32,15 +32,14 @@ import base64
|
|||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from ukdi import UKDI
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class Seek(UKDI):
|
class Seek():
|
||||||
|
|
||||||
# get this from lsusb -vd VEND:PROD
|
# get this from lsusb -vd VEND:PROD
|
||||||
CAM = None
|
CAM = None
|
||||||
campath = "/home/disp/cam_seek/bin/seek"
|
seekbin = "/home/disp/yoloserv/modules/seek/bin/seek"
|
||||||
X = 1902
|
X = 1902
|
||||||
Y = 1080
|
Y = 1080
|
||||||
min = 0.0
|
min = 0.0
|
||||||
@ -53,7 +52,6 @@ class Seek(UKDI):
|
|||||||
def describe(self):
|
def describe(self):
|
||||||
return "UKDI Seek camera read"
|
return "UKDI Seek camera read"
|
||||||
|
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
# does nothing
|
# does nothing
|
||||||
return
|
return
|
||||||
@ -64,7 +62,7 @@ class Seek(UKDI):
|
|||||||
|
|
||||||
# Red the image from a camera as numpy-ready CSV buffer.
|
# Red the image from a camera as numpy-ready CSV buffer.
|
||||||
def hid_read(self):
|
def hid_read(self):
|
||||||
result = subprocess.run([self.campath], stdout=subprocess.PIPE)
|
result = subprocess.run([self.seekbin], stdout=subprocess.PIPE)
|
||||||
rows = result.stdout.split(b'\n')
|
rows = result.stdout.split(b'\n')
|
||||||
print(rows[0],rows[1],rows[3],rows[4])
|
print(rows[0],rows[1],rows[3],rows[4])
|
||||||
self.X = int(rows[0].decode("utf-8"))
|
self.X = int(rows[0].decode("utf-8"))
|
||||||
@ -78,22 +76,30 @@ class Seek(UKDI):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# return a PNG version of the pic in memory
|
# return a PNG version of the pic in memory
|
||||||
def png(self):
|
def png64(self):
|
||||||
_ , im_arr = cv2.imencode('.png', self.data)
|
_ , im_arr = cv2.imencode('.png', self.data)
|
||||||
img_as_txt = base64.b64encode(im_arr)
|
img_as_txt = base64.b64encode(im_arr)
|
||||||
return b'data:image/png;base64, '+img_as_txt
|
return 'data:image/png;base64, '+img_as_txt.decode()
|
||||||
|
|
||||||
# return a JPG version of the pic in memory
|
# return a JPG version of the pic in memory
|
||||||
def jpg(self):
|
def jpg64(self):
|
||||||
_ , im_arr = cv2.imencode('.jpg', self.data)
|
_ , im_arr = cv2.imencode('.jpg', self.data)
|
||||||
img_as_txt = base64.b64encode(im_arr)
|
img_as_txt = base64.b64encode(im_arr)
|
||||||
return b'data:image/jpeg;base64,'+img_as_txt
|
return 'data:image/jpeg;base64,'+img_as_txt.decode()
|
||||||
|
|
||||||
# return a BMP version of the pic in memory
|
# return a BMP version of the pic in memory
|
||||||
def bmp(self):
|
def bmp64(self):
|
||||||
_ , im_arr = cv2.imencode('.bmp', self.data)
|
_ , im_arr = cv2.imencode('.bmp', self.data)
|
||||||
img_as_txt = base64.b64encode(im_arr)
|
img_as_txt = base64.b64encode(im_arr)
|
||||||
return b'data:image/bmp;base64,'+img_as_txt
|
return 'data:image/bmp;base64,'+img_as_txt.decode()
|
||||||
|
|
||||||
|
|
||||||
|
def img(self,type):
|
||||||
|
_ , im_arr = cv2.imencode(type, self.data)
|
||||||
|
return im_arr
|
||||||
|
|
||||||
|
def numpy(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import cv2
|
|||||||
from numpy import random
|
from numpy import random
|
||||||
import copy
|
import copy
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Yoloserv contains references to a number of packages that do different things.
|
# Yoloserv contains references to a number of packages that do different things.
|
||||||
@ -21,6 +20,9 @@ import numpy
|
|||||||
|
|
||||||
class yoloserv(object):
|
class yoloserv(object):
|
||||||
|
|
||||||
|
READY = 0
|
||||||
|
BUSY = 1
|
||||||
|
OVERRUN = 5
|
||||||
yolo = None
|
yolo = None
|
||||||
device = None
|
device = None
|
||||||
indir = None
|
indir = None
|
||||||
@ -33,7 +35,7 @@ class yoloserv(object):
|
|||||||
ir_camera = None
|
ir_camera = None
|
||||||
devices = []
|
devices = []
|
||||||
points = []
|
points = []
|
||||||
|
state = "READY"
|
||||||
|
|
||||||
# Nature of init depends on the required algotithms listed in /etc/ukdi.conf
|
# Nature of init depends on the required algotithms listed in /etc/ukdi.conf
|
||||||
# eg :: "yolo_devices": "detect_face,facematch"
|
# eg :: "yolo_devices": "detect_face,facematch"
|
||||||
@ -48,7 +50,7 @@ class yoloserv(object):
|
|||||||
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.indir, self.outdir) )
|
||||||
self.devices = self.conf["yolo_devices"].split(",")
|
self.devices = self.conf["yolo_devices"].split(",")
|
||||||
self.indir = self.conf["yolo_indir"]
|
self.indir = self.conf["yolo_indir"]
|
||||||
self.outdir = self.conf["yolo_outdir"]
|
self.outdir = self.conf["yolo_outdir"]
|
||||||
@ -86,9 +88,8 @@ class yoloserv(object):
|
|||||||
self.camera = Camera()
|
self.camera = Camera()
|
||||||
self.camera.init()
|
self.camera.init()
|
||||||
if "seek" in self.devices:
|
if "seek" in self.devices:
|
||||||
print("AAAAAAAAAAA Loading seek IR... [NOT YET IMPLEMETED]")
|
from seek import Seek
|
||||||
self.ircamera = Seek()
|
self.seek = Seek()
|
||||||
self.ircamera.init()
|
|
||||||
if "flir" in self.devices:
|
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()
|
||||||
@ -110,13 +111,13 @@ class yoloserv(object):
|
|||||||
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.indir,self.outdir)
|
||||||
|
|
||||||
if "yolov8" in self.devices:
|
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.indir,self.outdir)
|
||||||
|
|
||||||
# Intoxication
|
# Intoxication
|
||||||
if "intox" in self.devices:
|
if "intox" in self.devices:
|
||||||
@ -174,8 +175,9 @@ class yoloserv(object):
|
|||||||
|
|
||||||
# @doc load images from two files using the specified yoloserv plugin (test OK CG 2024-0724)
|
# @doc load images from two files using the specified yoloserv plugin (test OK CG 2024-0724)
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def svc_load_faces(self,name1,infile1,name2,infile2):
|
def svc_detect_faces(self,infile):
|
||||||
return self.facematcher.load2(name1, self.indir + infile1, name2, self.indir + infile2)
|
nfaces = self.facematcher.detect_all(self.indir + infile)
|
||||||
|
return '{ "status":0, "remark":"found faces", "count":%d }' % (nfaces)
|
||||||
|
|
||||||
# @doc find all the faces in the named image that was loaded using the above calls (test OK CG 2024-0724)
|
# @doc find all the faces in the named image that was loaded using the above calls (test OK CG 2024-0724)
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@ -314,18 +316,18 @@ class yoloserv(object):
|
|||||||
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def irstill(self,ident):
|
def irstill(self,ident,type="png"):
|
||||||
if self.state == self.BUSY:
|
if self.state == self.BUSY:
|
||||||
return '{ "status":9, "remark":"BUSY" }'
|
return '{ "status":9, "remark":"BUSY" }'
|
||||||
self.state = self.BUSY
|
self.state = self.BUSY
|
||||||
self.devices["seek"].open()
|
self.seek.open()
|
||||||
self.devices["seek"].hid_read()
|
self.seek.hid_read()
|
||||||
self.devices["seek"].close()
|
self.seek.close()
|
||||||
self.state = self.READY
|
self.state = self.READY
|
||||||
f = open("/tmp/%s.bmp" % ident, "wb")
|
f = open("/tmp/%s.%s" % (ident,type), "wb")
|
||||||
f.write( self.devices["seek"].bmp() )
|
f.write( self.seek.img(".%s" % type) )
|
||||||
f.close()
|
f.close()
|
||||||
return self.devices["seek"].jpg()
|
return self.seek.png64()
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def yolo(self,ident):
|
def yolo(self,ident):
|
||||||
@ -405,13 +407,13 @@ class yoloserv(object):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Deal with the incoming call parameters
|
# Deal with the incoming call parameters
|
||||||
servport = int(sys.argv[1])
|
servport = int(sys.argv[1])
|
||||||
indir = sys.argv[2]
|
|
||||||
outdir = sys.argv[3]
|
|
||||||
|
|
||||||
# Initialise the webserver
|
# Initialise the webserver
|
||||||
s = yoloserv()
|
s = yoloserv()
|
||||||
s.initialise()
|
s.initialise()
|
||||||
#s.initialise(indir,outdir,weightsfile)
|
s.indir = sys.argv[2]
|
||||||
|
s.outdir = sys.argv[3]
|
||||||
|
|
||||||
cherrypy.config.update({'server.socket_host': '0.0.0.0',
|
cherrypy.config.update({'server.socket_host': '0.0.0.0',
|
||||||
'server.socket_port': servport})
|
'server.socket_port': servport})
|
||||||
cherrypy.quickstart(s, '/')
|
cherrypy.quickstart(s, '/')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user