changeset 1207:36f0d18e1fad

work in progress on loading kitti (issue with int)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 26 Apr 2023 18:33:29 -0400
parents 3905b393ade0
children a07e455baaa6
files trafficintelligence/moving.py trafficintelligence/storage.py
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/trafficintelligence/moving.py	Wed Mar 22 23:29:09 2023 -0400
+++ b/trafficintelligence/moving.py	Wed Apr 26 18:33:29 2023 -0400
@@ -4,7 +4,7 @@
 import copy
 from math import sqrt, atan2, cos, sin
 
-from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, minimum
+from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, minimum,  issubdtype, integer as npinteger
 from matplotlib.pyplot import plot, text
 from scipy.stats import scoreatpercentile
 from scipy.spatial.distance import cdist
@@ -720,7 +720,7 @@
         return self.__len__() == 0
 
     def __getitem__(self, i):
-        if isinstance(i, int):
+        if isinstance(i, int) or issubdtype(i, npinteger):
             return Point(self.positions[0][i], self.positions[1][i])
         elif isinstance(i, slice):
             return Trajectory([self.positions[0][i],self.positions[1][i]])
--- a/trafficintelligence/storage.py	Wed Mar 22 23:29:09 2023 -0400
+++ b/trafficintelligence/storage.py	Wed Apr 26 18:33:29 2023 -0400
@@ -1313,7 +1313,7 @@
     
     header = ['frame', # 0, 1, ..., n
               'trackingid', # -1, 0 , 1, ..., k
-              'type',  # 'Car', 'Pedestrian', ...
+              'usertype',  # 'Car', 'Pedestrian', ...
               'truncation', # truncated pixel ratio [0..1]
               'occlusion', # 0=visible, 1=partly occluded, 2=fully occluded, 3=unknown
               'alpha', # object observation angle [-pi..pi]
@@ -1381,7 +1381,8 @@
             for i in range(4):
                 featureTrajectories[i].addPositionXY(xCoords[i], yCoords[i])                
             # check https://docs.opencv.org/3.4/d9/d0c/group__calib3d.html#ga1019495a2c8d1743ed5cc23fa0daff8c
-        newObj = moving.MovingObject(num = objNum, timeInterval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())), positions = t, userType = tmp.iloc[0].type, features = [moving.MovingObject(num = featureNum+i, timeInterval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())), positions = featureTrajectories[i]) for i in range(4)])
+        
+        newObj = moving.MovingObject(num = objNum, timeInterval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())), positions = t, velocities = t.differentiate(True), userType = tmp.iloc[0].usertype, features = [moving.MovingObject(num = featureNum+i, timeInterval = moving.TimeInterval(int(tmp.frame.min()), int(tmp.frame.max())), positions = featureTrajectories[i], velocities = featureTrajectories[i].differentiate(True)) for i in range(4)])
         objects.append(newObj)
         featureNum += 4
     return objects