def getImgUrl_and_aveRgbArrayWeb_forSelection(selection, imageQueryLog):
    imageUrlArray=[]
    aveRgbArrayWeb=[]

    logFilename=imageQueryLog
    fileContents=mm.getFileContents(logFilename)

    singleQueryImageList=[]
    singleQueryRGBList=[]

    
    for item in selection:
        for i in range(len(fileContents)):
            if fileContents[i][8:-1]==item:
                singleQueryImageList=fileContents[i+2]
                singleQueryImageList=ast.literal_eval(singleQueryImageList[:-1])
                for item in singleQueryImageList:
                    imageUrlArray.append(item)
                singleQueryRGBList=fileContents[i+4]
                singleQueryRGBList=ast.literal_eval(singleQueryRGBList[:-1])
                for item in singleQueryRGBList:
                    aveRgbArrayWeb.append(item)

    returnedArray=[]
    
    returnedArray.append(imageUrlArray)
    returnedArray.append(aveRgbArrayWeb)

    print "---------------------------------------------------------------------"
    print "You are using search queries: ",
    for i in range(len(selection)):
        if i!=len(selection)-1:
            print str(selection[i])+', ',
        else:
            print "and "+str(selection[i])+"."
    print "These searches include "+str(len(imageUrlArray))+" images."
    print "---------------------------------------------------------------------"

    return returnedArray
예제 #2
0
    for item in selection:
        for i in range(len(fileContents)):
            if fileContents[i][8:-1] == item:
                singleQueryImageList = fileContents[i + 2]
                singleQueryImageList = ast.literal_eval(
                    singleQueryImageList[:-1])
                imageUrlArray.append(singleQueryImageList)

    return imageUrlArray


## Uses the above functions and generates a list of random urls
## (One from each term)
filenameIQ = "data/savedImageQueriesF1.log"
imageQueryData = mosaicModule.getFileContents(filenameIQ)
selection = getUserSelectedQueries(imageQueryData)
imageUrlArray = getImgUrl(selection, imageQueryData)

##randImgList=[]
##for i in range(len(imageUrlArray)):
##        index=int(floor(100*random()))
##        randImgList.append(imageUrlArray[i][index])


##----File Upload----##
def upload_file():
    if request.method == 'POST':
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
예제 #3
0
        intermediate=[]
        singleQueryImageList=[]

        for item in selection:
                for i in range(len(fileContents)):
                        if fileContents[i][8:-1]==item:
                                singleQueryImageList=fileContents[i+2]
                                singleQueryImageList=ast.literal_eval(singleQueryImageList[:-1])
                                imageUrlArray.append(singleQueryImageList)

        return imageUrlArray

## Uses the above functions and generates a list of random urls
## (One from each term)
filenameIQ = "data/savedImageQueriesF1.log"
imageQueryData = mosaicModule.getFileContents(filenameIQ)
selection = getUserSelectedQueries(imageQueryData)
imageUrlArray = getImgUrl(selection, imageQueryData)
##randImgList=[]
##for i in range(len(imageUrlArray)):
##        index=int(floor(100*random()))
##        randImgList.append(imageUrlArray[i][index])

##----File Upload----##
def upload_file():
        if request.method == 'POST':
                file = request.files['file']
                if file and allowed_file(file.filename):
                        filename = secure_filename(file.filename)
                        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
                        return redirect(url_for('uploaded_file',filename=filename))