Skip to content

Commit

Permalink
Updates reader to use requests. Updates microcontroller comms to use …
Browse files Browse the repository at this point in the history
…proper logging
  • Loading branch information
lucashicks1 committed Oct 15, 2023
1 parent feb2f31 commit d78cd87
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/figurines/microcontroller_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def main():
if serialPort.is_open:
try:
response = json.loads(
requests.get('http://127.0.0.1:8000/figurines').text
requests.get('http://127.0.0.1:8000/figurines', timeout=5).text
)
if response != figurine_status:
figurine_status = response
Expand Down
13 changes: 11 additions & 2 deletions build/vision/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import namedtuple

import numpy as np
import requests
import pytesseract
from camera_constants import left
from camera_constants import time_slot_height
Expand All @@ -17,6 +18,8 @@
Point = namedtuple('Point', ['X', 'Y'])
TimeSlot = namedtuple('TimeSlot', ['top_left', 'bottom_right'])

USER_NAME = "family"


def main(image: Image):
"""
Expand Down Expand Up @@ -59,9 +62,15 @@ def main(image: Image):
'colour': ','.join(colour), # logic to get out of list
}
)

request_body = {"body": coloured_time_slots}
try:
requests.post(f"http://127.0.0.1:8000/whiteboard/{USER_NAME}", json=request_body, timeout=30)
except requests.exceptions.ConnectionError as e:
print(f"Error making HTTP request - {e}")

with open('coloured_time_slots.json', 'w') as json_file:
json.dump(coloured_time_slots, json_file, indent=4)
# with open('coloured_time_slots.json', 'w') as json_file:
# json.dump(coloured_time_slots, json_file, indent=4)


def get_info(time_slot_array: np.ndarray) -> (bool, [str], str):
Expand Down
20 changes: 14 additions & 6 deletions environment.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
---
name: lambda-env
channels: [conda-forge, defaults]
channels:
- conda-forge
- defaults
dependencies:
- annotated-types=0.6.0=pyhd8ed1ab_0
- anyio=3.7.1=pyhd8ed1ab_0
- blas=1.0=openblas
- brotli=1.0.9=h1a28f6b_7
- brotli-bin=1.0.9=h1a28f6b_7
- brotlipy=0.7.0=py311h80987f9_1002
- bzip2=1.0.8=h620ffc9_4
- ca-certificates=2023.7.22=hf0a4a13_0
- certifi=2023.7.22=pyhd8ed1ab_0
- ca-certificates=2023.08.22=hca03da5_0
- certifi=2023.7.22=py311hca03da5_0
- cffi=1.16.0=py311h4a08483_0
- charset-normalizer=2.0.4=pyhd3eb1b0_0
- click=8.1.7=unix_pyh707e725_0
- contourpy=1.0.5=py311h48ca7d4_0
- cryptography=41.0.4=py311h5fb2c35_0
Expand Down Expand Up @@ -71,14 +74,17 @@ dependencies:
- pydantic=2.4.2=pyhd8ed1ab_0
- pydantic-core=2.10.1=py311h0563b04_0
- pymongo=4.5.0=py311ha891d26_1
- pyopenssl=23.2.0=py311hca03da5_0
- pyparsing=3.0.9=py311hca03da5_0
- pysocks=1.7.1=py311hca03da5_0
- pytesseract=0.3.10=py311hca03da5_0
- python=3.11.6=h47c9636_0_cpython
- python-dateutil=2.8.2=pyhd3eb1b0_0
- python-dotenv=1.0.0=pyhd8ed1ab_1
- python_abi=3.11=4_cp311
- pyyaml=6.0.1=py311heffc1b2_1
- readline=8.2=h1a28f6b_0
- requests=2.31.0=py311hca03da5_0
- setuptools=68.0.0=py311hca03da5_0
- six=1.16.0=pyhd3eb1b0_1
- sniffio=1.3.0=pyhd8ed1ab_0
Expand All @@ -90,6 +96,7 @@ dependencies:
- typing-extensions=4.8.0=hd8ed1ab_0
- typing_extensions=4.8.0=pyha770c72_0
- tzdata=2023c=h04d1e81_0
- urllib3=1.26.16=py311hca03da5_0
- uvicorn=0.23.2=py311h267d04e_1
- uvicorn-standard=0.23.2=ha1ab1f8_1
- uvloop=0.17.0=py311heffc1b2_2
Expand All @@ -100,5 +107,6 @@ dependencies:
- yaml=0.2.5=h3422bc3_2
- zlib=1.2.13=h53f4e23_5
- zstd=1.5.5=hd90d995_0
- pip: [opencv-python-headless==4.8.1.78]
prefix: /Users/alexviller/miniconda3/envs/lambda-vision
- pip:
- opencv-python-headless==4.8.1.78
prefix: /opt/homebrew/Caskroom/miniconda/base/envs/lambda-env

0 comments on commit d78cd87

Please sign in to comment.