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


Python cv2.SimpleBlobDetector_Params方法代碼示例

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


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

示例1: init_blob_detector

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

示例2: init_blob_detector

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

示例3: __init__

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_Params [as 別名]
def __init__(self, args):
        self.node_name = "cvBridge"
        rospy.init_node(self.node_name)

        # What we do during shutdown
        rospy.on_shutdown(self.cleanup)

        # Create the cv_bridge object
        self.bridge = CvBridge()

        # Subscribe to the camera image topics and set
        # the appropriate callbacks
        self.image_sub = rospy.Subscriber(args[1], Image, self.image_callback)
        self.image_pub = rospy.Publisher(
            "%s/BlobDetector" % (args[1]), Image, queue_size=10)

        # Detector
        # Set up the detector with parameters.

        # Setup SimpleBlobDetector parameters.
        params = cv2.SimpleBlobDetector_Params()

        # Filter by Color.
        params.filterByColor = rospy.get_param('~FilterByColor')
        params.blobColor = rospy.get_param('~BlobColor')

        # Filter by Area.
        params.filterByArea = rospy.get_param('~FilterByArea')
        params.minArea = rospy.get_param('~BlobMinArea')
        params.maxArea = rospy.get_param('~BlobMaxArea')

        # Filter by Circularity
        params.filterByCircularity = rospy.get_param('~FilterByCircularity')
        params.minCircularity = rospy.get_param('~BlobMinCircularity')
        params.maxCircularity = rospy.get_param('~BlobMaxCircularity')

        # Filter by Convexity
        params.filterByConvexity = rospy.get_param('~FilterByConvexity')
        params.minConvexity = rospy.get_param('~BlobMinConvexity')
        params.maxConvexity = rospy.get_param('~BlobMaxConvexity')

        # Filter by Inertia
        params.filterByInertia = rospy.get_param('~FilterByInertia')
        params.minInertiaRatio = rospy.get_param('~BlobMinInertia')
        params.maxInertiaRatio = rospy.get_param('~BlobMaxInertia')

        self.MaxLeavesSocketA = [0]
        self.MaxLeavesSocketB = [0]
        self.MaxLeavesSocketC = [0]
        self.MaxLeavesSocketD = [0]
        self.MaxLeavesSocketE = [0]
        self.MaxLeavesSocketF = [0]

        self.detector = cv2.SimpleBlobDetector(params)
        rospy.loginfo("Waiting for image topics...") 
開發者ID:OpenAgricultureFoundation,項目名稱:openag_cv,代碼行數:57,代碼來源:BlobDetector.py

示例4: __init__

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_Params [as 別名]
def __init__(self,
                 pattern_type,
                 pattern_rows,
                 pattern_columns,
                 distance_in_world_units = 1.0,
                 figsize = (8,8),
                 debug_dir = None,
                 term_criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_COUNT, 30, 0.001)
                 ):
        
        pattern_types = ["chessboard","symmetric_circles","asymmetric_circles","custom"]
        
        assert pattern_type in pattern_types, "pattern type must be one of {}".format(pattern_types)
        
        self.pattern_type = pattern_type
        self.pattern_rows = pattern_rows
        self.pattern_columns = pattern_columns
        self.distance_in_world_units = distance_in_world_units
        self.figsize = figsize
        self.debug_dir = debug_dir
        self.term_criteria = term_criteria
        self.subpixel_refinement = True #turn on or off subpixel refinement
        # on for chessboard 
        # off for circular objects
        # set accordingly for custom pattern
        # NOTE: turining on subpixel refinement for circles gives a very high 
        # reprojection error.
        if self.pattern_type in ["asymmetric_circles","symmetric_circles"]:
            self.subpixel_refinement = False
            self.use_clustering = True
            # Setup Default SimpleBlobDetector parameters.
            self.blobParams = cv2.SimpleBlobDetector_Params()
            # Change thresholds
            self.blobParams.minThreshold = 8
            self.blobParams.maxThreshold = 255
            # Filter by Area.
            self.blobParams.filterByArea = True
            self.blobParams.minArea = 50     # minArea may be adjusted to suit for your experiment
            self.blobParams.maxArea = 10e5   # maxArea may be adjusted to suit for your experiment
            # Filter by Circularity
            self.blobParams.filterByCircularity = True
            self.blobParams.minCircularity = 0.8
            # Filter by Convexity
            self.blobParams.filterByConvexity = True
            self.blobParams.minConvexity = 0.87
            # Filter by Inertia
            self.blobParams.filterByInertia = True
            self.blobParams.minInertiaRatio = 0.01
        if self.pattern_type == "asymmetric_circles":
            self.double_count_in_column = True # count the double circles in asymmetrical circular grid along the column
            
        if self.debug_dir and not os.path.isdir(self.debug_dir):
            os.mkdir(self.debug_dir)
                
        print("The Camera Calibration API is initialized and ready for calibration...") 
開發者ID:Abhijit-2592,項目名稱:camera_calibration_API,代碼行數:57,代碼來源:camera_calibration.py

示例5: analyse_frame

# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import SimpleBlobDetector_Params [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_Params方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。