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


Python cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS属性代码示例

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


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

示例1: postprocessing_image

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def postprocessing_image(self, frame):
        # Detect blobs.
        keypoints = self.detector.detect(frame)

        # Draw detected blobs as red circles.
        # cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the
        # circle corresponds to the size of blob
        im_with_keypoints = cv2.drawKeypoints(frame,
                                              keypoints,
                                              np.array([]),
                                              (0, 0, 255),
                                              cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

        leaves_data = self.k_means(keypoints)
        frame = self.print_number_of_leaves(im_with_keypoints, leaves_data)
        return frame 
开发者ID:OpenAgricultureFoundation,项目名称:openag_cv,代码行数:18,代码来源:BlobDetector.py

示例2: draw_skel_and_kp

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def draw_skel_and_kp(
        img, instance_scores, keypoint_scores, keypoint_coords,
        min_pose_score=0.5, min_part_score=0.5):
    out_img = img
    adjacent_keypoints = []
    cv_keypoints = []
    for ii, score in enumerate(instance_scores):
        if score < min_pose_score:
            continue

        new_keypoints = get_adjacent_keypoints(
            keypoint_scores[ii, :], keypoint_coords[ii, :, :], min_part_score)
        adjacent_keypoints.extend(new_keypoints)

        for ks, kc in zip(keypoint_scores[ii, :], keypoint_coords[ii, :, :]):
            if ks < min_part_score:
                continue
            cv_keypoints.append(cv2.KeyPoint(kc[1], kc[0], 10. * ks))

    out_img = cv2.drawKeypoints(
        out_img, cv_keypoints, outImage=np.array([]), color=(255, 255, 0),
        flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
    out_img = cv2.polylines(out_img, adjacent_keypoints, isClosed=False, color=(255, 255, 0))
    return out_img 
开发者ID:rwightman,项目名称:posenet-python,代码行数:26,代码来源:utils.py

示例3: draw_skel_and_kp

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def draw_skel_and_kp(
        img, instance_scores, keypoint_scores, keypoint_coords,
        min_pose_score=0.5, min_part_score=0.5):

    out_img = img
    adjacent_keypoints = []
    cv_keypoints = []
    for ii, score in enumerate(instance_scores):
        if score < min_pose_score:
            continue

        new_keypoints = get_adjacent_keypoints(
            keypoint_scores[ii, :], keypoint_coords[ii, :, :], min_part_score)
        adjacent_keypoints.extend(new_keypoints)

        for ks, kc in zip(keypoint_scores[ii, :], keypoint_coords[ii, :, :]):
            if ks < min_part_score:
                continue
            cv_keypoints.append(cv2.KeyPoint(kc[1], kc[0], 10. * ks))

    if cv_keypoints:
        out_img = cv2.drawKeypoints(
            out_img, cv_keypoints, outImage=np.array([]), color=(255, 255, 0),
            flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
    out_img = cv2.polylines(out_img, adjacent_keypoints, isClosed=False, color=(255, 255, 0))
    return out_img 
开发者ID:rwightman,项目名称:posenet-pytorch,代码行数:28,代码来源:utils.py

示例4: show_blobs_in_heatmap

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def show_blobs_in_heatmap(heatmap, blobs):
    heatmap_with_blobs = cv2.drawKeypoints(heatmap, blobs, np.array([]),
                                           (0,0,255),
                                           cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

    [i,j] = np.unravel_index(heatmap.argmin(), heatmap.shape)
    cv2.circle(heatmap_with_blobs, (j,i), 3, (0,255,0))
    cv2.imshow("Heatmap Blobs", heatmap_with_blobs)
    cv2.waitKey(0) 
开发者ID:Guanghan,项目名称:lighttrack,代码行数:11,代码来源:utils_nms.py

示例5: add_blobs

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def add_blobs(crop_frame):
    frame=cv2.GaussianBlur(crop_frame, (3, 3), 0)
    # Convert BGR to HSV
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    # define range of green color in HSV
    lower_green = np.array([70,50,50])
    upper_green = np.array([85,255,255])
    # Threshold the HSV image to get only blue colors
    mask = cv2.inRange(hsv, lower_green, upper_green)
    mask = cv2.erode(mask, None, iterations=1)
    mask = cv2.dilate(mask, None, iterations=1)    
    # Bitwise-AND mask and original image
    res = cv2.bitwise_and(frame,frame, mask= mask)
    detector = cv2.SimpleBlobDetector_create(params)
    # Detect blobs.
    reversemask=255-mask
    keypoints = detector.detect(reversemask)
    if keypoints:
        print "found blobs"
        if len(keypoints) > 4:
            keypoints.sort(key=(lambda s: s.size))
            keypoints=keypoints[0:3]
        # Draw detected blobs as red circles.
        # cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
        im_with_keypoints = cv2.drawKeypoints(frame, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
    else:
        print "no blobs"
        im_with_keypoints=crop_frame
        
    return im_with_keypoints #, max_blob_dist, blob_center, keypoint_in_orders 
开发者ID:perrytsao,项目名称:pc-drone,代码行数:32,代码来源:webcam_track_blobs.py

示例6: show_blobs_in_heatmap

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def show_blobs_in_heatmap(heatmap, blobs):
    heatmap_with_blobs = cv2.drawKeypoints(heatmap, blobs, np.array([]),
                                           (0, 0, 255),
                                           cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

    [i, j] = np.unravel_index(heatmap.argmin(), heatmap.shape)
    cv2.circle(heatmap_with_blobs, (j, i), 3, (0, 255, 0))
    cv2.imshow("Heatmap Blobs", heatmap_with_blobs)
    cv2.waitKey(0) 
开发者ID:zh-plus,项目名称:video-to-pose3D,代码行数:11,代码来源:utils_nms.py

示例7: starDetection

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def starDetection(inputImg_edge):
    imgStar=cv2.imread(inputImg_edge)
#    imgGray=cv2.cvtColor(imgStar,cv2.COLOR_BGR2GRAY)
    star=cv2.xfeatures2d.StarDetector_create()
    keypoints=star.detect(imgStar)
#    print(len(keypoints),keypoints)
    cv2.drawKeypoints(imgStar,keypoints,imgStar,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
    cv2.imshow('star features',imgStar)
    cv2.imwrite(os.path.join(rootDirectory,'star features.jpg'),imgStar)
    cv2.waitKey()    
   
#sift图像匹配 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:14,代码来源:opencv_py.py

示例8: matchSift

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def matchSift(imgA,imgB):   
    img1 = cv2.imread(imgA, 0) 
    img2 = cv2.imread(imgB, 0)  
    sift = cv2.xfeatures2d.SIFT_create()
    kp1, des1 = sift.detectAndCompute(img1, None)  #获取SIFT关键点和描述子
    kp2, des2 = sift.detectAndCompute(img2, None)  
    bf = cv2.BFMatcher()  
    matches = bf.knnMatch(des1, des2, k=2)  #根据描述子匹配图像,返回n个最佳匹配
    """
    .   @param k Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
    The result of matches = bf.match(des1,des2) line is a list of DMatch objects. This DMatch object has following attributes:
    DMatch.distance - Distance between descriptors. The lower, the better it is.
    DMatch.trainIdx - Index of the descriptor in train descriptors
    DMatch.queryIdx - Index of the descriptor in query descriptors
    DMatch.imgIdx - Index of the train image.
    参看:https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html
    """
    print(type(matches),matches[:2],(matches[0][0].distance,matches[0][1].distance))
    good = []  
    for m, n in matches:  
        if m.distance < 0.75 * n.distance:  #因为k=2,因此返回距离最近和次近关键点,比较最近和次近,满足最近/次近<value,才被认为匹配。ratio test explained by D.Lowe in his paper
            good.append([m])  
    
    imgM = cv2.drawMatchesKnn(img1, kp1, img2, kp2, good[0:int(1*len(good)):int(0.1*len(good))], None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)  
    fig, ax=plt.subplots(figsize=(50,30))
    ax.imshow(imgM), plt.show()    
#    cv2.imshow('matchSift',imgM)
#    cv2.waitKey() 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:30,代码来源:opencv_py.py

示例9: siftDetection

# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS [as 别名]
def siftDetection(inputImg_edge):
    imgSift=cv2.imread(inputImg_edge)
    imgGray=cv2.cvtColor(imgSift,cv2.COLOR_BGR2GRAY)
    print(imgGray.shape)
    sift=cv2.xfeatures2d.SIFT_create() #SIFT特征实例化
    keypoints=sift.detect(imgGray,None)  #提取SIFT特征关键点detector
    print(keypoints[:3],len(keypoints))
    for k in keypoints[:3]:
        print(k.pt,k.size,k.octave,k.response,k.class_id,k.angle) 
        """
        关键点信息包含:
        k.pt关键点点的坐标(图像像素位置)
        k.size该点直径的大小
        k.octave从高斯金字塔的哪一层提取得到的数据
        k.response响应程度,代表该点强壮大小,即角点的程度。角点:极值点,某方面属性特别突出的点(最大或最小)。
        k.class_id对图像进行分类时,可以用class_id对每个特征点进行区分,未设置时为-1
        k.angle角度,关键点的方向。SIFT算法通过对邻域做梯度运算,求得该方向。-1为初始值        
        """
       
    des = sift.compute(imgGray,keypoints) #提取SIFT调整描述子descriptor
    print(type(keypoints),type(des))
    print(des[0][:2]) #关键点
    print(des[1][:2]) #描述子(关键点周围对其有贡献的像素点)
    print(des[1].shape)
    imgSift=np.copy(imgSift)
    cv2.drawKeypoints(imgSift,keypoints,imgSift,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) 
    """
    help(cv2.drawKeypoints)
    Help on built-in function drawKeypoints:

    drawKeypoints(...)
    drawKeypoints(image, keypoints, outImage[, color[, flags]]) -> outImage
    .   @brief Draws keypoints.
    .   
    .   @param image Source image. 原始图像(3通道或单通道)
    .   @param keypoints Keypoints from the source image. 关键点(特征点向量),向量内每一个元素是一个keypoint对象,包含特征点的各种属性特征
    .   @param outImage Output image. Its content depends on the flags value defining what is drawn in the. output image. See possible flags bit values below.
    特征点绘制的画布图像(可以是原始图像)。标记类型,参看@note部分
    .   @param color Color of keypoints. 显示颜色,默认随机彩色
    .   @param flags Flags setting drawing features. Possible flags bit values are defined by.DrawMatchesFlags. See details above in drawMatches .
        .   
    .   @note 特征点的 绘制模式,即绘制特征点的哪些信息
    .   For Python API, flags are modified as cv2.DRAW_MATCHES_FLAGS_DEFAULT,
    .   cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv2.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG,
    .   cv2.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS
    """
    cv2.imshow('sift features',imgSift)
    cv2.imwrite(os.path.join(rootDirectory,'sift features.jpg'),imgSift)
    cv2.waitKey()

#star特征检测器 
开发者ID:richieBao,项目名称:python-urbanPlanning,代码行数:53,代码来源:opencv_py.py


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