Skip to content

Commit

Permalink
First implementation of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMariday committed Feb 17, 2024
1 parent 9ddaf0d commit 93bc146
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 7 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/l3d_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install flake8 pytest
pip install -r requirements.txt
- name: Flake 8 Syntax Errors
Expand All @@ -34,3 +35,7 @@ jobs:
- name: Flake 8 Syntax Warnings
run: |
flake8 . --count --statistics
- name: Pytest
run: |
pytest .
2 changes: 1 addition & 1 deletion lib/led_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def v(self):

class LedFinder:

def __init__(self, threshold):
def __init__(self, threshold=128):
self.threshold = threshold

def find_led(self, image):
Expand Down
1 change: 1 addition & 0 deletions scripts/reconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import os


if __name__ == "__main__":

raise NotImplementedError("This hasn't been properly implemented yet and is still a work in progress")
Expand Down
Binary file added test/media/capture_sequence/a_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/a_none.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/media/capture_sequence/s_none.png
39 changes: 39 additions & 0 deletions test/test_led_identifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import sys
import cv2
sys.path.append('./')
from lib.led_identifier import LedFinder


def close(x, y):
return abs(x - y) < 0.5


def load_image(filename):
image = cv2.imread(filename)
return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


def test_init():
LedFinder()


def test_basic_image_loading():
led_finder = LedFinder()

image = load_image("test/media/capture_sequence/a_0.png")

led_results = led_finder.find_led(image)

assert close(led_results.u(), 193)
assert close(led_results.v(), 150)


def test_none_found():

led_finder = LedFinder()

image = load_image("test/media/capture_sequence/a_none.png")

led_results = led_finder.find_led(image)

assert led_results is None

0 comments on commit 93bc146

Please sign in to comment.