Skip to content

Commit

Permalink
Fix overflow, fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed Sep 2, 2024
1 parent 75a828b commit 67411fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install apt packages
run: sudo apt update && sudo apt-get install -y libgl1-mesa-glx
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 2 additions & 0 deletions brickmos/brickify.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ def closest_color(rgb: tuple[int, int, int], color_range: list) -> BrickColor:
"""
# Get rgb values of color while adhering to cv2 BGR representation
r, g, b = rgb
r, g, b = float(r), float(g), float(b)
# Assess euclidean distance of color to all brick colors given
color_diffs = []
for color in color_range:
cr, cg, cb = color.rgb
cr, cg, cb = float(cr), float(cg), float(cb)
color_diff = math.sqrt(abs(r - cr) ** 2 + abs(g - cg) ** 2 + abs(b - cb) ** 2)
color_diffs.append((color_diff, color))
# Get color closest to the given one and update its stats
Expand Down

0 comments on commit 67411fd

Please sign in to comment.