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


Python cv2.BORDER_WRAP属性代码示例

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


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

示例1: E2P

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import BORDER_WRAP [as 别名]
def E2P(image, corner_i, corner_j, wall_height, camera, resolution=512, is_wall=True):
    """convert panorama to persepctive image
    """
    corner_i = corner_i - camera
    corner_j = corner_j - camera

    if is_wall:
        xs = np.linspace(corner_i[0], corner_j[0], resolution)[None].repeat(resolution, 0)
        ys = np.linspace(corner_i[1], corner_j[1], resolution)[None].repeat(resolution, 0)
        zs = np.linspace(-camera[-1], wall_height - camera[-1], resolution)[:, None].repeat(resolution, 1)
    else:
        xs = np.linspace(corner_i[0], corner_j[0], resolution)[None].repeat(resolution, 0)
        ys = np.linspace(corner_i[1], corner_j[1], resolution)[:, None].repeat(resolution, 1)
        zs = np.zeros_like(xs) + wall_height - camera[-1]

    coorx, coory = xyz_2_coorxy(xs, ys, zs)

    persp = cv2.remap(image, coorx.astype(np.float32), coory.astype(np.float32), 
                      cv2.INTER_CUBIC, borderMode=cv2.BORDER_WRAP)

    return persp 
开发者ID:bertjiazheng,项目名称:Structured3D,代码行数:23,代码来源:visualize_mesh.py

示例2: blur_edge

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import BORDER_WRAP [as 别名]
def blur_edge(img, d=31):
    h, w  = img.shape[:2]
    img_pad = cv2.copyMakeBorder(img, d, d, d, d, cv2.BORDER_WRAP)
    img_blur = cv2.GaussianBlur(img_pad, (2*d+1, 2*d+1), -1)[d:-d,d:-d]
    y, x = np.indices((h, w))
    dist = np.dstack([x, w-x-1, y, h-y-1]).min(-1)
    w = np.minimum(np.float32(dist)/d, 1.0)
    return img*w + img_blur*(1-w) 
开发者ID:makelove,项目名称:OpenCV-Python-Tutorial,代码行数:10,代码来源:deconvolution.py

示例3: _smoothen_alphas

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import BORDER_WRAP [as 别名]
def _smoothen_alphas(cls, alphas, sigma):
        if sigma <= 0.0+1e-2:
            return alphas

        ksize = max(int(sigma * 2.5), 3)
        ksize_y, ksize_x = (1, ksize)
        if ksize_x % 2 == 0:
            ksize_x += 1

        # we fake here cv2.BORDER_WRAP, because GaussianBlur does not
        # support that mode, i.e. we want:
        #   cdefgh|abcdefgh|abcdefg
        alphas = np.concatenate([
            alphas[-ksize_x:],
            alphas,
            alphas[:ksize_x],
        ])

        alphas = cv2.GaussianBlur(
            _normalize_cv2_input_arr_(alphas[np.newaxis, :]),
            ksize=(ksize_x, ksize_y),
            sigmaX=sigma, sigmaY=sigma,
            borderType=cv2.BORDER_REPLICATE
        )[0, :]

        # revert fake BORDER_WRAP
        alphas = alphas[ksize_x:-ksize_x]

        return alphas

    # Added in 0.4.0. 
开发者ID:aleju,项目名称:imgaug,代码行数:33,代码来源:blend.py

示例4: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import BORDER_WRAP [as 别名]
def __init__(self, target_size, fill_color=127, mode='letterbox',
                 border='constant', random_state=None):
        super(Resize, self).__init__(random_state=random_state)
        self.target_size = None if target_size is None else np.array(target_size)
        self.mode = mode

        import imgaug.parameters as iap
        if fill_color == imgaug.ALL:
            self.fill_color = iap.Uniform(0, 255)
        else:
            self.fill_color = iap.handle_continuous_param(
                fill_color, "fill_color", value_range=None,
                tuple_to_uniform=True, list_to_choice=True)

        self._cv2_border_type_map = {
            'constant': cv2.BORDER_CONSTANT,
            'edge': cv2.BORDER_REPLICATE,
            'linear_ramp': None,
            'maximum': None,
            'mean': None,
            'median': None,
            'minimum': None,
            'reflect': cv2.BORDER_REFLECT_101,
            'symmetric': cv2.BORDER_REFLECT,
            'wrap': cv2.BORDER_WRAP,
            cv2.BORDER_CONSTANT: cv2.BORDER_CONSTANT,
            cv2.BORDER_REPLICATE: cv2.BORDER_REPLICATE,
            cv2.BORDER_REFLECT_101: cv2.BORDER_REFLECT_101,
            cv2.BORDER_REFLECT: cv2.BORDER_REFLECT
        }
        if isinstance(border, six.string_types):
            if border == imgaug.ALL:
                border = [k for k, v in self._cv2_border_type_map.items()
                          if v is not None and isinstance(k, six.string_types)]
            else:
                border = [border]
        if isinstance(border, (list, tuple)):
            from imgaug.parameters import Choice
            border = Choice(border)
        self.border = border
        assert self.mode == 'letterbox', 'thats all folks' 
开发者ID:Erotemic,项目名称:netharn,代码行数:43,代码来源:augmenters.py


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