-
Notifications
You must be signed in to change notification settings - Fork 6
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
19 changed files
with
508 additions
and
236 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 |
---|---|---|
|
@@ -5,6 +5,9 @@ on: | |
- 'main' | ||
- 'dev' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
clean-up: | ||
name: Clean Up Python Notebooks | ||
|
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
\i overlap.sql; | ||
\i in_view.sql; | ||
\i ahead.sql; | ||
\i angleBetween.sql; | ||
\i angleExcluding.sql; | ||
\i convertCamera.sql; | ||
\i distance.sql; | ||
\i sameRegion.sql; | ||
\i facingRelative.sql; | ||
\i ahead.sql; | ||
\i geoContained.sql; | ||
\i geoContainedMargin.sql; | ||
\i headingAtTimestamp.sql; | ||
\i in_view.sql; | ||
\i minDistance.sql; | ||
\i objectBBox.sql; | ||
\i operators.sql; | ||
\i overlap.sql; | ||
\i roadCoords.sql; | ||
\i roadDirection.sql; | ||
\i angleBetween.sql; | ||
\i headingAtTimestamp.sql; | ||
\i objectBBox.sql; | ||
\i viewAngle.sql; | ||
\i geoContained.sql; | ||
\i roadSegment.sql; | ||
\i angleExcluding.sql; | ||
\i roadCoords.sql; | ||
\i convertCamera.sql; | ||
\i sameRegion.sql; | ||
\i viewAngle.sql; |
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 |
---|---|---|
@@ -1,2 +1,23 @@ | ||
import json | ||
from typing import Any | ||
|
||
from .video_processor.camera_config import CameraConfig, camera_config | ||
|
||
|
||
class GeospatialVideo: | ||
pass | ||
def __init__(self, video: "str", camera: "list[CameraConfig] | str") -> None: | ||
self.video = video | ||
if isinstance(camera, str): | ||
with open(camera, "r") as f: | ||
camera_configs = json.load(f) | ||
assert isinstance(camera_configs, list), camera_configs | ||
self.camera = [_camera_config(c) for c in camera_configs] | ||
else: | ||
self.camera = camera | ||
|
||
|
||
def _camera_config(c: "Any"): | ||
assert isinstance(c, list), c | ||
assert len(c) == 13, c | ||
c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13 = c | ||
return camera_config(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, 0) |
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
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
11 changes: 11 additions & 0 deletions
11
spatialyze/video_processor/utils/associate_segment_mapping.py
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,11 @@ | ||
from ..stages.segment_trajectory.from_tracking_3d import SegmentTrajectoryMetadatum | ||
from ..stages.tracking_3d.tracking_3d import Tracking3DResult | ||
|
||
|
||
def associate_segment_mapping( | ||
tracking_result: "Tracking3DResult", | ||
segment_mapping_meta: "list[SegmentTrajectoryMetadatum] | None", | ||
): | ||
if segment_mapping_meta is None: | ||
return None | ||
return segment_mapping_meta[tracking_result.frame_idx].get(tracking_result.object_id) |
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,65 @@ | ||
from ..camera_config import CameraConfig | ||
from ..stages.segment_trajectory.construct_segment_trajectory import SegmentPoint | ||
from ..stages.tracking_3d.tracking_3d import Tracking3DResult | ||
from ..types import Float3 | ||
|
||
|
||
def format_trajectory( | ||
video_name: "str", | ||
obj_id: "str", | ||
track: "list[tuple[Tracking3DResult, CameraConfig, SegmentPoint | None]]", | ||
base=None, | ||
): | ||
timestamps: "list[str]" = [] | ||
pairs: "list[Float3]" = [] | ||
itemHeadings: "list[int]" = [] | ||
translations: "list[Float3]" = [] | ||
camera_id = None | ||
object_type = None | ||
# road_types: "list[str]" = [] | ||
# roadpolygons: "list[list[Float2]]" = [] | ||
### TODO (fge): remove investigation code | ||
info_found = [] | ||
# if obj_id in investigation_ids: | ||
# print(f"obj_id, {obj_id}:", [e[1].filename for e in track]) | ||
for tracking_result_3d, ego_info, segment_mapping in track: | ||
if ego_info: | ||
if ( | ||
"sweeps/CAM_FRONT/n008-2018-08-30-15-16-55-0400__CAM_FRONT__1535657125362404.jpg" | ||
in ego_info.filename | ||
): | ||
info_found.append( | ||
[ | ||
obj_id, | ||
tracking_result_3d.bbox_left, | ||
tracking_result_3d.bbox_top, | ||
tracking_result_3d.bbox_w, | ||
tracking_result_3d.bbox_h, | ||
] | ||
) | ||
camera_id = ego_info.camera_id | ||
object_type = tracking_result_3d.object_type | ||
timestamps.append(ego_info.timestamp) | ||
pairs.append(tracking_result_3d.point) | ||
if not segment_mapping or (segment_mapping.segment_type == "intersection"): | ||
itemHeadings.append(None) | ||
else: | ||
itemHeadings.append(segment_mapping.segment_heading) | ||
translations.append(ego_info.ego_translation) | ||
# road_types.append(segment_mapping.road_polygon_info.road_type if base else detection_info.road_type) | ||
# roadpolygons.append(None if base else detection_info.road_polygon_info.polygon) | ||
if len(timestamps) == 0 or camera_id is None or object_type is None: | ||
return None | ||
# if obj_id in investigation_ids: | ||
# print(f"pairs for obj {obj_id}:", [(e[0], e[1]) for e in pairs]) | ||
# print(f"itemHeadings for obj {obj_id}:", itemHeadings) | ||
|
||
return ( | ||
video_name + "_obj_" + str(obj_id), | ||
camera_id, | ||
object_type, | ||
timestamps, | ||
pairs, | ||
itemHeadings, | ||
translations, | ||
), info_found |
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,36 @@ | ||
from ..camera_config import CameraConfig | ||
from ..stages.segment_trajectory.construct_segment_trajectory import SegmentPoint | ||
from ..stages.segment_trajectory.from_tracking_3d import SegmentTrajectoryMetadatum | ||
from ..stages.tracking_3d.tracking_3d import Metadatum as Tracking3DMetadatum | ||
from ..stages.tracking_3d.tracking_3d import Tracking3DResult | ||
from .associate_segment_mapping import associate_segment_mapping | ||
|
||
|
||
def get_tracks( | ||
sortmeta: "list[Tracking3DMetadatum]", | ||
ego_meta: "list[CameraConfig]", | ||
segment_mapping_meta: "list[SegmentTrajectoryMetadatum] | None" = None, | ||
base=None, | ||
) -> "dict[str, list[tuple[Tracking3DResult, CameraConfig, SegmentPoint | None]]]": | ||
trajectories: "dict[str, list[tuple[Tracking3DResult, CameraConfig, SegmentPoint | None]]]" = {} | ||
for i in range(len(sortmeta)): | ||
frame = sortmeta[i] | ||
for obj_id, tracking_result in frame.items(): | ||
if obj_id not in trajectories: | ||
trajectories[obj_id] = [] | ||
associated_ego_info = ego_meta[i] | ||
associated_segment_mapping = associate_segment_mapping( | ||
tracking_result, segment_mapping_meta | ||
) | ||
trajectories[obj_id].append( | ||
(tracking_result, associated_ego_info, associated_segment_mapping) | ||
) | ||
|
||
for trajectory in trajectories.values(): | ||
last = len(trajectory) - 1 | ||
for i, t in enumerate(trajectory): | ||
if i > 0: | ||
t[0].prev = trajectory[i - 1][0] | ||
if i < last: | ||
t[0].next = trajectory[i + 1][0] | ||
return trajectories |
Oops, something went wrong.