def load_images(queue: PriorityQueue,
source: int,
file_path: str,
target_width: int,
target_height: int,
display_progress: bool=False):
window = 'image'
if display_progress:
cv2.namedWindow(window)
for file in iglob(path.join(file_path, '**', '*.jpg'), recursive=True):
buffer = cv2.imread(file)
buffer = cv2.resize(buffer, (target_width, target_height), interpolation=cv2.INTER_AREA)
random_priority = random()
queue.put((random_priority, (buffer, source)))
if display_progress:
cv2.imshow(window, buffer)
if (cv2.waitKey(33) & 0xff) == 27:
break
if display_progress:
cv2.destroyWindow(window)
评论列表
文章目录