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


Python preprocessing.cv2rotateimage方法代碼示例

本文整理匯總了Python中preprocessing.cv2rotateimage方法的典型用法代碼示例。如果您正苦於以下問題:Python preprocessing.cv2rotateimage方法的具體用法?Python preprocessing.cv2rotateimage怎麽用?Python preprocessing.cv2rotateimage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在preprocessing的用法示例。


在下文中一共展示了preprocessing.cv2rotateimage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ParallelPreprocessing

# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import cv2rotateimage [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.cv2rotateimage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。