Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/utils.py @ 1222:69b531c7a061
added methods to reset trajectories and change object coordinates (including features)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 20 Jun 2023 15:42:19 -0400 |
| parents | 4356065ed3ca |
| children | 77fbd0e2ba7d |
comparison
equal
deleted
inserted
replaced
| 1221:5a207c838323 | 1222:69b531c7a061 |
|---|---|
| 430 window_values = cat_list[lower_bound_check:upper_bound_check] | 430 window_values = cat_list[lower_bound_check:upper_bound_check] |
| 431 smoothed[point] = max(set(window_values), key=window_values.count) | 431 smoothed[point] = max(set(window_values), key=window_values.count) |
| 432 return smoothed | 432 return smoothed |
| 433 | 433 |
| 434 def filterMovingWindow(inputSignal, halfWidth, mode = 'valid'): | 434 def filterMovingWindow(inputSignal, halfWidth, mode = 'valid'): |
| 435 '''Returns an array obtained after the smoothing of the input by a moving average | 435 '''Returns an array obtained after the smoothing of the 1-D input by a moving average |
| 436 The size of the output depends on the mode: 'full', 'same', 'valid' | 436 The size of the output depends on the mode: 'full', 'same', 'valid' |
| 437 See https://numpy.org/doc/stable/reference/generated/numpy.convolve.html.''' | 437 See https://numpy.org/doc/stable/reference/generated/numpy.convolve.html.''' |
| 438 width = min(len(inputSignal), int(halfWidth*2+1)) | 438 width = min(len(inputSignal), int(halfWidth*2+1)) |
| 439 win = ones(width,'d') | 439 win = ones(width,'d') |
| 440 return convolve(win/width, array(inputSignal), mode) | 440 return convolve(win/width, array(inputSignal), mode) |
