Mercurial Hosting > traffic-intelligence
changeset 1272:785c86013d2c
added moving average smoothing for kitti loading
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 17 Jun 2024 22:49:22 -0400 |
parents | b2f90cada58f |
children | 0bfcbc58352f |
files | trafficintelligence/pavement.py trafficintelligence/storage.py |
diffstat | 2 files changed, 22 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/trafficintelligence/pavement.py Fri Jun 14 15:56:01 2024 -0400 +++ b/trafficintelligence/pavement.py Mon Jun 17 22:49:22 2024 -0400 @@ -35,10 +35,10 @@ def caracteristiques(rtss, maintenanceLevel, rtssWeatherStation, fmr, paintType): '''Computes characteristic data for the RTSS (class rtss) - maintenanceLevel = pylab.csv2rec('C:\\Users\Alexandre\Desktop\Projet_maitrise_recherche\BDD_access\\analyse_donnees_deneigement\\exigence_circuits.txt', delimiter = ';') - rtssWeatherStation = pylab.csv2rec('C:\\Users\Alexandre\Desktop\Projet_maitrise_recherche\stations_environnement_canada\\rtssWeatherStation\juste_pour_rtss_avec_donnees_entretien_hiv\\rtssWeatherStation_EC3.txt', delimiter = ',') - fmr = pylab.csv2rec('C:\\Users\Alexandre\Desktop\Projet_maitrise_recherche\BDD_access\\analyse_donnees_deneigement\\fmr.txt', delimiter = ';') - paintType = pylab.csv2rec('C:\\Users\Alexandre\Desktop\Projet_maitrise_recherche\BDD_access\\analyse_donnees_deneigement\\type_peinture.txt', delimiter = ';') + maintenanceLevel = pylab.csv2rec('C:\\Users\\Alexandre\\Desktop\\Projet_maitrise_recherche\\BDD_access\\analyse_donnees_deneigement\\exigence_circuits.txt', delimiter = ';') + rtssWeatherStation = pylab.csv2rec('C:\\Users\\Alexandre\\Desktop\\Projet_maitrise_recherche\\stations_environnement_canada\\rtssWeatherStation\\juste_pour_rtss_avec_donnees_entretien_hiv\\rtssWeatherStation_EC3.txt', delimiter = ',') + fmr = pylab.csv2rec('C:\\Users\\Alexandre\\Desktop\\Projet_maitrise_recherche\\BDD_access\\analyse_donnees_deneigement\\fmr.txt', delimiter = ';') + paintType = pylab.csv2rec('C:\\Users\\Alexandre\\Desktop\\Projet_maitrise_recherche\\BDD_access\\analyse_donnees_deneigement\\type_peinture.txt', delimiter = ';') ''' # determination exigence deneigement if rtss.id in maintenanceLevel['rtss_debut']: @@ -104,7 +104,7 @@ def winterMaintenanceIndicators(data, startDate, endDate, circuitReference, snowThreshold): '''Computes several winter maintenance indicators - data = entretien_hivernal = pylab.csv2rec('C:\\Users\Alexandre\Documents\Cours\Poly\Projet\mesures_entretien_hivernal\mesures_deneigement.txt', delimiter = ',')''' + data = entretien_hivernal = pylab.csv2rec('C:\\Users\\Alexandre\\Documents\\Cours\\Poly\\Projet\\mesures_entretien_hivernal\\mesures_deneigement.txt', delimiter = ',')''' somme_eau, somme_neige, somme_abrasif, somme_sel, somme_lc, somme_lrg, somme_lrd, compteur_premiere_neige, compteur_somme_abrasif = 0,0,0,0,0,0,0,0,0 if circuitReference in data['ref_circuit']:
--- a/trafficintelligence/storage.py Fri Jun 14 15:56:01 2024 -0400 +++ b/trafficintelligence/storage.py Mon Jun 17 22:49:22 2024 -0400 @@ -1312,13 +1312,14 @@ # from https://github.com/utiasSTARS/pykitti/blob/master/pykitti/utils.py -def loadTrajectoriesFromKITTI(filename, kittiCalibration = None, oxts = None, resultFile = False): +def loadTrajectoriesFromKITTI(filename, kittiCalibration = None, oxts = None, resultFile = False, halfWidth = None): '''Reads data from KITTI ground truth or output from an object detection and tracking method kittiCalibration is obtained from loading training/testing calibration file for each sequence 00XX.txt oxts is obtained using utils.load_oxts_packets_and_poses(['./training/oxts/0001.txt']) from pykitti + Ref: https://github.com/pratikac/kitti/blob/master/readme.tracking.txt - Ref: https://github.com/pratikac/kitti/blob/master/readme.tracking.txt''' + non-null halfWidth indicates positions are smoothed using moving window avefraging''' from pykitti.utils import roty, rotz from trafficintelligence.cvutils import cartesian2Homogeneous @@ -1431,6 +1432,9 @@ featureTrajectories[j].addPositionXY(xCoords[j], yCoords[j]) # check https://docs.opencv.org/3.4/d9/d0c/group__calib3d.html#ga1019495a2c8d1743ed5cc23fa0daff8c if interval.length()>1: + if halfWidth is not None: + for i in range(4): + featureTrajectories[i] = featureTrajectories[i].filterMovingWindow(halfWidth) objects.append(moving.MovingObject(num = objNum, timeInterval = interval, positions = t, velocities = t.differentiate(True), userType = userType, features = [moving.MovingObject(num = featureNum+i, timeInterval = copy(interval), positions = featureTrajectories[i], velocities = featureTrajectories[i].differentiate(True)) for i in range(4)])) featureNum += 4 @@ -1470,17 +1474,22 @@ 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 + if halfWidth is not None: + for i in range(4): + featureTrajectories[i] = featureTrajectories[i].filterMovingWindow(halfWidth) objects.append(moving.MovingObject(num = max([o.getNum() for o in objects])+1, timeInterval = interval, positions = t, velocities = t.differentiate(True), userType = 'Car', features = [moving.MovingObject(num = featureNum+i, timeInterval = copy(interval), positions = featureTrajectories[i], velocities = featureTrajectories[i].differentiate(True)) for i in range(4)])) return objects -def loadTrajectoriesFromKITTI2D(filename, kittiCalibration = None, oxts = None): +def loadTrajectoriesFromKITTI2D(filename, kittiCalibration = None, oxts = None, halfWidth = None): '''Loads x,y coordinate series e.g. obtained by projecting from image to ground world plane using a homography Format: frame_id,track_id,usertype,x,y,score if oxts is not None, it is obtained using utils.load_oxts_packets_and_poses(['./training/oxts/0001.txt']) from pykitti - to generate the movement of the ego vehicle''' + to generate the movement of the ego vehicle + + non-null halfWidth indicates positions are smoothed using moving window avefraging''' header = ['frame','trackingid','usertype','x','y','score'] data = read_csv(filename, delimiter=' ', names = header) @@ -1497,6 +1506,8 @@ #print(tmp.info()) if interval.length()>1: t = moving.Trajectory([tmp.x.to_list(), tmp.y.to_list()]) + if halfWidth is not None: + t = t.filterMovingWindow(halfWidth) objects.append(moving.MovingObject(num = objNum, timeInterval = interval, positions = t, velocities = t.differentiate(True), userType = userType)) # ego vehicle @@ -1526,6 +1537,8 @@ xCoords = worldCorners[:4,0] yCoords = worldCorners[:4,1] t.addPositionXY(xCoords.mean(), yCoords.mean()) + if halfWidth is not None: + t = t.filterMovingWindow(halfWidth) objects.append(moving.MovingObject(num = max([o.getNum() for o in objects])+1, timeInterval = interval, positions = t, velocities = t.differentiate(True), userType = 'Car')) return objects