Skip to content

Commit ff38eb8

Browse files
committed
updated detection
1 parent 48a789c commit ff38eb8

File tree

10 files changed

+297
-15
lines changed

10 files changed

+297
-15
lines changed

requirements.txt

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,262 @@
1+
arandr==0.1.11
2+
asgiref==3.6.0
3+
astroid==2.14.2
4+
asttokens==2.2.1
5+
av==12.1.0
6+
Babel==2.10.3
7+
beautifulsoup4==4.11.2
18
blinker==1.8.2
29
certifi==2024.6.2
10+
chardet==5.1.0
311
charset-normalizer==3.3.2
412
click==8.1.7
13+
colorama==0.4.6
14+
colorzero==2.0
515
contourpy==1.2.1
16+
cryptography==38.0.4
17+
cupshelpers==1.0
618
cycler==0.12.1
19+
dbus-python==1.3.2
20+
dill==0.3.6
21+
distro==1.8.0
22+
docutils==0.19
23+
filelock==3.14.0
724
Flask==2.3.2
825
fonttools==4.53.0
26+
fsspec==2024.3.1
27+
gpiozero==2.0
28+
html5lib==1.1
929
idna==3.7
30+
importlib-metadata==4.12.0
31+
isort==5.6.4
1032
itsdangerous==2.2.0
33+
jedi==0.18.2
1134
Jinja2==3.1.4
1235
kiwisolver==1.4.5
36+
lazy-object-proxy==1.9.0
37+
lgpio==0.2.2.0
38+
libevdev==0.5
39+
logilab-common==1.9.8
40+
lxml==4.9.2
1341
MarkupSafe==2.1.5
1442
matplotlib==3.9.0
43+
mccabe==0.7.0
44+
more-itertools==8.10.0
45+
mpmath==1.3.0
46+
mypy==1.0.1
47+
mypy-extensions==0.4.3
48+
networkx==3.3
1549
numpy==1.24.2
50+
oauthlib==3.2.2
51+
olefile==0.46
52+
opencv-python==4.10.0.82
1653
packaging==24.0
54+
paho-mqtt==2.1.0
55+
pandas==2.2.2
56+
parso==0.8.3
57+
pexpect==4.8.0
58+
pgzero==1.2
59+
picamera2==0.3.18
60+
pidng==4.0.9
61+
piexif==1.1.3
62+
pigpio==1.78
1763
Pillow==9.4.0
64+
platformdirs==2.6.0
65+
psutil==5.9.4
66+
ptyprocess==0.7.0
67+
py-cpuinfo==9.0.0
68+
pycairo==1.20.1
69+
pycryptodomex==3.11.0
70+
pycups==2.0.1
71+
pygame==2.1.2
72+
Pygments==2.14.0
73+
PyGObject==3.42.2
74+
pyinotify==0.9.6
75+
PyJWT==2.6.0
76+
pylint==2.16.2
77+
PyOpenGL==3.1.6
78+
pyOpenSSL==23.0.0
1879
pyparsing==3.1.2
80+
PyQt5==5.15.9
81+
PyQt5-sip==12.11.1
82+
pyserial==3.5
83+
pysmbc==1.0.23
84+
python-apt==2.6.0
1985
python-dateutil==2.9.0.post0
2086
python-dotenv==1.0.1
87+
python-prctl==1.8.1
88+
pytz==2022.7.1
89+
pyudev==0.24.0
90+
PyYAML==6.0.1
91+
reportlab==3.6.12
2192
requests==2.28.2
93+
requests-oauthlib==1.3.0
94+
responses==0.18.0
95+
roman==3.3
96+
RPi.GPIO==0.7.1a4
97+
RTIMULib==7.2.1
98+
scipy==1.13.0
99+
seaborn==0.13.2
100+
Send2Trash==1.8.1b0
101+
sense-hat==2.6.0
22102
shapely==2.0.4
103+
simplejpeg==1.7.2
104+
simplejson==3.18.3
23105
six==1.16.0
106+
smbus2==0.4.2
107+
soupsieve==2.3.2
108+
spidev==3.5
109+
ssh-import-id==5.10
110+
sympy==1.12
111+
tflite-runtime==2.14.0
112+
thonny==4.1.4
113+
thop==0.1.1.post2209072238
114+
toml==0.10.2
115+
tomlkit==0.11.7
116+
torch==2.3.0
117+
torchvision==0.18.0
118+
tqdm==4.66.4
119+
twython==3.8.2
120+
types-aiofiles==22.1
121+
types-annoy==1.17
122+
types-appdirs==1.4
123+
types-aws-xray-sdk==2.10
124+
types-babel==2.11
125+
types-backports.ssl-match-hostname==3.7
126+
types-beautifulsoup4==4.11
127+
types-bleach==5.0
128+
types-boto==2.49
129+
types-braintree==4.17
130+
types-cachetools==5.2
131+
types-caldav==0.10
132+
types-certifi==2021.10.8
133+
types-cffi==1.15
134+
types-chardet==5.0
135+
types-chevron==0.14
136+
types-click-spinner==0.1
137+
types-colorama==0.4
138+
types-commonmark==0.9
139+
types-console-menu==0.7
140+
types-contextvars==2.4
141+
types-croniter==1.3
142+
types-cryptography==3.3
143+
types-D3DShot==0.1
144+
types-dateparser==1.1
145+
types-DateTimeRange==1.2
146+
types-decorator==5.1
147+
types-Deprecated==1.2
148+
types-dj-database-url==1.0
149+
types-docopt==0.6
150+
types-docutils==0.19
151+
types-editdistance==0.6
152+
types-emoji==2.1
153+
types-entrypoints==0.4
154+
types-first==2.0
155+
types-flake8-2020==1.7
156+
types-flake8-bugbear==22.10.27
157+
types-flake8-builtins==2.0
158+
types-flake8-docstrings==1.6
159+
types-flake8-plugin-utils==1.3
160+
types-flake8-rst-docstrings==0.2
161+
types-flake8-simplify==0.19
162+
types-flake8-typing-imports==1.14
163+
types-Flask-Cors==3.0
164+
types-Flask-SQLAlchemy==2.5
165+
types-fpdf2==2.5
166+
types-gdb==12.1
167+
types-google-cloud-ndb==1.11
168+
types-hdbcli==2.14
169+
types-html5lib==1.1
170+
types-httplib2==0.21
171+
types-humanfriendly==10.0
172+
types-invoke==1.7
173+
types-JACK-Client==0.5
174+
types-jmespath==1.0
175+
types-jsonschema==4.17
176+
types-keyboard==0.13
177+
types-ldap3==2.9
178+
types-Markdown==3.4
179+
types-mock==4.0
180+
types-mypy-extensions==0.4
181+
types-mysqlclient==2.1
182+
types-oauthlib==3.2
183+
types-openpyxl==3.0
184+
types-opentracing==2.4
185+
types-paho-mqtt==1.6
186+
types-paramiko==2.11
187+
types-parsimonious==0.10
188+
types-passlib==1.7
189+
types-passpy==1.0
190+
types-peewee==3.15
191+
types-pep8-naming==0.13
192+
types-Pillow==9.3
193+
types-playsound==1.3
194+
types-polib==1.1
195+
types-prettytable==3.4
196+
types-protobuf==3.20
197+
types-psutil==5.9
198+
types-psycopg2==2.9
199+
types-pyaudio==0.2
200+
types-PyAutoGUI==0.9
201+
types-pycurl==7.45
202+
types-pyfarmhash==0.3
203+
types-pyflakes==2.5
204+
types-Pygments==2.13
205+
types-pyinstaller==5.6
206+
types-PyMySQL==1.0
207+
types-pynput==1.7
208+
types-pyOpenSSL==22.1
209+
types-pyRFC3339==1.1
210+
types-PyScreeze==0.1
211+
types-pysftp==0.2
212+
types-pytest-lazy-fixture==0.6
213+
types-python-crontab==2.6
214+
types-python-dateutil==2.8
215+
types-python-gflags==3.1
216+
types-python-jose==3.3
217+
types-python-nmap==0.7
218+
types-python-slugify==6.1
219+
types-pytz==2022.6
220+
types-pyvmomi==7.0
221+
types-pywin32==304
222+
types-PyYAML==6.0
223+
types-redis==4.3
224+
types-regex==2022.10.31
225+
types-requests==2.28
226+
types-retry==0.9
227+
types-Send2Trash==1.8
228+
types-setuptools==65.5
229+
types-simplejson==3.17
230+
types-singledispatch==3.7
231+
types-six==1.16
232+
types-slumber==0.7
233+
types-SQLAlchemy==1.4.43
234+
types-stdlib-list==0.8
235+
types-stripe==3.5
236+
types-tabulate==0.9
237+
types-termcolor==1.1
238+
types-toml==0.10
239+
types-toposort==1.7
240+
types-tqdm==4.64
241+
types-tree-sitter==0.20
242+
types-tree-sitter-languages==1.5
243+
types-ttkthemes==3.2
244+
types-typed-ast==1.5
245+
types-tzlocal==4.2
246+
types-ujson==5.5
247+
types-urllib3==1.26
248+
types-vobject==0.9
249+
types-waitress==2.1
250+
types-whatthepatch==1.0
251+
types-xmltodict==0.13
252+
types-xxhash==3.0
253+
types-zxcvbn==4.4
254+
typing_extensions==4.11.0
255+
tzdata==2024.1
256+
ultralytics==8.2.12
24257
urllib3==1.26.18
258+
v4l2-python3==0.3.4
259+
webencodings==0.5.1
25260
Werkzeug==3.0.3
261+
wrapt==1.14.1
262+
zipp==1.0.0

