This commit is contained in:
2022-08-26 11:30:18 +02:00
parent 559cd7367f
commit 66686e7740
2 changed files with 24 additions and 23 deletions
+23 -22
View File
@@ -108,48 +108,49 @@ def dont_exit(status):
sys.exit = dont_exit
DEFAULT_PIPELINE_PORT = 5005
stop_event = None
parameter_queue = None
statistics =None
current_pipeline = None
PIPELINE_DEFAULT_PORT = 5005
pipeline_stop_event = None
pipeline_queue = None
pipeline_statistics =None
pipeline_name = None
pipeline_port = None
pipeline_thread = None
def start_pipeline(name, parameters, port=DEFAULT_PIPELINE_PORT):
global stop_event, parameter_queue, statistics, current_pipeline, parameter_queue, statistics, pipeline_port
def start_pipeline(name, parameters, port=PIPELINE_DEFAULT_PORT):
global pipeline_stop_event, pipeline_queue, pipeline_statistics, current_pipeline, pipeline_port, pipeline_thread
if name is None:
raise Exception("Pipeline name undefined")
stop_pipeline();
current_pipeline = name
pipeline_name = name
pipeline_port = port
stop_event = threading.Event()
parameter_queue = queue.Queue()
statistics = Namespace()
pipeline_stop_event = threading.Event()
pipeline_queue = queue.Queue()
pipeline_statistics = Namespace()
pipeline_config = PipelineConfig(name, parameters=parameters)
def send(port):
print ("Startint pipeline ", name, " on port: ", port)
try:
processing_pipeline(stop_event, statistics, parameter_queue, camera_client, pipeline_config, port, MockBackgroundManager())
processing_pipeline(pipeline_stop_event, pipeline_statistics, pipeline_queue, camera_client, pipeline_config, port, MockBackgroundManager())
except:
traceback.print_exc()
thread = Thread(target=send, args=(port,))
thread.start()
pipeline_thread = Thread(target=send, args=(port,))
pipeline_thread.start()
def stop_pipeline():
global stop_event, parameter_queue, statistics
global pipeline_stop_event, pipeline_queue, pipeline_statistics, pipeline_thread, pipeline_name
if get_pipeline():
try:
stop_event.set()
thread.join(5.0)
pipeline_stop_event.set()
pipeline_thread.join(5.0)
except:
traceback.print_exc()
current_pipeline = None
stop_event = None
parameter_queue = None
statistics =None
pipeline_name = None
pipeline_stop_event = None
pipeline_queue = None
pipeline_statistics =None
def get_pipeline():
return current_pipeline
return pipeline_name
def get_pipeline_msg():
if not get_pipeline():
+1 -1
View File
@@ -1,5 +1,5 @@
viewer.show_stream("tcp://localhost:" + str(DEFAULT_PIPELINE_PORT))
viewer.show_stream("tcp://localhost:" + str(PIPELINE_DEFAULT_PORT))
pipeline_config = PipelineConfig("test_pipeline", parameters={"camera_name": "simulation", "function":"transparent"})
start_pipeline("test_pipeline", {"camera_name": "simulation", "function":"transparent"})