Add image rotation option
This commit is contained in:
parent
6c04556800
commit
6cc7290a02
|
@ -27,6 +27,7 @@ docker run \
|
||||||
-e MQTT_PORT="1883" \
|
-e MQTT_PORT="1883" \
|
||||||
-e MQTT_CLIENT_ID="cvzone_tracker_01" \
|
-e MQTT_CLIENT_ID="cvzone_tracker_01" \
|
||||||
-e MIN_FACE_SCORE="0.5" \
|
-e MIN_FACE_SCORE="0.5" \
|
||||||
|
-e ROTATE_IMAGE="0" \
|
||||||
--name=face-detect-mqtt \
|
--name=face-detect-mqtt \
|
||||||
selexin/face-detect-mqtt:latest
|
selexin/face-detect-mqtt:latest
|
||||||
```
|
```
|
||||||
|
|
|
@ -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_port = int(os.environ.get("MQTT_PORT", 1883))
|
||||||
mqtt_client_id = os.environ.get("MQTT_CLIENT_ID", "cvzone_tracker_01")
|
mqtt_client_id = os.environ.get("MQTT_CLIENT_ID", "cvzone_tracker_01")
|
||||||
min_face_score = float(os.environ.get("MIN_FACE_SCORE", 0.5))
|
min_face_score = float(os.environ.get("MIN_FACE_SCORE", 0.5))
|
||||||
|
rotate_img = int(os.environ.get("ROTATE_IMAGE", 0))
|
||||||
|
|
||||||
tracker = Tracker(
|
tracker = Tracker(
|
||||||
mqtt_address=mqtt_address,
|
mqtt_address=mqtt_address,
|
||||||
mqtt_port=mqtt_port,
|
mqtt_port=mqtt_port,
|
||||||
mqtt_client_id=mqtt_client_id,
|
mqtt_client_id=mqtt_client_id,
|
||||||
min_face_score=min_face_score,
|
min_face_score=min_face_score,
|
||||||
|
rotate_img=rotate_img == 1,
|
||||||
show_img=False)
|
show_img=False)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -13,12 +13,14 @@ class Tracker(object):
|
||||||
mqtt_port=1883,
|
mqtt_port=1883,
|
||||||
mqtt_client_id="",
|
mqtt_client_id="",
|
||||||
min_face_score=0.5,
|
min_face_score=0.5,
|
||||||
|
rotate_img=False,
|
||||||
show_img=False):
|
show_img=False):
|
||||||
|
|
||||||
self.show_img = show_img
|
self.show_img = show_img
|
||||||
self.min_face_score = min_face_score
|
self.min_face_score = min_face_score
|
||||||
self.cap = cv2.VideoCapture(0)
|
self.cap = cv2.VideoCapture(0)
|
||||||
self.face_detector = FaceDetector()
|
self.face_detector = FaceDetector()
|
||||||
|
self.rotate_img = rotate_img
|
||||||
self.img = None
|
self.img = None
|
||||||
self.face_found = False
|
self.face_found = False
|
||||||
|
|
||||||
|
@ -50,6 +52,9 @@ class Tracker(object):
|
||||||
|
|
||||||
def read_img(self):
|
def read_img(self):
|
||||||
success, img = self.cap.read()
|
success, img = self.cap.read()
|
||||||
|
if self.rotate_img:
|
||||||
|
img = cv2.rotate(img, cv2.ROTATE_180)
|
||||||
|
|
||||||
self.img = img
|
self.img = img
|
||||||
|
|
||||||
def detect_face(self):
|
def detect_face(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user