-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simulator dataset and test (#22)
- Loading branch information
1 parent
114ca34
commit e9bea53
Showing
118 changed files
with
205 additions
and
75 deletions.
There are no files selected for viewing
File renamed without changes
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
octagon,Y,96:160:80,68:223:187 -19,0,-44 | ||
rectangle,O,101:210:28,37:104:143 -99,0,34 | ||
rectangle,8,153:45:255,149:118:93 -64,0,59 | ||
cross,T,118:73:48,16:64:37 -125,0,-65 | ||
hexagon,O,22:160:151,99:7:45 -134,0,-25 |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import unittest | ||
from uavf_2024.imaging.target_tracker import TargetTracker | ||
from uavf_2024.imaging.image_processor import ImageProcessor | ||
from uavf_2024.imaging.color_classification import ColorClassifier | ||
from uavf_2024.imaging.imaging_types import TargetDescription, Target3D | ||
import os | ||
import numpy as np | ||
import cv2 as cv | ||
|
||
CURRENT_FILE_PATH = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
SHAPES = [ | ||
"circle", | ||
"cross", | ||
"heptagon", | ||
"hexagon", | ||
"octagon", | ||
"pentagon", | ||
"quartercircle", | ||
"rectangle", | ||
"semicircle", | ||
"square", | ||
"star", | ||
"trapezoid", | ||
"triangle", | ||
"person" | ||
] | ||
|
||
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789" | ||
|
||
def csv_to_np(csv_str: str, delim: str = ","): | ||
''' | ||
Parses strings like "1,2,3" or "1:2:3" into numpy array [1,2,3] | ||
''' | ||
return np.array( | ||
[ | ||
int(x) for x in | ||
csv_str.split(delim) | ||
] | ||
) | ||
|
||
class TestPipeline(unittest.TestCase): | ||
def test_with_sim_dataset(self): | ||
def latlng_to_local(latlng): | ||
return np.array([latlng[0], 0, latlng[1]]) | ||
def local_to_latlng(coords): | ||
return coords[0], coords[2] | ||
target_tracker = TargetTracker( | ||
latlng_to_local, | ||
local_to_latlng, | ||
67, | ||
5312 | ||
) | ||
color_classifier = ColorClassifier() | ||
image_processor = ImageProcessor() | ||
ground_truth: list[Target3D] = [] | ||
|
||
with open(f"{CURRENT_FILE_PATH}/imaging_data/sim_dataset/labels.txt", "r") as f: | ||
for line in f.readlines(): | ||
label, location_str = line.split(" ") | ||
location = csv_to_np(location_str) | ||
|
||
shape_name, alphanumeric, shape_col_rgb, letter_col_rgb = label.split(",") | ||
shape_probs = np.eye(13)[SHAPES.index(shape_name)] | ||
letter_probs = np.eye(35)[LETTERS.index(alphanumeric)] | ||
|
||
shape_col_rgb = csv_to_np(shape_col_rgb, ":") | ||
letter_col_rgb = csv_to_np(letter_col_rgb, ":") | ||
shape_col_probs = color_classifier.predict(shape_col_rgb) | ||
letter_color_probs = color_classifier.predict(letter_col_rgb) | ||
|
||
ground_truth.append( | ||
Target3D( | ||
location[0], | ||
location[2], | ||
TargetDescription( | ||
shape_probs, | ||
letter_probs, | ||
shape_col_probs, | ||
letter_color_probs | ||
) | ||
) | ||
) | ||
|
||
images_dirname = f"{CURRENT_FILE_PATH}/imaging_data/sim_dataset/images" | ||
for file_name in os.listdir(images_dirname): | ||
img = cv.imread(f"{images_dirname}/{file_name}") | ||
pose_strs = file_name.split(".")[0].split("_")[1:] | ||
cam_position = csv_to_np(pose_strs[0]) | ||
cam_angles = csv_to_np(pose_strs[1]) | ||
|
||
predictions = image_processor.process_image(img) | ||
for pred in predictions: | ||
target_tracker.update_with_new_data(pred, np.concatenate([cam_position, cam_angles])) | ||
|
||
EPSILON = 1e-6 | ||
scores = [] | ||
for gt_target in ground_truth: | ||
closest_match = target_tracker.closest_match(gt_target.description) | ||
if abs(closest_match.lat-gt_target.lat)<EPSILON and abs(closest_match.lng-gt_target.lng)<EPSILON: | ||
scores.append(1) | ||
else: | ||
scores.append(0) | ||
|
||
print(f"Imaging Sim Score: {np.mean(scores)}") | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.