def match(crop_amount,ipd):
    out = None
    text1 = ent1.get().upper()
    text2 = ent2.get().upper()
    resize_ratio_m = float(ent3.get())
    print resize_ratio_m
    if resize_ratio_m == None:
        resize_ratio_m = default_values.resize_ratio
    num_matches = int(ent4.get())
    if num_matches == None:
        num_matches = 10
    print resize_ratio_m
    try:
        img1URL = imagesHandler.get_full_url(text1)
        img2URL = imagesHandler.get_full_url(text2)
        img1 = cv2.imread(img1URL)
        img2 = cv2.imread(img2URL)
        
        if ipd =="SURF":
            k1,d1,gray1 = interest_point_detectors.calculate_surf_values(img1,hessian_threshold=default_values.hessian_threshold,resize_ratio=resize_ratio_m,resize_method=default_values.resize_method,crop_amount=crop_amount)
            k2,d2,gray2 = interest_point_detectors.calculate_surf_values(img2,hessian_threshold=default_values.hessian_threshold,resize_ratio=resize_ratio_m,resize_method=default_values.resize_method,crop_amount=crop_amount)
        if ipd =="SIFT":
            k1,d1,gray1 = interest_point_detectors.calculate_sift_values(img1,resize_ratio=resize_ratio_m,resize_method=default_values.resize_method,crop_amount=crop_amount)
            k2,d2,gray2 = interest_point_detectors.calculate_sift_values(img2,resize_ratio=resize_ratio_m,resize_method=default_values.resize_method,crop_amount=crop_amount)
        if ipd =="ORB":
            k1,d1,gray1 = interest_point_detectors.calculate_orb_values(img1,resize_ratio=resize_ratio_m,resize_method=default_values.resize_method,crop_amount=crop_amount)
            k2,d2,gray2 = interest_point_detectors.calculate_orb_values(img2,resize_ratio=resize_ratio_m,resize_method=default_values.resize_method,crop_amount=crop_amount)
        
        
        out = matching.matchandDraw(gray1,gray2,k1,d1,k2,d2,num_matches)
    except Exception,e:
        print e
def match(crop_amount, ipd):
    out = None
    text1 = ent1.get().upper()
    text2 = ent2.get().upper()
    resize_ratio_m = float(ent3.get())
    print resize_ratio_m
    if resize_ratio_m == None:
        resize_ratio_m = default_values.resize_ratio
    num_matches = int(ent4.get())
    if num_matches == None:
        num_matches = 10
    print resize_ratio_m
    try:
        img1URL = imagesHandler.get_full_url(text1)
        img2URL = imagesHandler.get_full_url(text2)
        img1 = cv2.imread(img1URL)
        img2 = cv2.imread(img2URL)

        if ipd == "SURF":
            k1, d1, gray1 = interest_point_detectors.calculate_surf_values(
                img1,
                hessian_threshold=default_values.hessian_threshold,
                resize_ratio=resize_ratio_m,
                resize_method=default_values.resize_method,
                crop_amount=crop_amount)
            k2, d2, gray2 = interest_point_detectors.calculate_surf_values(
                img2,
                hessian_threshold=default_values.hessian_threshold,
                resize_ratio=resize_ratio_m,
                resize_method=default_values.resize_method,
                crop_amount=crop_amount)
        if ipd == "SIFT":
            k1, d1, gray1 = interest_point_detectors.calculate_sift_values(
                img1,
                resize_ratio=resize_ratio_m,
                resize_method=default_values.resize_method,
                crop_amount=crop_amount)
            k2, d2, gray2 = interest_point_detectors.calculate_sift_values(
                img2,
                resize_ratio=resize_ratio_m,
                resize_method=default_values.resize_method,
                crop_amount=crop_amount)
        if ipd == "ORB":
            k1, d1, gray1 = interest_point_detectors.calculate_orb_values(
                img1,
                resize_ratio=resize_ratio_m,
                resize_method=default_values.resize_method,
                crop_amount=crop_amount)
            k2, d2, gray2 = interest_point_detectors.calculate_orb_values(
                img2,
                resize_ratio=resize_ratio_m,
                resize_method=default_values.resize_method,
                crop_amount=crop_amount)

        out = matching.matchandDraw(gray1, gray2, k1, d1, k2, d2, num_matches)
    except Exception, e:
        print e
Exemple #3
0
def build_distribution(est, n_clusters, resize_ratio, resize_method, crop_amount):
    print 'BuildingDistribution'
    images = imagesHandler.get_all_img_rows()
    allDist = []
    numimg = 0
    for image in images:
        if numimg%100==0:
                print numimg
        imageId = image[0]
        imageURL = image[1]
        img = cv2.imread(dirm.rootDirectory + imageURL)
        
        #print dirm.rootDirectory + imageURL
        try:
            kp,desc,gray = interest_point_detectors.calculate_sift_values(img, resize_ratio, resize_method, crop_amount)
        except Exception,e:
            print "unable to process image "+imageId
            print str(e)
        
        dist =  np.zeros((n_clusters))
        imagePred = est.predict(desc)
        for p in imagePred:
            dist[p] = dist[p] + 1
        dist = dist / len(imagePred)
        allDist.append([imageId] + dist.tolist())
        numimg = numimg +1
Exemple #4
0
def extract_all_descriptors(resize_ratio, resize_method, crop_amount):
    print 'Extracting Discriptors: SIFT'
    images = imagesHandler.get_all_img_rows()
    concatDesc = []
    concatIds = []
    numimg = 0
    numDesc = 0
    for image in images:
        if numimg%100==0:
                print numimg
        imageId = image[0]
        imageURL = image[1]
        img = cv2.imread(dirm.rootDirectory + imageURL)
        try:
            kp,desc,gray = interest_point_detectors.calculate_sift_values(img, resize_ratio, resize_method, crop_amount)
            numDesc = numDesc + len(desc)
            for d in desc:
                concatDesc.append(d)
                concatIds.append([imageId,len(desc)])
       
        except Exception,e:
            print "unable to process image "+imageId
            print str(e)
        numimg = numimg +1