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


Python cv2.estimateAffinePartial2D方法代碼示例

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


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

示例1: align_to_shape

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import estimateAffinePartial2D [as 別名]
def align_to_shape(image, labels, target, extend=1.0, rotate=False):
  image = np.array(image)
  labels = np.array(labels).astype(np.float32)
  target = np.array(target).astype(np.float32)
  m, _ = cv2.estimateAffinePartial2D(labels, target)
  image_t = cv2.warpAffine(image, m, (128, 128))
  labels_t = np.dot(labels, m[:,:2].T) + m[np.newaxis,:,2]
  return image_t, labels_t 
開發者ID:vahidk,項目名稱:TensorflowFramework,代碼行數:10,代碼來源:image_utils.py

示例2: find_homography

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import estimateAffinePartial2D [as 別名]
def find_homography(keypoints_pic1, keypoints_pic2, matches) -> (List, np.float32, np.float32):
        # Find an Homography matrix between two pictures
        # From two list of keypoints and a list of matches, extrat
        # A list of good matches found by RANSAC and two transformation matrix (an homography and a rigid homography/affine)

        # Instanciate outputs
        good = []

        # Transforming keypoints to list of points
        src_pts = np.float32([keypoints_pic1[m.queryIdx].pt for m in matches]).reshape(-1, 1, 2)
        dst_pts = np.float32([keypoints_pic2[m.trainIdx].pt for m in matches]).reshape(-1, 1, 2)

        # Find the transformation between points
        transformation_matrix, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0)

        # Compute a rigid transformation (without depth, only scale + rotation + translation)
        transformation_rigid_matrix, rigid_mask = cv2.estimateAffinePartial2D(src_pts, dst_pts)

        # Get a mask list for matches = A list that says "This match is an in/out-lier"
        matchesMask = mask.ravel().tolist()

        # Filter the matches list thanks to the mask
        for i, element in enumerate(matchesMask):
            if element == 1:
                good.append(matches[i])

        return good, transformation_matrix, transformation_rigid_matrix 
開發者ID:CIRCL,項目名稱:douglas-quaid,代碼行數:29,代碼來源:distance_ransac_orb.py

示例3: cv2_estimateRigidTransform

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import estimateAffinePartial2D [as 別名]
def cv2_estimateRigidTransform(from_pts, to_pts, full=False):
    """Estimate transforms in OpenCV 3 or OpenCV 4"""
    if not from_pts.shape[0] or not to_pts.shape[0]:
        return None

    if imutils.is_cv4():
        transform = cv2.estimateAffinePartial2D(from_pts, to_pts)[0]
    else:
        # noinspection PyUnresolvedReferences
        transform = cv2.estimateRigidTransform(from_pts, to_pts, full)

    return transform 
開發者ID:AdamSpannbauer,項目名稱:python_video_stab,代碼行數:14,代碼來源:cv2_utils.py

示例4: find_affine

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import estimateAffinePartial2D [as 別名]
def find_affine(i1, i2):
    # quick sanity checks
    if i1 == i2:
        return None
    if not i2.name in i1.match_list:
        return None
    if len(i1.match_list[i2.name]) == 0:
        return None

    if not i1.kp_list or not len(i1.kp_list):
        i1.load_features()
    if not i2.kp_list or not len(i2.kp_list):
        i2.load_features()

    # affine transformation from i2 uv coordinate system to i1
    uv1 = []; uv2 = []; indices = []
    for pair in i1.match_list[i2.name]:
        uv1.append( i1.kp_list[ pair[0] ].pt )
        uv2.append( i2.kp_list[ pair[1] ].pt )
    uv1 = np.float32([uv1])
    uv2 = np.float32([uv2])
    affine, status = \
        cv2.estimateAffinePartial2D(uv2, uv1)
    return affine

# return individual components of affine transform: rot, tx, ty, sx,
# sy (units are degrees and pixels) 
開發者ID:UASLab,項目名稱:ImageAnalysis,代碼行數:29,代碼來源:smart.py

示例5: findAffine

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import estimateAffinePartial2D [as 別名]
def findAffine(src, dst, fullAffine=False):
    #print("src:", src)
    #print("dst:", dst)
    if len(src) >= affine_minpts:
        # affine = cv2.estimateRigidTransform(np.array([src]), np.array([dst]), fullAffine)
        affine, status = \
            cv2.estimateAffinePartial2D(np.array([src]).astype(np.float32),
                                        np.array([dst]).astype(np.float32))
    else:
        affine = None
    #print str(affine)
    return affine 
開發者ID:UASLab,項目名稱:ImageAnalysis,代碼行數:14,代碼來源:1a-est-gyro-rates.py


注:本文中的cv2.estimateAffinePartial2D方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。