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


Python cv2.DescriptorExtractor_create方法代码示例

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


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

示例1: init_detector

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def init_detector(self):
        """Init keypoint detector object."""
        # BRIEF is a feature descriptor, recommand CenSurE as a fast detector:
        if check_cv_version_is_new():
            # OpenCV3/4, star/brief is in contrib module, you need to compile it seperately.
            try:
                self.star_detector = cv2.xfeatures2d.StarDetector_create()
                self.brief_extractor = cv2.xfeatures2d.BriefDescriptorExtractor_create()
            except:
                import traceback
                traceback.print_exc()
                print("to use %s, you should build contrib with opencv3.0" % self.METHOD_NAME)
                raise NoModuleError("There is no %s module in your OpenCV environment !" % self.METHOD_NAME)
        else:
            # OpenCV2.x
            self.star_detector = cv2.FeatureDetector_create("STAR")
            self.brief_extractor = cv2.DescriptorExtractor_create("BRIEF")

        # create BFMatcher object:
        self.matcher = cv2.BFMatcher(cv2.NORM_L1)  # cv2.NORM_L1 cv2.NORM_L2 cv2.NORM_HAMMING(not useable) 
开发者ID:AirtestProject,项目名称:Airtest,代码行数:22,代码来源:keypoint_matching_contrib.py

示例2: detectAndDescribe

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def detectAndDescribe(self, image):
        # check to see if we are using OpenCV 3.X
        if int(cv2.__version__[0]) >= 3:
            # detect and extract features from the image
            descriptor = cv2.xfeatures2d.SIFT_create()
            (kps, features) = descriptor.detectAndCompute(image, None)

        # otherwise, we are using OpenCV 2.4.X
        else:
            # convert the image to grayscale
            gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

            # detect keypoints in the image
            detector = cv2.FeatureDetector_create("SIFT")
            kps = detector.detect(gray)

            # extract features from the image
            extractor = cv2.DescriptorExtractor_create("SIFT")
            (kps, features) = extractor.compute(gray, kps)

        # convert the keypoints from KeyPoint objects to NumPy arrays
        kps = np.float32([kp.pt for kp in kps])

        # return a tuple of keypoints and features
        return (kps, features) 
开发者ID:cynricfu,项目名称:dual-fisheye-video-stitching,代码行数:27,代码来源:stitcher.py

示例3: DescriptorExtractor_create

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def DescriptorExtractor_create(extractor, *args, **kw_args):
        """

        :param extractor: string of the type of descriptor extractor to return
        :param args: positional arguments for extractor
        :param kw_args: keyword arguments for extractor
        :return: the key extractor object
        """
        try:
            extr = _EXTRACTOR_FACTORY[extractor.upper()]
        except KeyError:
            if extractor.upper() in _CONTRIB_FUNCS:
                msg = "OpenCV needs to be compiled with opencv_contrib to support {}".format(extractor)
                raise AttributeError(msg)
            raise AttributeError("{} not a supported extractor".format(extractor))

        return extr(*args, **kw_args) 
开发者ID:jrosebr1,项目名称:imutils,代码行数:19,代码来源:factories.py

示例4: get_sift_descriptors

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def get_sift_descriptors (image, kpts):
	"""
		Function: get_sift_descriptor
		-----------------------------
		given an image and a list of keypoints, this returns
		(keypoints, descriptors), each a list
	"""
	sift_descriptor = cv2.DescriptorExtractor_create('SIFT')
	return sift_descriptor.compute (image, kpts)[1]







####################################################################################################
#################[ --- FINDING BOARD_IMAGE HOMOGRAPHY FROM POINTS CORRESPONDENCES --- ]#############
#################################################################################################### 
开发者ID:nebbles,项目名称:DE3-ROB1-CHESS,代码行数:21,代码来源:CVAnalysis_old.py

