コード例 #1
0
def refreshUrlImageLists(imageQueryLog):

    savedImageFile=imageQueryLog
    siv=savedImageFile
    sivTemp=siv[:siv.index('.')]+'Test'+siv[siv.rindex('.'):]

    fileContents=getFileContents(siv)

    listOfQueries=[]
    
    tempFile=open(sivTemp,'w')

    tempFile.write(fileContents[0])
    tempFile.write(fileContents[1])
    tempFile.write(fileContents[2])
    tempFile.write(fileContents[3])
    #tempFile.write(fileContents[4])

    aveRgbArrayWebRefresh=[]
    
    for i in range(4,len(fileContents)):
        if fileContents[i-4][:7]=="Search:":
            print "---------------------------------------------------------------------"
            print "Refreshing the image list for "+fileContents[i-4][8:-1]
            aveRgbArrayWebRefresh=F1.getAveRgbArrayWebNew(ast.literal_eval(fileContents[i-2][:-1]))
            tempFile.write(str(aveRgbArrayWebRefresh))
            tempFile.write('\n')
            
        else:
            tempFile.write(fileContents[i])

    tempFile.close()

    shutil.copyfile(sivTemp,siv)
    os.remove(sivTemp)
コード例 #2
0
def mosaicMakerInterface(progDir, mainDir, imageQueryLog):

    print "---------------------------------------------------------------------"
    print "Choose one of the following:"
    print "[1] Make a mosaic"
    print "[2] Do a new search"
    print "[3] Print Searches"
    print "[4] Refresh"
    print "[5] Quit :("
    print "---------------------------------------------------------------------"
    
    promptString="Please make a selection.[1]"

    choice=getIntegerInput(1, 5, promptString, 1) # This goes (start, end, promptString, default)
    print "---------------------------------------------------------------------"
    
    if choice==1:
        
        print "You picked choice one"

        imageFile=getBaseImage(progDir,mainDir)

        imCopy=openImageReturnCopy(imageFile)      ##  I think this doesn't do what I want - too lazy to fix.
        newFilename=saveImageCopy(imCopy,imageFile,progDir, mainDir)
        
        width=imCopy.size[0]                                    ##  Get width of image
        height=imCopy.size[1]                                   ##  Get height of image
        pix=imCopy.load()                                       ##  Noooow we have pixel data

        percentOfPic=getPercentOfPic()             ##  How small to you want the images that make up the mosaic to be?

        pixelHeight=op.floor(height*percentOfPic)               ##  Height of each section
        pixelWidth=op.floor(width*percentOfPic)                 ##  Width of each section
        aveRgbArray=F1.getAveRgbArray(width, height, pixelWidth, pixelHeight, pix)
        
        
        filename=imageQueryLog
        fileContents=getFileContents(filename)

        print "---------------------------------------------------------------------"
        prompt="Choose queries from list using comma separated integers. [All]"
        userSelectedQueries=getUserSelectedQueries(fileContents,prompt)
        returnedArray=F1.getImgUrl_and_aveRgbArrayWeb_forSelection(userSelectedQueries, imageQueryLog)

        imageUrlArray=returnedArray[0]
        aveRgbArrayWeb=returnedArray[1]

        print "Entering output URL"
        entTime=time.time()
        outputUrlList=F1.getOutputUrlList(aveRgbArray, aveRgbArrayWeb, imageUrlArray)
        exiTime=time.time()
        print "Exited output URL"
        diff=exiTime-entTime
        minutes=op.floor(diff/60)
        seconds=diff-minutes*60
        print "That took "+str(minutes)+" minutes and "+str(seconds)+" seconds!"
        
        mosaicDisplayWidth=800
        cssFile='mosaicStyle.css' 

        filenameHTML=generateHTML(width,height,pixelWidth,pixelHeight,mosaicDisplayWidth,cssFile,outputUrlList,imageFile, progDir, mainDir)
   
        mosaicMakerInterface(progDir, mainDir, imageQueryLog)
        
    elif choice==2:
        
        print "You picked choice 2"
        
        imageUrlArray=getImageUrlArrayNew(imageQueryLog)
        
        aveRgbArrayWeb=F1.getAveRgbArrayWebNew(imageUrlArray)
        
        logNewResults(imageUrlArray, aveRgbArrayWeb, imageQueryLog)
        
        mosaicMakerInterface(progDir, mainDir, imageQueryLog)

    elif choice==3:

        print "You picked choice 3"
        print "---------------------------------------------------------------------"
        filename=imageQueryLog
        fileContents=getFileContents(filename)
        prompt="Please hit enter to continue [Enter]"
        userSelectedQueries=getUserSelectedQueries(fileContents,prompt)
        
        mosaicMakerInterface(progDir, mainDir, imageQueryLog)
    
    elif choice==4:

        print "You picked choice 4"
        print "---------------------------------------------------------------------"
        
        refreshUrlImageLists(imageQueryLog)

        mosaicMakerInterface(progDir, mainDir, imageQueryLog)

    else: print "Bye!"