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


Python cv2.DescriptorMatcher_create方法代码示例

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


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

示例1: match

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def match(self, key_a, fea_a, key_b, fea_b):
		# Compute the raw matches and initialize the list of actual matches
		matcher = cv2.DescriptorMatcher_create(self.distance_method)
		raw_matches = matcher.knnMatch(fea_b, fea_a, 2)
		matches = []

		# Loop over the raw matches
		for match in raw_matches:
			# Ensure the distance is within a certain ratio of each other
			if len(match) == 2 and match[0].distance < match[1].distance * self.ratio:
				matches.append((match[0].trainIdx, match[0].queryIdx))

		# Check to see if there are enough matches to process
		if len(matches) > self.min_matches:
			# Construct the two sets of points
			poi_a = np.float32([key_a[i] for (i, _) in matches])
			poi_b = np.float32([key_b[j] for (_, j) in matches])

			# Compute the homography between the two sets of points and compute the ratio of matched points
			(_, status) = cv2.findHomography(poi_a, poi_b, cv2.RANSAC, 4.0)

			# Return the ratio of the number of matched keypoints to the total number of keypoints
			return float(status.sum()) / status.size

		# No matches were found
		return -1.0 
开发者ID:hsSam,项目名称:PracticalPythonAndOpenCV_CaseStudies,代码行数:28,代码来源:covermatcher.py

示例2: get_Allpossible_Match

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def get_Allpossible_Match(self,featuresA,featuresB):

        # compute the all matches using euclidean distance and opencv provide
        #DescriptorMatcher_create() function for that
        match_instance = cv2.DescriptorMatcher_create("BruteForce")
        All_Matches = match_instance.knnMatch(featuresA, featuresB, 2)

        return All_Matches 
开发者ID:AVINASH793,项目名称:Panoramic-Image-Stitching-using-invariant-features,代码行数:10,代码来源:panorama.py

示例3: DescriptorMatcher_create

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def DescriptorMatcher_create(method):
        return cv2.DescriptorMatcher_create(method) 
开发者ID:jrosebr1,项目名称:imutils,代码行数:4,代码来源:factories.py

示例4: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def __init__(self, image, ratio = 0.75, reprojThresh = 4.0):
        self.leftImage = image
        self.ratio = ratio
        self.reprojThresh = reprojThresh

        self.surfFeature = cv2.xfeatures2d.SURF_create(500, extended = False, upright = False)
        #HessianThreshold = 500
        #No orientation calculation
        #64 dimension feature vector

        self.matcher = cv2.DescriptorMatcher_create('BruteForce')

        self.leftKps, self.leftDescriptor = self.detectAndDescribe(image) 
开发者ID:shekkizh,项目名称:ImageProcessingProjects,代码行数:15,代码来源:StitchingFromVideo.py

示例5: matchKeypoints

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def matchKeypoints(self, kpsA, kpsB, featuresA, featuresB,
                       ratio, reprojThresh):
        # compute the raw matches and initialize the list of actual
        # matches
        matcher = cv2.DescriptorMatcher_create("BruteForce")
        rawMatches = matcher.knnMatch(featuresA, featuresB, 2)
        matches = []

        # loop over the raw matches
        for m in rawMatches:
            # ensure the distance is within a certain ratio of each
            # other (i.e. Lowe's ratio test)
            if len(m) == 2 and m[0].distance < m[1].distance * ratio:
                matches.append((m[0].trainIdx, m[0].queryIdx))

                # computing a homography requires at least 4 matches
        if len(matches) > 4:
            # construct the two sets of points
            ptsA = np.float32([kpsA[i] for (_, i) in matches])
            ptsB = np.float32([kpsB[i] for (i, _) in matches])

            # compute the homography between the two sets of points
            (H, status) = cv2.findHomography(ptsA, ptsB, cv2.RANSAC,
                                             reprojThresh)

            # return the matches along with the homograpy matrix
            # and status of each matched point
            return (matches, H, status)

        # otherwise, no homograpy could be computed
        return None 
开发者ID:shekkizh,项目名称:ImageProcessingProjects,代码行数:33,代码来源:ImageStitching.py

示例6: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def __init__(self, image, ratio = 0.75, reprojThresh = 4.0):
        self.leftImage = image
        self.ratio = ratio
        self.reprojThresh = reprojThresh

        self.surfFeature = cv2.xfeatures2d.SURF_create(500, extended = False, upright = True)
        #HessianThreshold = 500
        #No orientation calculation
        #64 dimension feature vector

        self.matcher = cv2.DescriptorMatcher_create('BruteForce')

        self.leftKps, self.leftDescriptor = self.detectAndDescribe(image) 
开发者ID:shekkizh,项目名称:ImageProcessingProjects,代码行数:15,代码来源:ImageStitching.py

示例7: matchDescriptors

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorMatcher_create [as 别名]
def matchDescriptors(self, featuresA, featuresB):
        '''
        功能:匹配特征点
        :param featuresA: 第一张图像的特征点描述符
        :param featuresB: 第二张图像的特征点描述符
        :return:返回匹配的对数matches
        '''
        if self.isGPUAvailable == False:        # CPU Mode
            # 建立暴力匹配器
            if self.featureMethod == "surf" or self.featureMethod == "sift":
                matcher = cv2.DescriptorMatcher_create("BruteForce")
                # 使用KNN检测来自A、B图的SIFT特征匹配对,K=2,返回一个列表
                rawMatches = matcher.knnMatch(featuresA, featuresB, 2)
                matches = []
                for m in rawMatches:
                # 当最近距离跟次近距离的比值小于ratio值时,保留此匹配对
                    if len(m) == 2 and m[0].distance < m[1].distance * self.searchRatio:
                        # 存储两个点在featuresA, featuresB中的索引值
                        matches.append((m[0].trainIdx, m[0].queryIdx))
            elif self.featureMethod == "orb":
                matcher = cv2.DescriptorMatcher_create("BruteForce-Hamming")
                rawMatches = matcher.match(featuresA, featuresB)
                matches = []
                for m in rawMatches:
                    matches.append((m.trainIdx, m.queryIdx))
            # self.printAndWrite("  The number of matches is " + str(len(matches)))
        else:                                   # GPU Mode
            if self.featureMethod == "surf":
                matches = self.npToListForMatches(myGpuFeatures.matchDescriptors(np.array(featuresA), np.array(featuresB), 2, self.searchRatio))
            elif self.featureMethod == "orb":
                matches = self.npToListForMatches(myGpuFeatures.matchDescriptors(np.array(featuresA), np.array(featuresB), 3, self.orbMaxDistance))
        return matches 
开发者ID:Keep-Passion,项目名称:ImageStitch,代码行数:34,代码来源:ImageUtility.py


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