Read videos from HIM project files
This commit is contained in:
26
util.py
Normal file
26
util.py
Normal 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
|
||||
Reference in New Issue
Block a user