Add dockerfile
This commit is contained in:
parent
99cf61f0cf
commit
3d1208897b
3
.dockerignore
Normal file
3
.dockerignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
venv
|
||||
docker/
|
||||
.idea
|
10
README.md
10
README.md
|
@ -1,5 +1,15 @@
|
|||
# CVZone MQTT Tracker
|
||||
|
||||
## Run with docker
|
||||
```
|
||||
docker run \
|
||||
--device /dev/video0 \
|
||||
-e MQTT_ADDRESS="10.1.1.100" \
|
||||
-e MQTT_PORT="1883" \
|
||||
-e MQTT_CLIENT_ID="cvzone_tracker_01" \
|
||||
-e MIN_FACE_SCORE="0.5" \
|
||||
cvzone-mqtt-tracker:latest
|
||||
```
|
||||
|
||||
## Install on Raspberry Pi
|
||||
*Required*: Raspberry Pi OS 64-bit
|
||||
|
|
10
docker/Dockerfile
Normal file
10
docker/Dockerfile
Normal file
|
@ -0,0 +1,10 @@
|
|||
FROM python:3.7
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y python3-opencv
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD python main.py
|
12
main.py
12
main.py
|
@ -1,8 +1,16 @@
|
|||
import os
|
||||
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_client_id = os.environ.get("MQTT_CLIENT_ID", "cvzone_tracker_01")
|
||||
min_face_score = float(os.environ.get("MIN_FACE_SCORE", 0.5))
|
||||
|
||||
tracker = Tracker(
|
||||
mqtt_address="10.1.1.100",
|
||||
mqtt_client_id="cvzone_tracker_01",
|
||||
mqtt_address=mqtt_address,
|
||||
mqtt_port=mqtt_port,
|
||||
mqtt_client_id=mqtt_client_id,
|
||||
min_face_score=min_face_score,
|
||||
show_img=False)
|
||||
|
||||
while True:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
cvzone==1.5.6
|
||||
mediapipe==0.8.10
|
||||
mediapipe==0.8.9.1
|
||||
opencv-contrib-python==4.5.5.64
|
||||
opencv-python==4.5.5.64
|
||||
paho-mqtt==1.6.1
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
cvzone==1.5.6
|
||||
mediapipe==0.8.9.1
|
||||
numpy==1.22.3
|
||||
opencv-contrib-python==4.5.5.64
|
||||
opencv-python==4.5.5.64
|
||||
paho-mqtt==1.6.1
|
13
tracker.py
13
tracker.py
|
@ -7,9 +7,16 @@ from debounce import debounce
|
|||
|
||||
|
||||
class Tracker(object):
|
||||
def __init__(self, mqtt_address="", mqtt_port=1883, mqtt_client_id="", show_img=False):
|
||||
def __init__(
|
||||
self,
|
||||
mqtt_address="",
|
||||
mqtt_port=1883,
|
||||
mqtt_client_id="",
|
||||
min_face_score=0.5,
|
||||
show_img=False):
|
||||
|
||||
self.show_img = show_img
|
||||
self.min_face_score = 0.5
|
||||
self.min_face_score = min_face_score
|
||||
self.cap = cv2.VideoCapture(0)
|
||||
self.face_detector = FaceDetector()
|
||||
self.img = None
|
||||
|
@ -56,8 +63,6 @@ class Tracker(object):
|
|||
|
||||
score = face_bboxs[0]["score"][0]
|
||||
return score >= self.min_face_score
|
||||
else:
|
||||
print('Image not usable')
|
||||
return False
|
||||
|
||||
def loop(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user