Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/camera deskew #202

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3905b12
small changes to update the repo for 2025
DJDMVP Aug 19, 2024
73725b0
testing
DJDMVP Aug 20, 2024
11779df
Test 2
DJDMVP Aug 20, 2024
f6af86a
fixing small typing error for mypy
DJDMVP Aug 21, 2024
1c6fbbe
Merge pull request #1 from MissouriMRR/First-Setup
DJDMVP Aug 21, 2024
b3dbd3b
updating poetry
DJDMVP Sep 11, 2024
9d2e689
Merge branch 'develop' into feature/poetryupdate
DJDMVP Sep 11, 2024
221f4bd
there were some errors with ppoetry lock and pyproject
DJDMVP Sep 13, 2024
732479e
Merge branch 'feature/poetryupdate' of github.com:MissouriMRR/SUAS-20…
DJDMVP Sep 13, 2024
2d13a40
Merge pull request #11 from MissouriMRR/feature/poetryupdate
DJDMVP Sep 13, 2024
1db9ac7
unittest
Oct 9, 2024
b062feb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
78600f1
Fix the error
Oct 22, 2024
ae7530e
a
Oct 22, 2024
94583b0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 22, 2024
a8d1b94
Fix error
Oct 22, 2024
50a3666
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 22, 2024
b3cb01e
f
Oct 22, 2024
42689d0
a
Oct 22, 2024
d90161a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 22, 2024
ed3e59b
a
Oct 29, 2024
5e39c5d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
aff42b0
d
Oct 29, 2024
1d5288a
d
Oct 29, 2024
28d8cd2
d
Oct 29, 2024
bcc9b0a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
bb7c5b8
fix
Oct 29, 2024
653671d
s
Oct 29, 2024
f73b165
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
3b0e870
s
Oct 29, 2024
c58e979
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
e577267
s
Oct 30, 2024
100dd95
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 30, 2024
8183661
s
Oct 30, 2024
418d137
s
Oct 30, 2024
0a50993
s
Oct 30, 2024
2c3e700
s
Oct 30, 2024
7294855
s
Oct 30, 2024
de71b74
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 30, 2024
224aec8
s
Oct 30, 2024
f16cba5
test
Nov 13, 2024
c84402f
dd
Nov 13, 2024
9b77dd6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 13, 2024
dc04769
d
Nov 15, 2024
469a199
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 15, 2024
62676fe
test
Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SUAS-2023
# SUAS-2025

Missouri S&T Multirotor Robot Design Team's code for the Association for Unmanned Vehicle Systems International's 2023 Student Unmanned Aerial Systems Competition (AUVSI SUAS 2023)
Missouri S&T Multirotor Drone Design Team's code for the Association for Unmanned Vehicle Systems International's 2025 Student Unmanned Aerial Systems Competition (AUVSI SUAS 2025) hosted by Robonation

## Table of contents

Expand Down Expand Up @@ -53,7 +53,7 @@ You will need to install pip with `sudo apt-get install python3-pip`. Pip is use

### Getting the Repo

Go to your documents folder and clone the repo with `git clone https://github.com/MissouriMRR/SUAS-2023.git`
Go to your documents folder and clone the repo with `git clone https://github.com/MissouriMRR/SUAS-2025.git`

### Pre-commit

Expand Down
93 changes: 93 additions & 0 deletions Unittest_camera_distance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import unittest
import numpy as np
from enum import Enum
from vision.common.constants import Point, CameraParameters, ODLCDict
from vision.common.bounding_box import BoundingBox, ObjectType
from vision.deskew.camera_distances import get_coordinates, bounding_area, calculate_distance


class TestVisionFunctions(unittest.TestCase):
"""
Tests to verify the functionality of calculations
concerning object positioning and distances in images captured by a camera.

Attributes
----------
The dimensions of the image used in tests, specified as (height, width, channels).
"""

def setUp(self) -> None:
"""
Initializes common properties for all test methods. Sets up camera parameters
and image dimensions that simulate a typical usage scenario.

"""
self.camera_params = CameraParameters(
focal_length=35.0,
rotation_deg=[0, 0, 0],
drone_coordinates=[37.7749, -122.4194],
altitude_f=1000.0,
)
self.image_shape = (1080, 1920, 3) # Image size with 3 color channels

def test_get_coordinates(self) -> None:
"""

Verifies that the accurately calculates coordinates
from a center pixel. Asserts correct type and closeness to expected values.

Returns
-------
None: This method does not return a value but asserts the correctness of the output.
"""
center_pixel = (960, 540)
expected_coordinates = (37.77, -122.211)
result = get_coordinates(center_pixel, self.image_shape, self.camera_params)

self.assertIsNotNone(result, "Coordinates should not be None")
# Check if the result is not None and is of the expected tuple type
self.assertIsInstance(result, tuple, "Result should be a tuple")
if isinstance(result, tuple):
self.assertEqual(len(result), 2, "Result tuple should have two elements")
self.assertIsInstance(result[0], float, "Latitude is float")
self.assertIsInstance(result[1], float, "Longitude is float")
# Make sure to get the expected value
if result is not None:
self.assertAlmostEqual(result[0], expected_coordinates[0], places=2)
self.assertAlmostEqual(result[1], expected_coordinates[1], places=2)

def test_bounding_area(self) -> None:
"""
Tests the function to calculate the area of a bounding box
within the image, simulating an object detection scenario.

Returns
-------
None: This method does not return a value but asserts the area calculation is correct.
"""
obj_type = ObjectType(value="") # Provide the necessary argument
self.box = BoundingBox(
obj_type=obj_type,
vertices=((100, 200), (200, 200), (200, 300), (100, 300)),
)
expected_area = 10000
result = bounding_area(self.box, self.image_shape, self.camera_params)

# Ensure result is not None before asserting
self.assertIsNotNone(result, "Result should not be None for valid bounding box")

def test_calculate_distance(self) -> None:
"""
Tests distance calculation between two points in an image. Ensures the method
returns a valid result.
"""
pixel1 = (100, 100)
pixel2 = (200, 200) # Valid pixel coordinates
result = calculate_distance(pixel1, pixel2, self.image_shape, self.camera_params)

# Ensure result is not None before asserting
self.assertIsNotNone(result, "Result should not be None for valid pixel coordinates")


if __name__ == "__main__":
unittest.main()
17 changes: 17 additions & 0 deletions camera.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"suas2.png": {
"focal_length": 10,
"rotation_deg": [10, 20, 30],
"drone_coordinates": [50.80085, 21.42069],
"altitude_f": 100
},



"suas.png": {
"focal_length": 10,
"rotation_deg": [10, 20, 30],
"drone_coordinates": [50.80085, 21.42069],
"altitude_f": 100
}
}
Loading