示例5: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def __init__ (self):
		"""
			PUBLIC: Constructor
			-------------------
			board_image: BoardImage object, the first frame
		"""
		#=====[ Step 1: set up feature extractors	]=====
		self.corner_detector = cv2.FeatureDetector_create ('HARRIS')
		self.sift_descriptor = cv2.DescriptorExtractor_create('SIFT')










	####################################################################################################
	##############################[ --- FIND BOARD CORNER CORRESPONDENCES --- ]#########################
	#################################################################################################### 
开发者ID:nebbles,项目名称:DE3-ROB1-CHESS,代码行数:24,代码来源:CVAnalyzer.py

示例6: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def __init__(self):
		# initialize the SIFT feature extractor for OpenCV 2.4
		if is_cv2():
			self.extractor = cv2.DescriptorExtractor_create("SIFT")

		# otherwise initialize the SIFT feature extractor for OpenCV 3+
		else:
			self.extractor = cv2.xfeatures2d.SIFT_create() 
开发者ID:jrosebr1,项目名称:imutils,代码行数:10,代码来源:rootsift.py

示例7: get_sift_descriptors

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def get_sift_descriptors (image, kpts):
	"""
		Function: get_sift_descriptors
		------------------------------
		given an image and a list of keypoints, this returns
		(keypoints, descriptors), each a list
	"""
	sift_descriptor = cv2.DescriptorExtractor_create('SIFT')
	return sift_descriptor.compute (image, kpts)[1] 
开发者ID:nebbles,项目名称:DE3-ROB1-CHESS,代码行数:11,代码来源:CVAnalysis.py

示例8: __init__

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def __init__(self, storage):
        super(SIFT_SIFT_Extractor, self).__init__(storage)
        self.STORAGE_SUB_NAME = 'sift_sift'
        self.sub_folder = self.storage.get_sub_folder(
            self.STORAGE_SUPER_NAME, self.STORAGE_SUB_NAME)
        self.storage.ensure_dir(self.sub_folder)

        self._keypoint_detector = cv2.FeatureDetector_create("SIFT")
        self._keypoint_extractor = cv2.DescriptorExtractor_create("SIFT") 
开发者ID:yassersouri,项目名称:omgh,代码行数:11,代码来源:extractor.py

示例9: main

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DescriptorExtractor_create [as 别名]
def main(image_file):
    image = Image.open(image_file)
    if image is None:
        print 'Could not load image "%s"' % sys.argv[1]
        return

    image = np.array(image.convert('RGB'), dtype=np.uint8)
    image = image[:, :, ::-1].copy()

    winSize = (200, 200)
    stepSize = 32

    roi = extractRoi(image, winSize, stepSize)
    weight_map, mask_scale = next(roi)

    samples = [(rect, scale, cv2.cvtColor(window, cv2.COLOR_BGR2GRAY))
               for rect, scale, window in roi]

    X_test = [window for rect, scale, window in samples]
    coords = [(rect, scale) for rect, scale, window in samples]

    extractor = cv2.FeatureDetector_create('SURF')
    detector = cv2.DescriptorExtractor_create('SURF')

    affine = AffineInvariant(extractor, detector)

    saved = pickle.load(open('classifier.pkl', 'rb'))

    feature_transform = saved['pipe']
    model = saved['model']

    print 'Extracting Affine transform invariant features'
    affine_invariant_features = affine.transform(X_test)
    print 'Matching features with template'
    features = feature_transform.transform(affine_invariant_features)

    rects = classify(model, features, coords, weight_map, mask_scale)
    for (left, top, right, bottom) in non_max_suppression_fast(rects, 0.4):
        cv2.rectangle(image, (left, top), (right, bottom), (0, 0, 0), 10)
        cv2.rectangle(image, (left, top), (right, bottom), (32, 32, 255), 5)

    plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
    plt.show() 
开发者ID:AVGInnovationLabs,项目名称:DoNotSnap,代码行数:45,代码来源:classify.py


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