-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helpers.py
38 lines (29 loc) · 869 Bytes
/
Helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import glob
import cv2 as cv2
import numpy as np
import matplotlib.pyplot as plt
# import random
import math
from tqdm import tqdm
def load_images(path):
image_list = []
images = glob.glob(path)
for index in range(len(images)):
image = cv2.cvtColor(cv2.imread(images[index]), cv2.COLOR_BGR2RGB)
image_list.append(image)
# image_list.append(cv2.resize(image,(1280,720)))
return image_list
def read_images(path):
images = glob.glob(path)
return images
def load_images_from_path(path):
image_list = []
for p in tqdm(path):
image = cv2.cvtColor(cv2.imread(p), cv2.COLOR_BGR2RGB)
image_list.append(image)
return image_list
def replace_labels(path):
labelpath = []
for p in path:
labelpath.append(p.replace('.jpg', '.txt')) #找到对应图片的标签
return labelpath