fix indir/outdir bug

This commit is contained in:
carl 2024-08-22 12:55:02 +00:00
parent 8efd2767d7
commit 9ad9cbab6a

View File

@ -14,16 +14,18 @@ import copy
import numpy
# Yoloserv contains references to a number of packages that do different things.
#
#
class yoloserv(object):
READY = 0
BUSY = 1
OVERRUN = 5
yolo = None
device = None
imgdir = None
indir = None
outdir = None
facedetector = None
lifedetector = None
@ -33,7 +35,7 @@ class yoloserv(object):
ir_camera = None
devices = []
points = []
state = "READY"
# Nature of init depends on the required algotithms listed in /etc/ukdi.conf
# eg :: "yolo_devices": "detect_face,facematch"
@ -48,10 +50,8 @@ class yoloserv(object):
with open("/etc/ukdi.json","r") as f:
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.imgdir = self.conf["yolo_indir"]
self.outdir = self.conf["yolo_outdir"]
# Object (face) matching
if "paravision" in self.devices:
@ -84,9 +84,8 @@ class yoloserv(object):
self.camera = Camera()
self.camera.init()
if "seek" in self.devices:
print("AAAAAAAAAAA Loading seek IR... [NOT YET IMPLEMETED]")
self.ircamera = Seek()
self.ircamera.init()
from seek import Seek
self.seek = Seek()
if "flir" in self.devices:
print("AAAAAAAAAAA Loading flir IR... [NOT YET IMPLEMETED]")
self.ircamera = Flir()
@ -108,13 +107,13 @@ class yoloserv(object):
print("AAAAAAAAAAA Loading yolov5 object detection...")
from yolov5 import 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:
print("AAAAAAAAAAA Loading yolov8 object detection...")
from yolov8 import Yolov8
self.detector = Yolov8()
#self.detector.init(self.conf["yolo_indir"],self.conf["yolo_outdir"])
#self.detector.init(self.indir,self.outdir)
# Intoxication
if "intox" in self.devices:
@ -160,7 +159,7 @@ class yoloserv(object):
@cherrypy.expose
def svc_detect_faces(self,infile):
nfaces = self.facematcher.detect_all(self.imgdir + infile)
nfaces = self.facematcher.detect_all(self.indir + infile)
return '{ "status":0, "remark":"found faces", "count":%d }' % (nfaces)
# Find the most prominent object
@ -269,18 +268,18 @@ class yoloserv(object):
@cherrypy.expose
def irstill(self,ident):
def irstill(self,ident,type="png"):
if self.state == self.BUSY:
return '{ "status":9, "remark":"BUSY" }'
self.state = self.BUSY
self.devices["seek"].open()
self.devices["seek"].hid_read()
self.devices["seek"].close()
self.seek.open()
self.seek.hid_read()
self.seek.close()
self.state = self.READY
f = open("/tmp/%s.bmp" % ident, "wb")
f.write( self.devices["seek"].bmp() )
f = open("/tmp/%s.%s" % (ident,type), "wb")
f.write( self.seek.img(".%s" % type) )
f.close()
return self.devices["seek"].jpg()
return self.seek.png64()
@cherrypy.expose
def yolo(self,ident):
@ -360,13 +359,14 @@ class yoloserv(object):
if __name__ == '__main__':
# Deal with the incoming call parameters
servport = int(sys.argv[1])
imgdir = sys.argv[2]
outdir = sys.argv[3]
# Initialise the webserver
s = yoloserv()
s.initialise()
#s.initialise(imgdir,outdir,weightsfile)
s.indir = sys.argv[2]
s.outdir = sys.argv[3]
#s.initialise(indir,outdir,weightsfile)
cherrypy.config.update({'server.socket_host': '0.0.0.0',
'server.socket_port': servport})
cherrypy.quickstart(s, '/')