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


Python cv2.CV_16SC2属性代码示例

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


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

示例1: rectify_images_float

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def rectify_images_float(img1, x1, img2, x2, K, d, F, shearing=False):
    imsize = (img1.shape[1], img1.shape[0])
    H1, H2, rms, max_error = epipolar.rectify_uncalibrated(x1, x2, F, imsize)
    if shearing:
        S = epipolar.rectify_shearing(H1, H2, imsize)
        H1 = S.dot(H1)
    rH = la.inv(K).dot(H1).dot(K)
    lH = la.inv(K).dot(H2).dot(K)
    map1x, map1y = cv2.initUndistortRectifyMap(K, d, rH, K, imsize, cv.CV_16SC2)
    map2x, map2y = cv2.initUndistortRectifyMap(K, d, lH, K, imsize, cv.CV_16SC2)

    rimg1 = cv2.remap(img1, map1x, map1y,
                      interpolation=cv.INTER_NEAREST,
                      borderMode=cv2.BORDER_CONSTANT,
                      borderValue=(0, 0, 0, 0))
    rimg2 = cv2.remap(img2, map2x, map2y,
                      interpolation=cv.INTER_NEAREST,
                      borderMode=cv2.BORDER_CONSTANT,
                      borderValue=(0, 0, 0, 0))

    return rimg1, rimg2


# get NITF metadata that we embedded in the GeoTIFF header 
开发者ID:pubgeo,项目名称:dfc2019,代码行数:26,代码来源:test-mvs.py

示例2: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def main():

  basler_undistorted = pickle.load(open("basler_pickle.p", "rb"))

  #objects = []
  #with (open("./basler_pickle.p", "rb")) as openfile:
  #    while True:
  #        try:
  #            basler_undistorted.append(pickle.load(openfile))
  #        except EOFError:
  #            break
    
  image_width  = 1280
  image_height = 1024

  #print(basler_undistorted)

  cam_mtx = basler_undistorted["mtx"]
  cam_dist = basler_undistorted["dist"]
  rvecs = basler_undistorted["rvecs"]
  tvecs = basler_undistorted["tvecs"]
  #imageSize = image_height * image_width
  imageSize = ( image_height, image_width )
  
  #getOptimal...Mtx(cameraMatrix, distCoeffs, imageSize, alpha[, newImgSize[, centerPrincipalPoint]]) -> retval, validPixROI
  # Doesn't take Rect of validPixROI, contrary to the cpp method
  new_cam_mtx, valid_roi = cv.getOptimalNewCameraMatrix(cam_mtx, cam_dist, imageSize, 1, imageSize, 1) 
  
  # getOptimalNewCameraMatrix() possibly not working like in cpp
  #map1, map2 = cv.initUndistortRectifyMap(cam_mtx, cam_dist, np.eye(3), new_cam_mtx, imageSize, cv.CV_16SC2);
  map1, map2 = cv.initUndistortRectifyMap(cam_mtx, cam_dist, np.eye(3), cam_mtx, imageSize, cv.CV_16SC2);
  
  # map1 and map2 can be used together with cv.remap() for efficient real-time undistortion
  # Only need to be calculated once.
  maps = { "map1": map1, "map2": map2 }
  pickle.dump( maps, open("maps.p", "wb")) 
开发者ID:ddavid,项目名称:fsoco,代码行数:38,代码来源:get-undistortion-maps.py

示例3: rectify_images_rgb

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def rectify_images_rgb(img1, x1, img2, x2, K, d, F, shearing=False):
    imsize = (img1.shape[1], img1.shape[0])
    H1, H2, rms, max_error = epipolar.rectify_uncalibrated(x1, x2, F, imsize)
    if shearing:
        S = epipolar.rectify_shearing(H1, H2, imsize)
        H1 = S.dot(H1)
    rH = la.inv(K).dot(H1).dot(K)
    lH = la.inv(K).dot(H2).dot(K)

    # TODO: lRect or rRect for img1/img2 ??
    map1x, map1y = cv2.initUndistortRectifyMap(K, d, rH, K, imsize, cv.CV_16SC2)
    map2x, map2y = cv2.initUndistortRectifyMap(K, d, lH, K, imsize, cv.CV_16SC2)
    rimg1 = cv2.remap(img1, map1x, map1y,
                      interpolation=cv.INTER_CUBIC,
                      borderMode=cv2.BORDER_CONSTANT,
                      borderValue=(0, 0, 0))
    rimg2 = cv2.remap(img2, map2x, map2y,
                      interpolation=cv.INTER_CUBIC,
                      borderMode=cv2.BORDER_CONSTANT,
                      borderValue=(0, 0, 0))

    return rimg1, rimg2, rms, max_error


# rectify a floating point image pair based on the Fundamental matrix
# use this for XYZ images 
开发者ID:pubgeo,项目名称:dfc2019,代码行数:28,代码来源:test-mvs.py

