本文整理汇总了Python中util.load_image方法的典型用法代码示例。如果您正苦于以下问题:Python util.load_image方法的具体用法?Python util.load_image怎么用?Python util.load_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util.load_image方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import util [as 别名]
# 或者: from util import load_image [as 别名]
def main():
if len(sys.argv) < 4:
print_usage()
dataset = sys.argv[1]
base_dir = sys.argv[2]
out_file = sys.argv[3]
names = util.load_names(dataset)
centers = []
for idx, name in enumerate(names):
if dataset == 'nyu': # use synthetic image to compute center
name = name.replace('depth', 'synthdepth')
img = util.load_image(dataset, os.path.join(base_dir, name))
if dataset == 'icvl':
center = util.get_center(img, upper=500, lower=0)
elif dataset == 'nyu':
center = util.get_center(img, upper=1300, lower=500)
elif dataset == 'msra':
center = util.get_center(img, upper=1000, lower=10)
centers.append(center.reshape((1, 3)))
if idx % 500 == 0:
print('{}/{}'.format(idx + 1, len(names)))
util.save_results(centers, out_file)
示例2: show_pose
# 需要导入模块: import util [as 别名]
# 或者: from util import load_image [as 别名]
def show_pose(dataset_model, dataset_image, base_dir, outputs, list_file, save_dir,
is_flip, gif):
if list_file is None:
names = util.load_names(dataset_image)
else:
with open(list_file) as f:
names = [line.strip() for line in f]
assert len(names) == outputs.shape[0]
for idx, (name, pose) in enumerate(zip(names, outputs)):
img = util.load_image(dataset_image, os.path.join(base_dir, name),
is_flip=is_flip)
img = img.astype(np.float32)
img = (img - img.min()) / (img.max() - img.min()) * 255
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
img = util.draw_pose(dataset_model, img, pose)
cv2.imshow('result', img / 255)
if save_dir is not None:
cv2.imwrite(os.path.join(save_dir, '{:>06d}.png'.format(idx)), img)
ch = cv2.waitKey(25)
if ch == ord('q'):
break
if gif and save_dir is not None:
os.system('convert -loop 0 -page +0+0 -delay 25 {0}/*.png {0}/output.gif'.format(save_dir))
示例3: __getitem__
# 需要导入模块: import util [as 别名]
# 或者: from util import load_image [as 别名]
def __getitem__(self, index):
albedo = load_image(join(self.albedo_path, self.image_filenames[index]))
depth = load_image(join(self.depth_path, self.image_filenames[index]))
direct = load_image(join(self.direct_path, self.image_filenames[index]))
normal = load_image(join(self.normal_path, self.image_filenames[index]))
gt = load_image(join(self.gt_path, self.image_filenames[index]))
return albedo, direct, normal, depth, gt
示例4: detect_files
# 需要导入模块: import util [as 别名]
# 或者: from util import load_image [as 别名]
def detect_files(self, base_dir, names, centers=None, dataset=None, max_batch=64, is_flip=False):
assert max_batch > 0
if dataset is None:
dataset = self._dataset
batch_imgs = []
batch_centers = []
results = []
for idx, name in enumerate(names):
img = util.load_image(dataset, os.path.join(base_dir, name),
is_flip=is_flip)
batch_imgs.append(img)
if centers is None:
batch_centers.append(self._center_loader(img))
else:
batch_centers.append(centers[idx, :])
if len(batch_imgs) == max_batch:
for line in self.detect_images(batch_imgs, batch_centers):
results.append(line)
del batch_imgs[:]
del batch_centers[:]
print('{}/{}'.format(idx + 1, len(names)))
if batch_imgs:
for line in self.detect_images(batch_imgs, batch_centers):
results.append(line)
print('done!')
return np.array(results)