fix indir/outdir bug
This commit is contained in:
parent
8efd2767d7
commit
9ad9cbab6a
@ -14,16 +14,18 @@ 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.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
class yoloserv(object):
|
class yoloserv(object):
|
||||||
|
|
||||||
|
READY = 0
|
||||||
|
BUSY = 1
|
||||||
|
OVERRUN = 5
|
||||||
yolo = None
|
yolo = None
|
||||||
device = None
|
device = None
|
||||||
imgdir = None
|
indir = None
|
||||||
outdir = None
|
outdir = None
|
||||||
facedetector = None
|
facedetector = None
|
||||||
lifedetector = None
|
lifedetector = 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,10 +50,8 @@ 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.imgdir = self.conf["yolo_indir"]
|
|
||||||
self.outdir = self.conf["yolo_outdir"]
|
|
||||||
|
|
||||||
# Object (face) matching
|
# Object (face) matching
|
||||||
if "paravision" in self.devices:
|
if "paravision" in self.devices:
|
||||||
@ -84,9 +84,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()
|
||||||
@ -108,13 +107,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:
|
||||||
@ -160,7 +159,7 @@ class yoloserv(object):
|
|||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def svc_detect_faces(self,infile):
|
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)
|
return '{ "status":0, "remark":"found faces", "count":%d }' % (nfaces)
|
||||||
|
|
||||||
# Find the most prominent object
|
# Find the most prominent object
|
||||||
@ -269,18 +268,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):
|
||||||
@ -360,13 +359,14 @@ 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])
|
||||||
imgdir = sys.argv[2]
|
|
||||||
outdir = sys.argv[3]
|
|
||||||
|
|
||||||
# Initialise the webserver
|
# Initialise the webserver
|
||||||
s = yoloserv()
|
s = yoloserv()
|
||||||
s.initialise()
|
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',
|
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