src/drone/detection/app.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
import pprint
22
import requests
3+
import json
34

45
from detection import Detector
56

7+
from messages import MQTTClient # Import the MQTT client
8+
9+
class CounterClient(MQTTClient):
10+
11+
def __init__(self, broker='localhost', port=1883, topic='/counter', node=None):
12+
super().__init__(broker=broker, port=port, topic=topic)
13+
14+
def on_message(self, client, userdata, message):
15+
pass
16+
17+
18+
client = CounterClient(broker="10.1.1.4", port=1883, topic='/counter/device1')
19+
620
def handle_stream(people, frame, image):
721
print(f"People detected: {people}")
8-
response = requests.post("http://localhost:8000/upload", files={"image": image})
22+
response = requests.post(f'http://10.1.1.4:8080/upload?device=device1', files={"image": image})
923
pprint.pprint(response)
1024

25+
payload = json.dumps({'people': people})
26+
client.publish(payload)
27+
1128
def main():
1229
detector = Detector()
1330
detector.stream_picam(handle_stream, target="person", show=False)

src/drone/detection/detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ def stream(self, callback, target="person", show=True):
9999
break
100100

101101
cap.release()
102-
cv2.destroyAllWindows()
102+
cv2.destroyAllWindows()

src/drone/detection/messages.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import paho.mqtt.client as mqtt
2+
3+
class MQTTClient:
4+
def __init__(self, broker, port, topic):
5+
self.broker = broker
6+
self.port = port
7+
self.topic = topic
8+
self.client = mqtt.Client()
9+
self.client.connect(broker, port, 60)
10+
11+
self.client.on_connect = self.on_connect
12+
self.client.on_message = self.on_message
13+
14+
self.client.loop_start()
15+
16+
def publish(self, message):
17+
self.client.publish(self.topic, message)
18+
19+
def close(self):
20+
self.client.loop_stop()
21+
self.client.disconnect()
22+
23+
def on_message(self, client, userdata, message):
24+
print(f"Received message: {message.payload.decode()} on topic {message.topic}")
25+
26+
def on_connect(self, client, userdata, flags, rc):
27+
print(f"Connected with result code {rc}")
28+
self.client.subscribe(self.topic)
29+

