lab_global_optimisation.py 文件源码

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

项目:Interactive-object-tracking 作者: abhishekarya286 项目源码 文件源码
def label(image) :
    '''This function along with click_and_crop() helps in labelling object and background.
       Input : Input image
       Output: selected region of interest(either obj or distractor)'''
    global refPt,cropping,img_copy,clone,list_refpt
    #image1=copy.deepcopy(image)
    #clone = image1.copy()
    #img_copy=image1.copy()
    cv2.namedWindow("image")
    cv2.setMouseCallback("image", click_and_crop)
    print "Label the object"
    print "After making a bounding box, press 'c' "
    print "if you wish to select the object again, press 'r' "

    while True:
    # display the image and wait for a keypress
        cv2.imshow("image", img_copy)
        key = cv2.waitKey(1) & 0xFF

        # if the 'r' key is pressed, reset the cropping region
        if key == ord("r"):
            image = clone.copy()
            img_copy=image.copy()

        # if the 'c' key is pressed, break from the loop
        elif key == ord("c"):
            break

    # if there are two reference points, then crop the region of interest
    # from the image and display it
    if len(refPt) == 2:
        roi = clone[refPt[0][1]:refPt[1][1], refPt[0][0]:refPt[1][0]]
        cv2.imshow("ROI", roi)
        print "press any key"
        cv2.waitKey(0)

    cv2.destroyAllWindows() # close all open windows
    obj_img=roi  # roi containing the object
    list_refpt.append(refPt)
    return obj_img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号