diff --git a/src/main.py b/src/main.py index d4d0799..6068aac 100644 --- a/src/main.py +++ b/src/main.py @@ -3,6 +3,8 @@ from tracker import Tracker mqtt_address = os.environ.get("MQTT_ADDRESS", "10.1.1.100") mqtt_port = int(os.environ.get("MQTT_PORT", 1883)) +mqtt_username = os.environ.get("MQTT_USERNAME", "username") +mqtt_passwd = os.environ.get("MQTT_PASSWD", "password") mqtt_client_id = os.environ.get("MQTT_CLIENT_ID", "cvzone_tracker_01") min_face_score = float(os.environ.get("MIN_FACE_SCORE", 0.5)) rotate_img = int(os.environ.get("ROTATE_IMAGE", 0)) @@ -10,6 +12,8 @@ rotate_img = int(os.environ.get("ROTATE_IMAGE", 0)) tracker = Tracker( mqtt_address=mqtt_address, mqtt_port=mqtt_port, + mqtt_passwd=mqtt_passwd, + mqtt_username=mqtt_username, mqtt_client_id=mqtt_client_id, min_face_score=min_face_score, rotate_img=rotate_img == 1, diff --git a/src/tracker.py b/src/tracker.py index 29eba9d..00b9613 100644 --- a/src/tracker.py +++ b/src/tracker.py @@ -11,6 +11,8 @@ class Tracker(object): self, mqtt_address="", mqtt_port=1883, + mqtt_username="", + mqtt_passwd="", mqtt_client_id="", min_face_score=0.5, rotate_img=False, @@ -29,6 +31,7 @@ class Tracker(object): self.mqtt_client_id = mqtt_client_id self.is_mqtt_connected = False self.mqtt_client = mqtt.Client(mqtt_client_id) + self.mqtt_client.username_pw_set(username=mqtt_username, password=mqtt_passwd) self.mqtt_connect() def mqtt_connect(self):