當前位置: 首頁>>代碼示例>>Python>>正文


Python util.load_image方法代碼示例

本文整理匯總了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) 
開發者ID:guohengkai,項目名稱:region-ensemble-network,代碼行數:25,代碼來源:get_centers.py

示例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)) 
開發者ID:guohengkai,項目名稱:region-ensemble-network,代碼行數:27,代碼來源:show_result.py

示例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 
開發者ID:CreativeCodingLab,項目名稱:DeepIllumination,代碼行數:9,代碼來源:data.py

示例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) 
開發者ID:guohengkai,項目名稱:region-ensemble-network,代碼行數:30,代碼來源:hand_model.py


注:本文中的util.load_image方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。