Mercurial Hosting > traffic-intelligence
diff scripts/dltrack.py @ 1265:0f5bebd62a55
minor modifications
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 24 May 2024 16:15:38 -0400 |
parents | dff5b678a33a |
children | 27b206d118b7 |
line wrap: on
line diff
--- a/scripts/dltrack.py Wed May 22 17:11:40 2024 -0400 +++ b/scripts/dltrack.py Fri May 24 16:15:38 2024 -0400 @@ -235,18 +235,19 @@ # project, smooth and save for num, obj in objects.items(): features = obj.getFeatures() - if moving.userTypeNames[obj.getUserType()] == 'pedestrian': - assert len(features) == 2 - t1 = features[0].getPositions() - t2 = features[1].getPositions() - t = [[(p1.x+p2.x)/2., max(p1.y, p2.y)] for p1, p2 in zip(t1, t2)] - else: - t = [] - for instant in obj.getTimeInterval(): - points = [f.getPositionAtInstant(instant) for f in features if f.existsAtInstant(instant)] - t.append(moving.Point.agg(points, np.mean).aslist()) - #t = sum([f.getPositions().asArray() for f in features])/len(features) - #t = (moving.Trajectory.add(t1, t2)*0.5).asArray() + # possible to save bottom pedestrians? not consistent with other users + # if moving.userTypeNames[obj.getUserType()] == 'pedestrian': + # assert len(features) == 2 + # t1 = features[0].getPositions() + # t2 = features[1].getPositions() + # t = [[(p1.x+p2.x)/2., max(p1.y, p2.y)] for p1, p2 in zip(t1, t2)] + # else: + t = [] + for instant in obj.getTimeInterval(): + points = [f.getPositionAtInstant(instant) for f in features if f.existsAtInstant(instant)] + t.append(moving.Point.agg(points, np.mean).aslist()) + #t = sum([f.getPositions().asArray() for f in features])/len(features) + #t = (moving.Trajectory.add(t1, t2)*0.5).asArray() projected = cvutils.imageToWorldProject(np.array(t).T, intrinsicCameraMatrix, distortionCoefficients, homography) featureNum = features[0].getNum() obj.features=[moving.MovingObject(featureNum, obj.getTimeInterval(), moving.Trajectory(projected.tolist()))]