Read videos from HIM project files

This commit is contained in:
Bart Moyaers
2019-11-08 17:14:27 +01:00
parent 17360b2fd5
commit e4ba433a56
9 changed files with 610 additions and 22 deletions

26
util.py Normal file
View File

@@ -0,0 +1,26 @@
from typing import Dict, Any, Tuple, Union, Iterable
IntPoint = Tuple[int, int]
FloatPoint = Tuple[float, float]
Point = Union[IntPoint, FloatPoint]
AlgorithmParams = Dict[str, Any]
FRAME_SHAPE = (512, 424) # TODO: hardcoded
FRAME_WIDTH, FRAME_HEIGHT = FRAME_SHAPE
def bounding_box_centre(points: Iterable[FloatPoint]) -> FloatPoint:
n = 0
x_sum = 0.0
y_sum = 0.0
for x, y in points:
n += 1
x_sum += x
y_sum += y
x_centre = x_sum / n
y_centre = y_sum / n
return x_centre, y_centre