src/drone/telemetry/telem/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import argparse
22

3-
from telem.telem import Telemetry
3+
from telem import Telemetry
44

55
def main():
66
parser = argparse.ArgumentParser(description='Telemetry node')
77
parser.add_argument('drone_id', type=str, help='Drone ID')
88
args = parser.parse_args()
99

10-
telem = Telemetry(drone=args.drone_id, broker='localhost', port=1883, mqtt_topic='/telem')
10+
telem = Telemetry(drone=args.drone_id, broker='10.1.1.4', port=1883, mqtt_topic='/telem')
1111

1212
try:
1313
telem.start()
1414
except KeyboardInterrupt:
1515
telem.shutdown()
1616

1717
if __name__ == '__main__':
18-
main()
18+
main()

src/drone/telemetry/telem/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
source /opt/ros/galactic/setup.bash
44

55
# Execute the passed command
6-
exec python3 /home/app.py "$@"
6+
exec python3 /home/telem/app.py "$@"

src/drone/telemetry/telem/telem.conf

Whitespace-only changes.

src/drone/telemetry/telem/telem.dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ RUN apt-get update && \
2727
RUN python3 -m pip install \
2828
paho-mqtt
2929

30-
COPY app.py /home/
31-
COPY telem /home/telem
30+
COPY . /home/telem
3231
COPY entrypoint.sh /home/
3332

3433
WORKDIR /home/
@@ -37,4 +36,4 @@ WORKDIR /home/
3736
ENTRYPOINT ["/home/entrypoint.sh"]
3837

3938
# Default command to run the app
40-
CMD ["python3", "app.py", "drone01"]
39+
CMD ["python3", "app.py", "drone01"]

0 commit comments

Comments
 (0)