Conversation
5da7a5e to
6bb42a3
Compare
67691e0 to
b1f0e49
Compare
| def __init__(self, image: np.ndarray, boxes_list: np.ndarray): | ||
| """ | ||
| image = A numpy array that represents the image needed to be tested. | ||
| bounding_box_list: A numpy array that holds a list of expected bounding box coordinates. |
There was a problem hiding this comment.
Me as a new member making an easy mistake:
top_left_x = boxes_list[0]
top_left_y = boxes_list[1]
bottom_right_x = boxes_list[2]
bottom_right_x = boxes_list[3]Add an explanation for the shape!
| @pytest.fixture() | ||
| def image_easy(single_circle: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load the single basic landing pad. | ||
| """ | ||
|
|
||
| image = single_circle.image | ||
| result, actual_image = image_and_time.ImageAndTime.create(image) | ||
| assert result | ||
| assert actual_image is not None | ||
| yield actual_image # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def blurry_image(single_blurry_circle: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load the single blurry landing pad. | ||
| """ | ||
|
|
||
| image = single_blurry_circle.image | ||
| result, actual_image = image_and_time.ImageAndTime.create(image) | ||
| assert result | ||
| assert actual_image is not None | ||
| yield actual_image # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def stretched_image(single_stretched_circle: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load the single stretched landing pad. | ||
| """ | ||
|
|
||
| image = single_stretched_circle.image | ||
| result, actual_image = image_and_time.ImageAndTime.create(image) | ||
| assert result | ||
| assert actual_image is not None | ||
| yield actual_image # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def multiple_images(multiple_circles: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load the multiple landing pads. | ||
| """ | ||
|
|
||
| image = multiple_circles.image | ||
| result, actual_image = image_and_time.ImageAndTime.create(image) | ||
| assert result | ||
| assert actual_image is not None | ||
| yield actual_image # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def expected_easy(single_circle: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load expected a basic image detections. | ||
| """ | ||
|
|
||
| expected = single_circle.bounding_box_list | ||
| yield create_detections(expected) # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def expected_blur(single_blurry_circle: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load expected the blured pad image detections. | ||
| """ | ||
|
|
||
| expected = single_blurry_circle.bounding_box_list | ||
| yield create_detections(expected) # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def expected_stretch(single_stretched_circle: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load expected a stretched pad image detections. | ||
| """ | ||
|
|
||
| expected = single_stretched_circle.bounding_box_list | ||
| yield create_detections(expected) # type: ignore | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def expected_multiple(multiple_circles: InputImageAndExpectedBoundingBoxes) -> image_and_time.ImageAndTime: # type: ignore | ||
| """ | ||
| Load expected multiple pads image detections. | ||
| """ | ||
|
|
||
| expected = multiple_circles.bounding_box_list | ||
| yield create_detections(expected) # type: ignore |
There was a problem hiding this comment.
Why are there so many fixtures doing the same work? I expect InputImageAndExpectedBoundingBoxes to already have the required information. Move this work into generate_detect_target_contour.py .
There was a problem hiding this comment.
I based a lot of my code on the ultralytics one so I thought this would be proper structure, should I do something else or just have it moved?
There was a problem hiding this comment.
image_and_time.ImageAndTime.create() should already be part of the generation that results in InputImageAndExpectedBoundingBoxes .
create_detections() is not necessary because it just holds the time data (which is thrown away). compare_detections() should take in just the bounding boxes.
| yield create_detections(expected) # type: ignore | ||
|
|
||
|
|
||
| # pylint:disable=duplicate-code |
There was a problem hiding this comment.
Pylint is part of the coding standard, so suppressing it needs to be justified. Can you explain:
- What exactly is causing this
- Why it's not possible to change the code so that it no longer warns on this
|
|
||
| (x, y), radius = cv2.minEnclosingCircle(contour) | ||
|
|
||
| enclosing_area = np.pi * (radius**2) |
| expected_blur: detections_and_time.DetectionsAndTime, | ||
| ) -> None: | ||
| """ | ||
| Run the detection for the blury cicular circle. |
There was a problem hiding this comment.
Spelling: for a single blurry circular landing pad.
Issues: detect_target_contour not detecting any contours(?)
Class -> Functions (Some sort of issue with detect_target)contour, extra unit tests added after)
…urs + Working Tests
03d95cb to
8ce749c
Compare
| # Create new object with actual detections | ||
| test_data = generate_detect_target_contour.InputImageAndTimeAndExpectedBoundingBoxes( | ||
| actual, | ||
| single_circle.bounding_box_list | ||
| ) | ||
| compare_detections(test_data) |
There was a problem hiding this comment.
No!
def compare_detections(actual: list[Detection], expected: np.ndarray) -> None:
...
# The test
...
assert actual is not None
compare_detections(actual.detections, single_circle.bounding_box_list)
# End of test no more code here in this test
Do not review. Waiting for tests.