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


Python cv2.SimpleBlobDetector_create方法代碼示例

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


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

示例1: _find_triangle

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_create [as 別名]
def _find_triangle(image, blob_params=None):
        """Finds the three dots for calibration in the image
        (of a 30 60 90 degree triangle)

        Parameters
        ----------
        image :
            return: the three triangle points
        blob_params :
             (Default value = None)

        Returns
        -------
        type
            the three triangle points

        """
        if blob_params is None:
            blobdet = cv2.SimpleBlobDetector_create()
        else:
            blobdet = cv2.SimpleBlobDetector_create(blob_params)
        # TODO check if blob detection is robust
        scaled_im = 255 - (image.astype(np.float32) * 255 / np.max(image)).astype(
            np.uint8
        )
        keypoints = blobdet.detect(scaled_im)
        if len(keypoints) != 3:
            raise CalibrationException("3 points for calibration not found")
        kps = np.array([k.pt for k in keypoints])

        # Find the angles between the points
        # and return the points sorted by the angles

        return kps[np.argsort(CircleCalibrator._find_angles(kps)), :] 
開發者ID:portugueslab,項目名稱:stytra,代碼行數:36,代碼來源:__init__.py

示例2: init_blob_detector

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_create [as 別名]
def init_blob_detector():
    params = cv2.SimpleBlobDetector_Params()
    params.minThreshold = 1
    params.maxThreshold = 255
    params.filterByArea = True
    params.minArea = 1
    params.filterByCircularity = False
    params.filterByConvexity = False
    params.filterByInertia = False
    #detector = cv2.SimpleBlobDetector(params)
    detector = cv2.SimpleBlobDetector_create(params)
    return detector 
開發者ID:Guanghan,項目名稱:lighttrack,代碼行數:14,代碼來源:utils_nms.py

示例3: add_blobs

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_create [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

示例4: init_blob_detector

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_create [as 別名]
def init_blob_detector():
    params = cv2.SimpleBlobDetector_Params()
    params.minThreshold = 1
    params.maxThreshold = 255
    params.filterByArea = True
    params.minArea = 1
    params.filterByCircularity = False
    params.filterByConvexity = False
    params.filterByInertia = False
    # detector = cv2.SimpleBlobDetector(params)
    detector = cv2.SimpleBlobDetector_create(params)
    return detector 
開發者ID:zh-plus,項目名稱:video-to-pose3D,代碼行數:14,代碼來源:utils_nms.py

示例5: analyse_frame

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_create [as 別名]
def analyse_frame(self,frame):
        balloon_found = False
        balloon_x = 0
        balloon_y = 0
        balloon_radius = 0
    
        # Convert BGR to HSV
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    
        # Threshold the HSV image
        mask = cv2.inRange(hsv, self.filter_low, self.filter_high)
    
        # Erode
        erode_kernel = numpy.ones((3,3),numpy.uint8);
        eroded_img = cv2.erode(mask,erode_kernel,iterations = 1)
    
        # dilate
        dilate_kernel = numpy.ones((10,10),numpy.uint8);
        dilate_img = cv2.dilate(eroded_img,dilate_kernel,iterations = 1)
    
        # blog detector
        blob_params = cv2.SimpleBlobDetector_Params()
        blob_params.minDistBetweenBlobs = 50
        blob_params.filterByInertia = False
        blob_params.filterByConvexity = False
        blob_params.filterByColor = True
        blob_params.blobColor = 255
        blob_params.filterByCircularity = False
        blob_params.filterByArea = False
        #blob_params.minArea = 20
        #blob_params.maxArea = 500
        blob_detector = cv2.SimpleBlobDetector_create(blob_params)
        keypts = blob_detector.detect(dilate_img)
    
        # draw centers of all keypoints in new image
        #blob_img = cv2.drawKeypoints(frame, keypts, color=(0,255,0), flags=0)
    
        # find largest blob
        if len(keypts) > 0:
            kp_max = keypts[0]
            for kp in keypts:
                if kp.size > kp_max.size:
                    kp_max = kp
    
            # draw circle around the largest blob
            cv2.circle(frame,(int(kp_max.pt[0]),int(kp_max.pt[1])),int(kp_max.size),(0,255,0),2)
    
            # set the balloon location
            balloon_found = True
            balloon_x = kp_max.pt[0]
            balloon_y = kp_max.pt[1]
            balloon_radius = kp_max.size
    
        # return results
        return balloon_found, balloon_x, balloon_y, balloon_radius

    # add_artificial_horizon - adds artificial horizon to an image using the vehicle's attitude 
開發者ID:rmackay9,項目名稱:ardupilot-balloon-finder,代碼行數:59,代碼來源:find_balloon.py


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