data_manager.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:deepmodels 作者: learningsociety 项目源码 文件源码
def load_crop_imgs(img_fns, img_bboxes, img_sz, use_bgr=True):
  nb_channels = 3
  if not use_bgr:
    nb_channels = 1
  imgs = np.ndarray((len(img_fns), nb_channels, img_sz[0], img_sz[1]),
                    np.float32)
  print imgs.shape
  for i in range(len(img_fns)):
    im = cv2.imread(img_fns[i])
    imcrop = np.ndarray((img_sz[0], img_sz[1], nb_channels), np.float32)
    xs, ys, xe, ye = img_bboxes[i][0], img_bboxes[i][1], img_bboxes[i][
        0] + img_bboxes[i][2], img_bboxes[i][1] + img_bboxes[i][3]
    # Check if im is bgr or grayscale here?
    if use_bgr:
      imcrop = im[xs:xe, ys:ye, :]
    else:
      imcrop = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
      im = imcrop[xs:xe, ys:ye]
    im = cv2.resize(imcrop, img_sz)
    if use_bgr:
      imgs[i, :, :, :] = im
    else:
      imgs[i, 0, :, :] = im
  return imgs


# load images into a numpy array
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号