[dd6877]: / mediaug / utils.py

Download this file

25 lines (20 with data), 689 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import pathlib
def convert_array_to_poly(arr):
""" Convert array of (x,y) coordinates, nx2, to
a Polygon object for Polygon package
Args:
arr (np.array): Array of the polygon
Returns:
asn (list): The polygon in a list
"""
return arr.flatten().tolist()
def create_dirs(base_path, dir_list=[]):
"""create dirs under the base path
Args:
base_path (str): The base of the directory paths
dir_list (list[str]): List of paths relative to the base dir
"""
pathlib.Path(base_path).mkdir(parents=True, exist_ok=True)
for new_dir in dir_list:
pathlib.Path(os.path.join(base_path, new_dir)).mkdir(parents=True)