blobdetect.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Conquest_kshitij 作者: pigeon-kgp 项目源码 文件源码
def blobdetect(img):
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

    yellowMin = (20,100,100)
    yellowMax = (30, 255, 255)

    blueMin=(50,100,100)
    blueMax=(100,255,255)

    brownMin=(0,100,0)
    brownMax=(20,255,255)
    yellow=cv2.inRange(hsv,yellowMin, yellowMax)
    blue=cv2.inRange(hsv,blueMin,blueMax)
    brown=cv2.inRange(hsv,brownMin,brownMax)

    params = cv2.SimpleBlobDetector_Params()
    params.filterByArea = True
    params.minArea=150
    detector=cv2.SimpleBlobDetector(params)
    keypoints=detector.detect(255-yellow)
    food=[]
    for i in keypoints:
        x=i.pt[0]; y=i.pt[1]
        food.append([x,y])

    params.maxArea=250
    detector=cv2.SimpleBlobDetector(params)
    keypoints=detector.detect(255-yellow)

    wood=[]
    for i in keypoints:
        x=i.pt[0]; y=i.pt[1]
        wood.append([x,y])

    params=cv2.SimpleBlobDetector()
    keypoints=params.detect(255-blue)
    rivers=[]
    for i in keypoints:
        x=i.pt[0]; y=i.pt[1]
        rivers.append([x,y])

    keypoints=params.detect(255-brown)
    centre=[]
    for i in keypoints:
        x=i.pt[0]; y=i.pt[1]
        centre.append([x,y])

    return [food, wood, rivers, centre]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号