-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
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,17 @@ | ||
# Copyright (c) 2023, Ivan Moskalenko, Anastasiia Kornilova | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from uav_loc.primitives.map import Map | ||
from uav_loc.primitives.map_tile import MapTile | ||
from uav_loc.primitives.uav_image import UAVImage | ||
from uav_loc.primitives.uav_seq import UAVSeq |
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,59 @@ | ||
# Copyright (c) 2023, Ivan Moskalenko, Anastasiia Kornilova | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from pathlib import Path | ||
|
||
from uav_loc.primitives.map_tile import MapTile | ||
|
||
|
||
class Map: | ||
""" | ||
The class represents the satellite map required for UAV localization. | ||
It is assumed that the map is divided into tiles. | ||
""" | ||
|
||
def __init__(self, path_to_metadata: Path): | ||
""" | ||
Reads map from metadata file. | ||
File format -- sequence of lines, each line is a single tile. | ||
The format of a line is as follows: | ||
`filename top_left_lat top_left_lon bottom_right_lat bottom_right_lon` | ||
:param path_to_metadata: Path to the metadata file | ||
""" | ||
tiles = [] | ||
map_folder = path_to_metadata.parents[0] | ||
with open(path_to_metadata) as file: | ||
lines = file.readlines()[1:] | ||
for line in lines: | ||
( | ||
filename, | ||
top_left_lat, | ||
top_left_lon, | ||
bottom_right_lat, | ||
bottom_right_lon, | ||
) = line.split() | ||
map_tile = MapTile( | ||
map_folder / filename, | ||
float(top_left_lat), | ||
float(top_left_lon), | ||
float(bottom_right_lat), | ||
float(bottom_right_lon), | ||
) | ||
tiles.append(map_tile) | ||
self.tiles = tiles | ||
|
||
def __iter__(self): | ||
for map_tile in self.tiles: | ||
yield map_tile |
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,34 @@ | ||
# Copyright (c) 2023, Ivan Moskalenko, Anastasiia Kornilova | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from pathlib import Path | ||
|
||
|
||
class MapTile: | ||
""" | ||
The class represents one satellite map tile with specified coordinates | ||
""" | ||
|
||
def __init__( | ||
self, | ||
path: Path, | ||
top_left_lat: float, | ||
top_left_lon: float, | ||
bottom_right_lat: float, | ||
bottom_right_lon: float, | ||
): | ||
self.path = path | ||
self.top_left_lat = top_left_lat | ||
self.top_left_lon = top_left_lon | ||
self.bottom_right_lat = bottom_right_lat | ||
self.bottom_right_lon = bottom_right_lon |
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,25 @@ | ||
# Copyright (c) 2023, Ivan Moskalenko, Anastasiia Kornilova | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from pathlib import Path | ||
|
||
|
||
class UAVImage: | ||
""" | ||
The class represents one UAV image with specified groundtruth coordinates | ||
""" | ||
|
||
def __init__(self, path: Path, gt_latitude: float, gt_longitude: float): | ||
self.path = path | ||
self.gt_latitude = gt_latitude | ||
self.gt_longitude = gt_longitude |
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,48 @@ | ||
# Copyright (c) 2023, Ivan Moskalenko, Anastasiia Kornilova | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from pathlib import Path | ||
|
||
from uav_loc.primitives.uav_image import UAVImage | ||
|
||
|
||
class UAVSeq: | ||
""" | ||
The class represents a sequence of frames taken from a UAV | ||
""" | ||
|
||
def __init__(self, path_to_metadata: Path): | ||
""" | ||
Reads sequence of images from metadata file. | ||
File format -- sequence of lines, each line is a single image. | ||
The format of a line is as follows: | ||
`filename groundtruth_longitude groundtruth_latitude` | ||
:param path_to_metadata: Path to the metadata file | ||
""" | ||
uav_images = [] | ||
queries_folder = path_to_metadata.parents[0] | ||
with open(path_to_metadata) as file: | ||
lines = file.readlines()[1:] | ||
for line in lines: | ||
filename, longitude, latitude = line.split() | ||
uav_image = UAVImage( | ||
queries_folder / filename, float(latitude), float(longitude) | ||
) | ||
uav_images.append(uav_image) | ||
self.uav_images = uav_images | ||
|
||
def __iter__(self): | ||
for uav_image in self.uav_images: | ||
yield uav_image |