From 6cc7290a027f96741ecfdd0d4f76a1114fc4105d Mon Sep 17 00:00:00 2001 From: se1exin Date: Sat, 14 May 2022 19:52:47 +1000 Subject: [PATCH] Add image rotation option --- README.md | 1 + src/main.py | 2 ++ src/tracker.py | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 306f987..14be2a2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ docker run \ -e MQTT_PORT="1883" \ -e MQTT_CLIENT_ID="cvzone_tracker_01" \ -e MIN_FACE_SCORE="0.5" \ + -e ROTATE_IMAGE="0" \ --name=face-detect-mqtt \ selexin/face-detect-mqtt:latest ``` diff --git a/src/main.py b/src/main.py index 7a2358a..968e0c4 100644 --- a/src/main.py +++ b/src/main.py @@ -5,12 +5,14 @@ mqtt_address = os.environ.get("MQTT_ADDRESS", "10.1.1.100") mqtt_port = int(os.environ.get("MQTT_PORT", 1883)) 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)) tracker = Tracker( mqtt_address=mqtt_address, mqtt_port=mqtt_port, mqtt_client_id=mqtt_client_id, min_face_score=min_face_score, + rotate_img=rotate_img == 1, show_img=False) while True: diff --git a/src/tracker.py b/src/tracker.py index fc46efd..29eba9d 100644 --- a/src/tracker.py +++ b/src/tracker.py @@ -13,12 +13,14 @@ class Tracker(object): mqtt_port=1883, mqtt_client_id="", min_face_score=0.5, + rotate_img=False, show_img=False): self.show_img = show_img self.min_face_score = min_face_score self.cap = cv2.VideoCapture(0) self.face_detector = FaceDetector() + self.rotate_img = rotate_img self.img = None self.face_found = False @@ -50,6 +52,9 @@ class Tracker(object): def read_img(self): success, img = self.cap.read() + if self.rotate_img: + img = cv2.rotate(img, cv2.ROTATE_180) + self.img = img def detect_face(self):