Module AmpliVision.src.objs.utils.utils_geometry

Functions

def calculate_distances(points: list[tuple]) ‑> list[float]

Calculate distances between each pair of points and diagonals.

points: list of 4 points (x,y)

def contour_is_circular(contour: numpy.ndarray)

Contour is circular


Function that checks if a contour is circular.

Args:

  • contour: Contour of the object in the image.
def distance(p1: float, p2: float)

p1 = (x1,y1) p2 = (x2,y2)

def draw_square_on_image(points: list[tuple], img: numpy.ndarray, timeout: int = 1000)

Draws a square on the image using the provided points.

points: list of 4 points (x,y) img: the image on which to draw the square

def find_center_of_contour(contour: numpy.ndarray)

Finds Center Point Of A Single Contour

contour: single contour

def find_center_of_points(points: list[tuple])

Finds Center Point Of A List Of Points

points: list of points

def is_arranged_as_square(points: list[tuple], img, SQUARE_LENGTH: int, recursion_flag: bool = 0, debug: bool = False)

Checks If A Combination Of Points Are Arranged In The Shape Of A Square

points= combination of 4 points (x,y)

def is_square(points: list[tuple], dists: list[float], SQUARE_LENGTH: int, debug: bool = False)

Checks if a set of points forms a square.


points: list of 4 points (x,y) dists: list of distances between each pair of points SQUARE_LENGTH: expected side length of the square

Arranged as:

3—2

0—1