-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from OpenTrafficCam/user-story/2061-boundingb…
…oxes-of-detections-per-frame User story/2061 boundingboxes of detections per frame
- Loading branch information
Showing
30 changed files
with
1,054 additions
and
137 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class SkipTime: | ||
seconds: int | ||
frames: int |
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
Empty file.
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,57 @@ | ||
from datetime import timedelta | ||
|
||
from OTAnalytics.application.state import TrackViewState, VideosMetadata | ||
from OTAnalytics.domain.date import DateRange | ||
|
||
|
||
class SwitchToNextFrame: | ||
def __init__(self, state: TrackViewState, videos_metadata: VideosMetadata) -> None: | ||
self._state = state | ||
self._videos_metadata = videos_metadata | ||
|
||
def set_next_frame(self) -> None: | ||
if filter_element := self._state.filter_element.get(): | ||
current_date_range = filter_element.date_range | ||
if current_date_range.start_date and current_date_range.end_date: | ||
if metadata := self._videos_metadata.get_metadata_for( | ||
current_date_range.end_date | ||
): | ||
fps = metadata.fps | ||
skip_time = self._state.skip_time.get() | ||
subseconds = min(skip_time.frames, fps) / fps | ||
milliseconds = subseconds * 1000 | ||
current_skip = timedelta( | ||
seconds=skip_time.seconds, milliseconds=milliseconds | ||
) | ||
next_start = current_date_range.start_date + current_skip | ||
next_end = current_date_range.end_date + current_skip | ||
next_date_range = DateRange(next_start, next_end) | ||
self._state.filter_element.set( | ||
filter_element.derive_date(next_date_range) | ||
) | ||
|
||
|
||
class SwitchToPreviousFrame: | ||
def __init__(self, state: TrackViewState, videos_metadata: VideosMetadata) -> None: | ||
self._state = state | ||
self._videos_metadata = videos_metadata | ||
|
||
def set_previous_frame(self) -> None: | ||
if filter_element := self._state.filter_element.get(): | ||
current_date_range = filter_element.date_range | ||
if current_date_range.start_date and current_date_range.end_date: | ||
if metadata := self._videos_metadata.get_metadata_for( | ||
current_date_range.end_date | ||
): | ||
fps = metadata.fps | ||
skip_time = self._state.skip_time.get() | ||
subseconds = min(skip_time.frames, fps) / fps | ||
current_skip = timedelta(seconds=skip_time.seconds) + timedelta( | ||
seconds=subseconds | ||
) | ||
next_start = current_date_range.start_date - current_skip | ||
next_end = current_date_range.end_date - current_skip | ||
next_date_range = DateRange(next_start, next_end) | ||
self._state.filter_element.set( | ||
filter_element.derive_date(next_date_range) | ||
) |
Empty file.
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.