示例4: undistort

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def undistort(img_path,K,D,DIM,scale=0.6,imshow=False):
    img = cv2.imread(img_path)
    dim1 = img.shape[:2][::-1]  #dim1 is the dimension of input image to un-distort
    assert dim1[0]/dim1[1] == DIM[0]/DIM[1], "Image to undistort needs to have same aspect ratio as the ones used in calibration"
    if dim1[0]!=DIM[0]:
        img = cv2.resize(img,DIM,interpolation=cv2.INTER_AREA)
    Knew = K.copy()
    if scale:#change fov
        Knew[(0,1), (0,1)] = scale * Knew[(0,1), (0,1)]
    map1, map2 = cv2.fisheye.initUndistortRectifyMap(K, D, np.eye(3), Knew, DIM, cv2.CV_16SC2)
    undistorted_img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)
    if imshow:
        cv2.imshow("undistorted", undistorted_img)
    return undistorted_img 
开发者ID:HLearning,项目名称:fisheye,代码行数:16,代码来源:main.py

示例5: dense_image_warp

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def dense_image_warp(im, dx, dy, interp=cv2.INTER_LINEAR):

        map_x, map_y = deformation_to_transformation(dx, dy)

        do_optimization = (interp == cv2.INTER_LINEAR)
        # The following command converts the maps to compact fixed point representation
        # this leads to a ~20% increase in speed but could lead to accuracy losses
        # Can be uncommented
        if do_optimization:
            map_x, map_y = cv2.convertMaps(map_x, map_y, dstmap1type=cv2.CV_16SC2)

        remapped = cv2.remap(im, map_x, map_y, interpolation=interp, borderMode=cv2.BORDER_REFLECT) #borderValue=float(np.min(im)))
        if im.ndim > remapped.ndim:
            remapped = np.expand_dims(remapped, im.ndim)
        return remapped 
开发者ID:RobinBruegger,项目名称:PartiallyReversibleUnet,代码行数:17,代码来源:utils.py

示例6: dense_image_warp

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def dense_image_warp(im, dx, dy, interp=cv2.INTER_LINEAR, do_optimisation=True):

        map_x, map_y = deformation_to_transformation(dx, dy)

        # The following command converts the maps to compact fixed point representation
        # this leads to a ~20% increase in speed but could lead to accuracy losses
        # Can be uncommented
        if do_optimisation:
            map_x, map_y = cv2.convertMaps(map_x, map_y, dstmap1type=cv2.CV_16SC2)
        return cv2.remap(im, map_x, map_y, interpolation=interp, borderMode=cv2.BORDER_REFLECT) #borderValue=float(np.min(im))) 
开发者ID:baumgach,项目名称:PHiSeg-code,代码行数:12,代码来源:utils.py

示例7: rectify_images

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import CV_16SC2 [as 别名]
def rectify_images(img1, x1, img2, x2, K, d, F, shearing=False):
    imsize = (img1.shape[1], img1.shape[0])
    H1, H2, rms, max_error = epipolar.rectify_uncalibrated(x1, x2, F, imsize)
    if shearing:
        S = epipolar.rectify_shearing(H1, H2, imsize)
        H1 = S.dot(H1)
    rH = la.inv(K).dot(H1).dot(K)
    lH = la.inv(K).dot(H2).dot(K)

    # check for y parallax
    max_yparallax = get_y_parallax(x1, x2, rH, lH, imsize)

    # TODO: lRect or rRect for img1/img2 ??
    map1x, map1y = cv2.initUndistortRectifyMap(K, d, rH, K, imsize,
                                               cv.CV_16SC2)
    map2x, map2y = cv2.initUndistortRectifyMap(K, d, lH, K, imsize,
                                               cv.CV_16SC2)

    # Convert the images to RGBA (add an axis with 4 values)
    img1 = np.tile(img1[:, :, np.newaxis], [1, 1, 4])
    img1[:, :, 3] = 255
    img2 = np.tile(img2[:, :, np.newaxis], [1, 1, 4])
    img2[:, :, 3] = 255

    rimg1 = cv2.remap(img1, map1x, map1y,
                      interpolation=cv.INTER_NEAREST,
                      borderMode=cv2.BORDER_CONSTANT,
                      borderValue=(0, 0, 0, 0))
    rimg2 = cv2.remap(img2, map2x, map2y,
                      interpolation=cv.INTER_NEAREST,
                      borderMode=cv2.BORDER_CONSTANT,
                      borderValue=(0, 0, 0, 0))

    # Put a red background on the invalid values
    # TODO: Return a mask for valid/invalid values
    # TODO: There is aliasing happening on the images border. We should
    # invalidate a margin around the border so we're sure we have only valid
    # pixels
    rimg1[rimg1[:, :, 3] == 0, :] = (255, 0, 0, 255)
    rimg2[rimg2[:, :, 3] == 0, :] = (255, 0, 0, 255)

    return rimg1, rimg2, rms, max_error, lH, rH, max_yparallax


# rectify an image pair based on the Fundamental matrix 
开发者ID:pubgeo,项目名称:dfc2019,代码行数:47,代码来源:test-mvs.py


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