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