Compare commits
No commits in common. "a7c6aaacd30bbec02b6fa5d531623ade7b3ade4f" and "5bf60e4579a375063e3cc04fcebe17834ba69ef4" have entirely different histories.
a7c6aaacd3
...
5bf60e4579
4 changed files with 73 additions and 105 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -290,49 +290,49 @@ class Track:
|
||||||
t.predictions,
|
t.predictions,
|
||||||
t.fps/step_size)
|
t.fps/step_size)
|
||||||
|
|
||||||
# def get_binned(self, bin_size=.5, remove_overlap=True):
|
def get_binned(self, bin_size=.5, remove_overlap=True):
|
||||||
# """
|
"""
|
||||||
# For an experiment: what if we predict using only concrete positions, by mapping
|
For an experiment: what if we predict using only concrete positions, by mapping
|
||||||
# dx,dy to a grid. Thus prediction can be for 8 moves, or rather headings
|
dx,dy to a grid. Thus prediction can be for 8 moves, or rather headings
|
||||||
# see ~/notes/attachments example svg
|
see ~/notes/attachments example svg
|
||||||
# """
|
"""
|
||||||
|
|
||||||
# new_history: List[Detection] = []
|
new_history: List[Detection] = []
|
||||||
# for i, (det0, det1) in enumerate(zip(self.history[:-1], self.history[1:]):
|
for i, (det0, det1) in enumerate(zip(self.history[:-1], self.history[1:]):
|
||||||
# if i == 0:
|
if i == 0:
|
||||||
# new_history.append(det0)
|
new_history.append(det0)
|
||||||
# continue
|
continue
|
||||||
# if abs(det1.x - new_history[-1].x) < bin_size or abs(det1.y - new_history[-1].y) < bin_size:
|
if abs(det1.x - new_history[-1].x) < bin_size or abs(det1.y - new_history[-1].y) < bin_size:
|
||||||
# continue
|
continue
|
||||||
|
|
||||||
# # det1 falls outside of the box [-bin_size:+bin_size] around last detection
|
# det1 falls outside of the box [-bin_size:+bin_size] around last detection
|
||||||
|
|
||||||
# # 1. Interpolate exact point between det0 and det1 that this happens
|
# 1. Interpolate exact point between det0 and det1 that this happens
|
||||||
# if abs(det1.x - new_history[-1].x) >= bin_size:
|
if abs(det1.x - new_history[-1].x) >= bin_size:
|
||||||
# if det1.x - new_history[-1].x >= bin_size:
|
if det1.x - new_history[-1].x >= bin_size:
|
||||||
# # det1 left of last
|
# det1 left of last
|
||||||
# x = new_history[-1].x + bin_size
|
x = new_history[-1].x + bin_size
|
||||||
# f = inv_lerp(det0.x, det1.x, x)
|
f = inv_lerp(det0.x, det1.x, x)
|
||||||
# elif new_history[-1].x - det1.x >= bin_size:
|
elif new_history[-1].x - det1.x >= bin_size:
|
||||||
# # det1 left of last
|
# det1 left of last
|
||||||
# x = new_history[-1].x - bin_size
|
x = new_history[-1].x - bin_size
|
||||||
# f = inv_lerp(det0.x, det1.x, x)
|
f = inv_lerp(det0.x, det1.x, x)
|
||||||
# y = lerp(det0.y, det1.y, f)
|
y = lerp(det0.y, det1.y, f)
|
||||||
# if abs(det1.y - new_history[-1].y) >= bin_size:
|
if abs(det1.y - new_history[-1].y) >= bin_size:
|
||||||
# if det1.y - new_history[-1].y >= bin_size:
|
if det1.y - new_history[-1].y >= bin_size:
|
||||||
# # det1 left of last
|
# det1 left of last
|
||||||
# y = new_history[-1].y + bin_size
|
y = new_history[-1].y + bin_size
|
||||||
# f = inv_lerp(det0.y, det1.y, x)
|
f = inv_lerp(det0.y, det1.y, x)
|
||||||
# elif new_history[-1].y - det1.y >= bin_size:
|
elif new_history[-1].y - det1.y >= bin_size:
|
||||||
# # det1 left of last
|
# det1 left of last
|
||||||
# y = new_history[-1].y - bin_size
|
y = new_history[-1].y - bin_size
|
||||||
# f = inv_lerp(det0.y, det1.y, x)
|
f = inv_lerp(det0.y, det1.y, x)
|
||||||
# x = lerp(det0.x, det1.x, f)
|
x = lerp(det0.x, det1.x, f)
|
||||||
|
|
||||||
|
|
||||||
# # 2. Find closest point on rectangle (rectangle's four corners, or 4 midpoints)
|
# 2. Find closest point on rectangle (rectangle's four corners, or 4 midpoints)
|
||||||
# points = [[bin_size, 0], [bin_size, bin_size], [0, bin_size], [-bin_size, bin_size], [-bin_size, 0], [-bin_size, -bin_size], [0, -bin_size], [bin_size, -bin_size]]
|
points = [[bin_size, 0], [bin_size, bin_size], [0, bin_size], [-bin_size, bin_size], [-bin_size, 0], [-bin_size, -bin_size], [0, -bin_size], [bin_size, -bin_size]]
|
||||||
# # todo Offsets to points:[ history for in points]
|
# todo Offsets to points:[ history for in points]
|
||||||
|
|
||||||
|
|
||||||
def to_trajectron_node(self, camera: Camera, env: Environment) -> Node:
|
def to_trajectron_node(self, camera: Camera, env: Environment) -> Node:
|
||||||
|
|
|
@ -11,7 +11,7 @@ import pandas as pd
|
||||||
import trap.tracker
|
import trap.tracker
|
||||||
from trap.config import parser
|
from trap.config import parser
|
||||||
from trap.frame_emitter import Camera, Detection, DetectionState, video_src_from_config, Frame
|
from trap.frame_emitter import Camera, Detection, DetectionState, video_src_from_config, Frame
|
||||||
from trap.tracker import DETECTOR_YOLOv8, FinalDisplacementFilter, Smoother, TrackReader, _yolov8_track, Track, TrainingDataWriter, Tracker, read_tracks_json
|
from trap.tracker import DETECTOR_YOLOv8, Smoother, TrackReader, _yolov8_track, Track, TrainingDataWriter, Tracker, read_tracks_json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -297,9 +297,6 @@ def blacklist_tracks():
|
||||||
path: Path = config.save_for_training
|
path: Path = config.save_for_training
|
||||||
|
|
||||||
reader = TrackReader(path, config.camera.fps, exclude_whitelisted = True)
|
reader = TrackReader(path, config.camera.fps, exclude_whitelisted = True)
|
||||||
tracks = [t for t in reader]
|
|
||||||
filter = FinalDisplacementFilter(2.0)
|
|
||||||
tracks = filter.apply(tracks, config.camera)
|
|
||||||
# blacklist_file = path / "blacklist.jsonl"
|
# blacklist_file = path / "blacklist.jsonl"
|
||||||
# whitelist_file = path / "whitelist.jsonl" # for skipping
|
# whitelist_file = path / "whitelist.jsonl" # for skipping
|
||||||
# tracks_file = path / "tracks.json"
|
# tracks_file = path / "tracks.json"
|
||||||
|
@ -314,7 +311,7 @@ def blacklist_tracks():
|
||||||
# whitelist = []
|
# whitelist = []
|
||||||
smoother = Smoother()
|
smoother = Smoother()
|
||||||
try:
|
try:
|
||||||
for track in tqdm.tqdm(tracks):
|
for track in reader:
|
||||||
|
|
||||||
if len(track.history) < 5:
|
if len(track.history) < 5:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue