Add image rotation option

This commit is contained in:
se1exin 2022-05-14 19:52:47 +10:00
parent 6c04556800
commit 6cc7290a02
No known key found for this signature in database
GPG Key ID: 8C5633201B25C57D
3 changed files with 8 additions and 0 deletions

View File

@ -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
```

View File

@ -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:

View File

@ -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):