class RealsenseStream(Thread): """ Realsense D415 Streamer Class Realsense D415 streamer functions for EMAR Mini Emergency Assistance Robot. """ def __init__(self): """ Initializes the class. """ super(RealsenseStream, self).__init__() self.Helpers = Helpers("Realsense D415 Streamer") self.Helpers.logger.info( "Realsense D415 Streamer Helper Class initialization complete.") def run(self): """ Runs the module. """ global capture # Allows time for socket server to start self.Helpers.logger.info( "Realsense D415 Streamer waiting 2 seconds for CamRead socket server." ) time.sleep(2) self.Helpers.logger.info("Realsense D415 Streamer continuing.") # Starts the socket module self.Socket = Socket("Realsense D415 Streamer") # Subscribes to the socket server capture = self.Socket.subscribe( self.Helpers.confs["EMAR"]["ip"], self.Helpers.confs["Realsense"]["socket"]["port"]) try: # Starts web server server = ThreadedHTTPServer( (self.Helpers.confs["EMAR"]["ip"], self.Helpers.confs["Realsense"]["server"]["port"]), CamHandler) self.Helpers.logger.info( "Realsense D415 Streamer server started on http://" + self.Helpers.confs["EMAR"]["ip"] + ":" + str(self.Helpers.confs["Realsense"]["server"]["port"])) server.serve_forever() except KeyboardInterrupt: # Closes socket server capture.close() exit()
class CamStream(Thread): """ CamStream Class The CamStream Class streams the processed frame to a local server. """ def __init__(self): """ Initializes the class. """ super(CamStream, self).__init__() self.Helpers = Helpers("CamStream") self.Helpers.logger.info( "CamStream Helper Class initialization complete.") def run(self): """ Runs the module. """ global capture # Allows time for socket server to start self.Helpers.logger.info( "CamStream waiting 2 seconds for CamRead socket server.") time.sleep(2) self.Helpers.logger.info("CamStream continuing.") # Starts the socket module self.Socket = Socket("CamStream") # Subscribes to the socket server capture = self.Socket.subscribe( self.Helpers.confs["tass"]["socket"]["ip"], self.Helpers.confs["tass"]["socket"]["port"]) try: # Starts web server server = ThreadedHTTPServer((self.Helpers.confs["tass"]["ip"], self.Helpers.confs["tass"]["port"]), CamHandler) self.Helpers.logger.info("Stream server started on http://" + self.Helpers.confs["tass"]["ip"] + ":" + str(self.Helpers.confs["tass"]["port"])) server.serve_forever() except KeyboardInterrupt: # Closes socket server capture.close() exit()