Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/storage.py @ 1287:76f5693b530c
updated tests for numpy 2
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sat, 20 Jul 2024 20:35:21 -0400 |
| parents | 9562f5e8edf8 |
| children | 46a30ce1a2e4 |
comparison
equal
deleted
inserted
replaced
| 1284:8e30c9a6ac6f | 1287:76f5693b530c |
|---|---|
| 5 from pathlib import Path | 5 from pathlib import Path |
| 6 import shutil | 6 import shutil |
| 7 from copy import copy | 7 from copy import copy |
| 8 import sqlite3, logging | 8 import sqlite3, logging |
| 9 | 9 |
| 10 from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg, int32, int64, reshape, dot, vstack, transpose, ones, zeros_like, pi, NaN | 10 from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg, int32, int64, reshape, dot, vstack, transpose, ones, zeros_like, pi, nan |
| 11 from pandas import read_csv, merge, concat, DataFrame | 11 from pandas import read_csv, merge, concat, DataFrame |
| 12 | 12 |
| 13 from trafficintelligence import utils, moving, events, indicators | 13 from trafficintelligence import utils, moving, events, indicators |
| 14 from trafficintelligence.base import VideoFilenameAddable | 14 from trafficintelligence.base import VideoFilenameAddable |
| 15 | 15 |
| 1357 interval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())) | 1357 interval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())) |
| 1358 userType = tmp.iloc[0].usertype | 1358 userType = tmp.iloc[0].usertype |
| 1359 if len(tmp) != interval.length(): #interpolate | 1359 if len(tmp) != interval.length(): #interpolate |
| 1360 print(objNum, len(tmp), interval.length()) | 1360 print(objNum, len(tmp), interval.length()) |
| 1361 instants = set(interval).difference(tmp.frame) | 1361 instants = set(interval).difference(tmp.frame) |
| 1362 missing = concat([tmp[['frame']+header[10:]], DataFrame([[t]+[NaN]*(len(header)-10) for t in instants], columns = ['frame']+header[10:])], ignore_index=True).sort_values('frame') | 1362 missing = concat([tmp[['frame']+header[10:]], DataFrame([[t]+[nan]*(len(header)-10) for t in instants], columns = ['frame']+header[10:])], ignore_index=True).sort_values('frame') |
| 1363 tmp = missing.interpolate() | 1363 tmp = missing.interpolate() |
| 1364 featureTrajectories = [moving.Trajectory() for i in range(4)] | 1364 featureTrajectories = [moving.Trajectory() for i in range(4)] |
| 1365 for i, r in tmp.iterrows(): | 1365 for i, r in tmp.iterrows(): |
| 1366 if kittiCalibration is not None: | 1366 if kittiCalibration is not None: |
| 1367 _, Tr_imu_to_world = oxts[r.frame] | 1367 _, Tr_imu_to_world = oxts[r.frame] |
| 1499 interval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())) | 1499 interval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())) |
| 1500 userType = tmp.iloc[0].usertype | 1500 userType = tmp.iloc[0].usertype |
| 1501 if len(tmp) != interval.length(): #interpolate | 1501 if len(tmp) != interval.length(): #interpolate |
| 1502 print(objNum, len(tmp), interval.length()) | 1502 print(objNum, len(tmp), interval.length()) |
| 1503 instants = set(interval).difference(tmp.frame) | 1503 instants = set(interval).difference(tmp.frame) |
| 1504 missing = concat([tmp[['frame', 'x', 'y']], DataFrame([[t, NaN, NaN] for t in instants], columns = ['frame', 'x', 'y'])], ignore_index=True).sort_values('frame') | 1504 missing = concat([tmp[['frame', 'x', 'y']], DataFrame([[t, nan, nan] for t in instants], columns = ['frame', 'x', 'y'])], ignore_index=True).sort_values('frame') |
| 1505 tmp = missing.interpolate() | 1505 tmp = missing.interpolate() |
| 1506 #print(tmp.info()) | 1506 #print(tmp.info()) |
| 1507 if interval.length()>1: | 1507 if interval.length()>1: |
| 1508 t = moving.Trajectory([tmp.x.to_list(), tmp.y.to_list()]) | 1508 t = moving.Trajectory([tmp.x.to_list(), tmp.y.to_list()]) |
| 1509 if halfWidth is not None: | 1509 if halfWidth is not None: |
