当前位置: 首页>>代码示例>>Python>>正文


Python preprocessing.cv2resizeminedge方法代码示例

本文整理汇总了Python中preprocessing.cv2resizeminedge方法的典型用法代码示例。如果您正苦于以下问题:Python preprocessing.cv2resizeminedge方法的具体用法?Python preprocessing.cv2resizeminedge怎么用?Python preprocessing.cv2resizeminedge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在preprocessing的用法示例。


在下文中一共展示了preprocessing.cv2resizeminedge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ParallelPreprocessing

# 需要导入模块: import preprocessing [as 别名]
# 或者: from preprocessing import cv2resizeminedge [as 别名]
def ParallelPreprocessing(args):
  """Parallel preprocessing: rotation, resize and jpeg encoding to string."""
  (vid_path, timestep, num_timesteps, view) = args
  try:
    image = GetSpecificFrame(vid_path, timestep)

    # Resizing.
    resize_str = ''
    if FLAGS.resize_min_edge > 0:
      resize_str += ', resize ' + shapestring(image)
      image = cv2resizeminedge(image, FLAGS.resize_min_edge)
      resize_str += ' => ' + shapestring(image)

    # Rotating.
    rotate = None
    if FLAGS.rotate:
      rotate = FLAGS.rotate
      if FLAGS.rotate_if_matching is not None:
        rotate = None
        patt = re.compile(FLAGS.rotate_if_matching)
        if patt.match(vid_path) is not None:
          rotate = FLAGS.rotate
      if rotate is not None:
        image = cv2rotateimage(image, FLAGS.rotate)

    # Jpeg encoding.
    image = Image.fromarray(image)
    im_string = bytes_feature([JpegString(image)])

    if timestep % FLAGS.log_frequency == 0:
      tf.logging.info('Loaded frame %d / %d for %s (rotation %s%s) from %s' %
                      (timestep, num_timesteps, view, str(rotate), resize_str,
                       vid_path))
    return im_string
  except cv2.error as e:
    tf.logging.error('Error while loading frame %d of %s: %s' %
                     (timestep, vid_path, str(e)))
    return None 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:40,代码来源:videos_to_tfrecords.py


注:本文中的preprocessing.cv2resizeminedge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。