Пример #1
0
		def get_matches(self, query_image,check_homogenity=False,k=2):
			good_matches = []
			for image in self.images:
				kp1, des1 = self.sift.detectAndCompute(query_image,None)
				kp2, des2 = self.sift.detectAndCompute(image,None)
				# BFMatcher with default params
				bf = cv2.BFMatcher()
				matches = bf.knnMatch(des1,des2, k=k)
				# Apply ratio test
				good = []
				for m,n in matches:
					if m.distance < 0.75*n.distance:
						good.append([m])	
			good_matches.append(len(good))
			self.cv = mstatistics.coefficients_of_variation(good_matches)

			if len(good_matches) == 0:
				return 0
			if check_homogenity:
				if self.cv <= CV_HOMOGENITY_COEFFICIENT:
					return mstatistics.mean(good_matches)
				else:
					return 0
			else:
				return [mstatistics.mean(good_matches), max(good_matches)]
Пример #2
0
		def get_matches(self, query_image,check_homogenity=False,k=2):
			good_matches = []
			for image in self.images:
				kp1, des1 = self.sift.detectAndCompute(query_image,None)
				kp2, des2 = self.sift.detectAndCompute(image,None)
				FLANN_INDEX_KDTREE = 0
				index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
				search_params = dict(checks = 50)
				flann = cv2.FlannBasedMatcher(index_params, search_params)
				matches = flann.knnMatch(des1,des2,k=2)
				good = []
				
				for m,n in matches:
					if m.distance < 0.7*n.distance:
						good.append(m)
			good_matches.append(len(good))
			self.cv = mstatistics.coefficients_of_variation(good_matches)

			if len(good_matches) == 0:
				return 0
			if check_homogenity:
				if self.cv <= CV_HOMOGENITY_COEFFICIENT:
					return mstatistics.mean(good_matches)
				else:
					return 0
			else:
				return [mstatistics.mean(good_matches), max(good_matches)]
Пример #3
0
        def get_matches(self, query_image, check_homogenity=False, k=2):
            good_matches = []
            for image in self.images:
                kp1, des1 = self.sift.detectAndCompute(query_image, None)
                kp2, des2 = self.sift.detectAndCompute(image, None)
                # BFMatcher with default params
                bf = cv2.BFMatcher()
                matches = bf.knnMatch(des1, des2, k=k)
                # Apply ratio test
                good = []
                for m, n in matches:
                    if m.distance < 0.75 * n.distance:
                        good.append([m])
            good_matches.append(len(good))
            self.cv = mstatistics.coefficients_of_variation(good_matches)

            if len(good_matches) == 0:
                return 0
            if check_homogenity:
                if self.cv <= CV_HOMOGENITY_COEFFICIENT:
                    return mstatistics.mean(good_matches)
                else:
                    return 0
            else:
                return [mstatistics.mean(good_matches), max(good_matches)]
Пример #4
0
        def get_matches(self, query_image, check_homogenity=False, k=2):
            good_matches = []
            for image in self.images:
                kp1, des1 = self.sift.detectAndCompute(query_image, None)
                kp2, des2 = self.sift.detectAndCompute(image, None)
                FLANN_INDEX_KDTREE = 0
                index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5)
                search_params = dict(checks=50)
                flann = cv2.FlannBasedMatcher(index_params, search_params)
                matches = flann.knnMatch(des1, des2, k=2)
                good = []

                for m, n in matches:
                    if m.distance < 0.7 * n.distance:
                        good.append(m)
            good_matches.append(len(good))
            self.cv = mstatistics.coefficients_of_variation(good_matches)

            if len(good_matches) == 0:
                return 0
            if check_homogenity:
                if self.cv <= CV_HOMOGENITY_COEFFICIENT:
                    return mstatistics.mean(good_matches)
                else:
                    return 0
            else:
                return [mstatistics.mean(good_matches), max(good_matches)]
Пример #5
0
		def get_matches(self, query_image,check_homogenity=True):
			matches = []
			for image in self.images:
				kp1, des1 = self.orb.detectAndCompute(query_image,None)
				kp2, des2 = self.orb.detectAndCompute(image,None)
			
				# create BFMatcher object
				bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
				# Match descriptors.
				_matches = bf.match(des1,des2)
				matches.append(len(_matches))
				# Sort them in the order of their distance.
				#_matches = sorted(_matches, key = lambda x:x.distance)
			if len(matches) == 0:
				return 0
			self.cv = mstatistics.coefficients_of_variation(matches)
			if check_homogenity:
				if self.cv <= CV_HOMOGENITY_COEFFICIENT:
					return mstatistics.mean(matches)
				else:
					return 0
			else:
				return [mstatistics.mean(matches), max(matches)]
Пример #6
0
        def get_matches(self, query_image, check_homogenity=True):
            matches = []
            for image in self.images:
                kp1, des1 = self.orb.detectAndCompute(query_image, None)
                kp2, des2 = self.orb.detectAndCompute(image, None)

                # create BFMatcher object
                bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
                # Match descriptors.
                _matches = bf.match(des1, des2)
                matches.append(len(_matches))
                # Sort them in the order of their distance.
                #_matches = sorted(_matches, key = lambda x:x.distance)
            if len(matches) == 0:
                return 0
            self.cv = mstatistics.coefficients_of_variation(matches)
            if check_homogenity:
                if self.cv <= CV_HOMOGENITY_COEFFICIENT:
                    return mstatistics.mean(matches)
                else:
                    return 0
            else:
                return [mstatistics.mean(matches), max(matches)]