refactor: remove thread
This commit is contained in:
parent
000dd65054
commit
c8372239d3
@ -32,7 +32,7 @@ def init_mqtt_client(broker_host: str, user: str, password: str, client_id: str)
|
|||||||
client = mqtt.Client(client_id=client_id, clean_session=True, userdata=None, protocol=mqtt.MQTTv311)
|
client = mqtt.Client(client_id=client_id, clean_session=True, userdata=None, protocol=mqtt.MQTTv311)
|
||||||
|
|
||||||
client.username_pw_set(user, password)
|
client.username_pw_set(user, password)
|
||||||
logger.info("Connect to mqtt broker "+ broker_host+ " -> " + user + " / " + password)
|
logger.info("Connect to mqtt broker "+ broker_host)
|
||||||
client.connect(host=broker_host, port=1883, keepalive=60)
|
client.connect(host=broker_host, port=1883, keepalive=60)
|
||||||
logger.info("Connected to mqtt broker")
|
logger.info("Connected to mqtt broker")
|
||||||
return client
|
return client
|
||||||
@ -55,9 +55,7 @@ def execute_from_command_line():
|
|||||||
frame_topic=frame_topic,
|
frame_topic=frame_topic,
|
||||||
img_width=int(get_default_value(args["--image-width"], "IMAGE_WIDTH", 160)),
|
img_width=int(get_default_value(args["--image-width"], "IMAGE_WIDTH", 160)),
|
||||||
img_height=int(get_default_value(args["--image-height"], "IMAGE_HEIGHT", 120)))
|
img_height=int(get_default_value(args["--image-height"], "IMAGE_HEIGHT", 120)))
|
||||||
frame_processor.start()
|
frame_processor.run()
|
||||||
|
|
||||||
client.loop_forever()
|
|
||||||
|
|
||||||
|
|
||||||
def get_default_value(value, env_var: str, default_value) -> str:
|
def get_default_value(value, env_var: str, default_value) -> str:
|
||||||
|
@ -8,14 +8,11 @@ import depthai as dai
|
|||||||
from depthai_sdk import getDeviceInfo
|
from depthai_sdk import getDeviceInfo
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
from threading import Thread
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FramePublisher(Thread):
|
class FramePublisher:
|
||||||
def __init__(self, mqtt_client: mqtt.Client, frame_topic: str, img_width: int, img_height: int):
|
def __init__(self, mqtt_client: mqtt.Client, frame_topic: str, img_width: int, img_height: int):
|
||||||
super().__init__(name="FrameProcessor")
|
|
||||||
self._mqtt_client = mqtt_client
|
self._mqtt_client = mqtt_client
|
||||||
self._frame_topic = frame_topic
|
self._frame_topic = frame_topic
|
||||||
self._img_width = img_width
|
self._img_width = img_width
|
||||||
|
Loading…
Reference in New Issue
Block a user