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
def exportTsneWithFile(name):
    tsne_vals,ids = getTSNEwithIds(name)
    tsne_x,tsne_y = zip(*tsne_vals)
    tsne_x = np.array(tsne_x) * 50
    tsne_y = np.array(tsne_y) * 50
    urls = []
    filenames = []
    for id in ids:
        fullurl = imagesHandler.get_full_url(id)
        filename = fullurl.split(dirm.rootDirectory)[1]
        urls.append(imagesHandler.get_full_url(id))
        filenames.append(str(filename))
    results = zip(ids,tsne_x,tsne_y,filenames,urls)
    util.writetoCSV(results, name + "tsne with url")
Esempio n. 4
0
def resize_all_images(size):
    imageids = imagesHandler.get_all_img_ids_string()
    for img_id in imageids:
        img = imagesHandler.get_image(img_id)
        url = imagesHandler.get_full_url(img_id)
        filename = url.split(dirm.rootDirectory)[1]
        imgr = cv2.resize(img, (size, size))
        cv2.imwrite(dirm.rootDirectory + "/small/" + filename, imgr)
def resize_all_images(size):
    imageids = imagesHandler.get_all_img_ids_string()
    for img_id in imageids:
        img = imagesHandler.get_image(img_id)
        url = imagesHandler.get_full_url(img_id)
        filename = url.split(dirm.rootDirectory)[1]
        imgr = cv2.resize(img, (size, size))
        cv2.imwrite(dirm.rootDirectory+"/small/"+ filename, imgr )
def searchImg(btId):
    
    imgURL = None
    if btId == 1:
        text = ent1.get().upper()
        try:
            imgURL = imagesHandler.get_full_url(text)
        except Exception,e:
            imgURL = None
            
        if imgURL == None:
            img1 = ITk.PhotoImage(Image.open(dirm.outputDirectory+"default.jpg"))
            img1URL = 0
        else:
            img1 = ITk.PhotoImage(Image.open(imgURL).resize((256,256),Image.ANTIALIAS))
            panel1.configure(image=img1)
            panel1.image = img1
            img1URL = imgURL
def searchImg(btId):

    imgURL = None
    if btId == 1:
        text = ent1.get().upper()
        try:
            imgURL = imagesHandler.get_full_url(text)
        except Exception, e:
            imgURL = None

        if imgURL == None:
            img1 = ITk.PhotoImage(
                Image.open(dirm.outputDirectory + "default.jpg"))
            img1URL = 0
        else:
            img1 = ITk.PhotoImage(
                Image.open(imgURL).resize((256, 256), Image.ANTIALIAS))
            panel1.configure(image=img1)
            panel1.image = img1
            img1URL = imgURL
        except Exception,e:
            imgURL = None
            
        if imgURL == None:
            img1 = ITk.PhotoImage(Image.open(dirm.outputDirectory+"default.jpg"))
            img1URL = 0
        else:
            img1 = ITk.PhotoImage(Image.open(imgURL).resize((256,256),Image.ANTIALIAS))
            panel1.configure(image=img1)
            panel1.image = img1
            img1URL = imgURL
    if btId == 2:
        text = ent2.get().upper()
        
        try:
            imgURL = imagesHandler.get_full_url(text)
        except Exception,e:
            imgURL = None
            
        if imgURL == None:
            img2 = ITk.PhotoImage(Image.open(dirm.outputDirectory+"default.jpg"))
            img2URL = 0
        else:
            img2 = ITk.PhotoImage(Image.open(imgURL).resize((256,256),Image.ANTIALIAS))
            panel2.configure(image=img2)
            panel2.image = img2
            img2URL = imgURL
    
def match(crop_amount,ipd):
    out = None
    text1 = ent1.get().upper()
        if imgURL == None:
            img1 = ITk.PhotoImage(
                Image.open(dirm.outputDirectory + "default.jpg"))
            img1URL = 0
        else:
            img1 = ITk.PhotoImage(
                Image.open(imgURL).resize((256, 256), Image.ANTIALIAS))
            panel1.configure(image=img1)
            panel1.image = img1
            img1URL = imgURL
    if btId == 2:
        text = ent2.get().upper()

        try:
            imgURL = imagesHandler.get_full_url(text)
        except Exception, e:
            imgURL = None

        if imgURL == None:
            img2 = ITk.PhotoImage(
                Image.open(dirm.outputDirectory + "default.jpg"))
            img2URL = 0
        else:
            img2 = ITk.PhotoImage(
                Image.open(imgURL).resize((256, 256), Image.ANTIALIAS))
            panel2.configure(image=img2)
            panel2.image = img2
            img2URL = imgURL