Пример #1
0
def loadDetectionsRamanan(fn):
    f = util.loadmat(fn)
    ids = f['ids']
    scores = []
    if f.has_key('sc'):
        scores = f['sc']
    boxes = f['BB']
    n = len(ids)

    det = []
    for i in range(n):
        this_id = ids[i][0][0].split(".")[0]
        if not scores == []:
            this_score = scores[i][0]
        else:
            this_score = 1.0
        box = boxes[:, i]
        x1 = float(box[0])
        y1 = float(box[1])
        x2 = float(box[2])
        y2 = float(box[3])
        det.append([this_id, this_score, x1, y1, x2, y2])
        if 0:
            im = util.myimread(
                "/users/visics/mpederso/databases/afw/testimages/" + this_id + ".jpg")
            pylab.clf()
            pylab.imshow(im)
            util.box([y1, x1, y2, x2])
            pylab.draw()
            pylab.show()
            raw_input()
    dets = sorted(det, key=itemgetter(1), reverse=True)
    return dets
Пример #2
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    plon, plat = lon[GRID_CELL[1]], lat[GRID_CELL[0]]
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    x, y = m(plon, plat)
    print 'point cell (lon lat x y):', plon, plat, x, y
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)

    #plt.colorbar().set_label(LABEL)
    viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL))

    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    return fig
Пример #3
0
def generate(model_path, meta, n_predict, input_file, wordy=False):
    processed = get_reader(input_file, meta)

    if wordy: print("got processed with data: {}\nLength of input data: {}".format(processed.data, len(processed.data)))

    config = meta.config
    config.n_possibilities = meta.n_possibilities
    config.hidden_size = meta.hidden_size
    config.num_layers = meta.num_layers
    config.init_scale = meta.init_scale
    config.mode = meta.mode

    lm = general_lm.Model(
        config,
        processed.vocab_size,
        is_training=False,
        is_generating=True)
    if wordy: print("finished creating model")
    saver = tf.train.Saver()

    with tf.Session() as session:
        # start threads
        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(coord=coord)
        current_state = np.zeros((lm.num_layers, 2, lm.batch_size, lm.hidden_size))

        # restore the trained model
        saver.restore(session, model_path)
        if wordy: print("restored session, predicting")

        sentence = ' '.join(processed.data) + '...'
        pred = None # for scope
        # set seed state
        for (X, Y) in processed.doc_slice(lm.batch_size, lm.seq_length):
            pred, current_state = session.run(
                [lm.predict, lm.state],
                feed_dict={lm.init_state: current_state, lm.X: X})
            
        # do the actual predicting
        for ii in range(n_predict):
            if wordy: print('making prediction {}'.format(ii))
            input = np.array(pred) # TODO: implicit shape? might be confusing (formerly [pred])
            pred, current_state = session.run(
                [lm.predict, lm.state],
                feed_dict={lm.init_state: current_state, lm.X: input})
            pred_word = meta.id_to_word[pred[0][0]] # formerly just one [0]
            sentence += ' ' * int(config.mode == 'word') # only add space in word mode
            sentence += pred_word.replace('_', ' ').replace('<eos>', os.linesep)
            if wordy: print('finished making prediction {}: {}'.format(ii, pred_word))

        #print("\n\t{}\n".format(sentence))
        print(box(sentence, alignment='left'))
        # close threads
        coord.request_stop()
        coord.join(threads)
Пример #4
0
def houseBox():
    w = faceFromVectors([O,x(10000),xy(10000,10000),y(10000)])
    f = faceFromVectors([xy(5000-1,5000-1),xy(5000+1,5000-1),xy(5000+1,5001),xy(5000-1,5001)])
    f.translate(z(wallMaxHeight-wallMinHeight))

    b=util.box(10000,10000,wallMinHeight)
    roof=rich(Part.makeLoft([
        w.Wires[0],
        f.Wires[0],
    ],True)).transO(z(wallMinHeight))
    return rich(util.fuse([b,roof])
            .transO(xy(-10000+width,-10000+length)))
Пример #5
0
def viewSortDet(gtImages,detlist,numim=numpy.inf,opt="all",usetr=True,usedf=False,ovr=0.5):
    dimg={}
    tot=0
    for idx in range(min(gtImages.getTotal(),numim)):
        rect=gtImages.getBBox(idx)
        if rect!=[]:
            #print gtImages.getImageName(idx).split("/")[-1].split(".")[0]
            dimg[gtImages.getImageName(idx).split("/")[-1].split(".")[0]]=rect
        tot=tot+len(rect)
    imname=[]
    cnt=0
    tp=numpy.zeros(len(detlist))
    fp=numpy.zeros(len(detlist))
    thr=numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx,detbb in enumerate(detlist):
        #print detbb[1]
        found=False
        if dimg.has_key(detbb[0]):
            rect=dimg[detbb[0]]
            found=False
            for r in rect:
                rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
                #print "GT:",r
                #print "DET:",rb
                if overlap(rb,r)>=ovr:
                    dimg[detbb[0]].remove(r)
                    found=True
                    break
        if found:  
            tp[idx]=1
        else:
            fp[idx]=1
        thr[idx]=detbb[1]
        if show:
            pylab.ioff()
            prec=numpy.sum(tp)/float(numpy.sum(tp)+numpy.sum(fp))
            rec=numpy.sum(tp)/tot
            print "Scr:",detbb[1],"Prec:",prec,"Rec:",rec
            img=gtImages.getImageByName2(detbb[0])
            pylab.figure(1)
            pylab.clf()
            pylab.imshow(img)
            rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
            for r in rect:
                pylab.figure(1)
                pylab.ioff()
                box(r[0],r[1],r[2],r[3],'b',lw=1.5)
            if found:
                box(rb[0],rb[1],rb[2],rb[3],'g',lw=1.5)
            else:
                box(rb[0],rb[1],rb[2],rb[3],'r',lw=1.5)
            pylab.draw()
            pylab.show()
            rect=[]
            raw_input()

    return tp,fp,thr,tot
Пример #6
0
def test():
    util.clear()
    reload(util); 
    s = sBuild()
    bb = s.BoundBox
    box = util.box(max(1,bb.XLength),max(1,bb.YLength),max(1,bb.ZLength))\
            .transO(v(bb.XMin,bb.YMin, bb.ZMin))

    util.show(box)
    util.show(s)
    e = s.Edges[3]
    util.show(e)
    splits = util.splitFaceAlong(s,util.dir(e),[100,500,800]); 
    util.addGroup("splits",map(lambda f: util.trimFace(f,10),splits))
Пример #7
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True, savefig=None):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    plon, plat = lon[GRID_CELL[1]], lat[GRID_CELL[0]]
    # shift grid half degree
    lon -= (lon[1] - lon[0])/2.
    lat -= (lat[1] - lat[0])/2.
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    x, y = m(plon, plat)
    print 'point cell (lon lat x y):', plon, plat, x, y
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    p_ = m.drawparallels(np.arange(-90.,-60, 2), labels=[1,0,0,0], color='0.3')
    m_ = m.drawmeridians(np.arange(-180,180., 15), labels=[0,0,1,0], color='0.3')
    #m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)
    ###
    '''
    x2, y2 = np.loadtxt('/Users/fpaolo/data/masks/scripps/scripps_iceshelves_v1_geod.txt', 
                        usecols=(0,1), unpack=True, comments='%')
    x2, y2 = m(x2, y2)
    m.plot(x2, y2, 'o', markersize=1.2)
    '''
    ###
    #plt.colorbar().set_label(LABEL)
    rect = 0.25, 0.11, 0.5, 0.02
    viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL), title='Elevation change rate (m/yr)',
                 rect=rect)
    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    if savefig is not None:
        plt.savefig(savefig+'_map.png')
    return fig
Пример #8
0
def VOCprlistfast(gtImages,detlist,show=False,usetr=True,usedf=False,ovr=0.5):
    """
        calculate the precision recall curve
    """
    dimg={}
    tot=0
    for idx in range(gtImages.getTotal()):
        rect=gtImages.getBBox(idx)
        if rect!=[]:
            dimg[gtImages.getImageName(idx).split("/")[-1].split(".")[0]]=rect
        tot=tot+len(rect)
        #print tot
    imname=[]
    cnt=0
    tp=numpy.zeros(len(detlist))
    fp=numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx,detbb in enumerate(detlist):#detlist[sortlist]):#gtImages.getTotal()):
        found=False
        if dimg.has_key(detbb[0]):
            rect=dimg[detbb[0]]#gtImages.getBBox(idx,usetr=usetr,usedf=usedf)
            #print rect
            found=False
            for r in rect:
                rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
                if overlap(rb,r)>=ovr:
                    dimg[detbb[0]].remove(r)
                    found=True
                    break
        if found:  
            tp[idx]=1#.append(float(detbb[1]))
        else:
            fp[idx]=1#.append(float(detbb[1]))
        if show:
            pylab.ioff()
            img=gtImages.getImageByName2(detbb[0])
            pylab.figure(1)
            pylab.clf()
            pylab.imshow(img)
            rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
            for r in rect:
                pylab.figure(1)
                pylab.ioff()
                box(r[0],r[1],r[2],r[3],'b',lw=1.5)
            if found:
                box(rb[0],rb[1],rb[2],rb[3],'g',lw=1.5)
            else:
                box(rb[0],rb[1],rb[2],rb[3],'r',lw=1.5)
            pylab.draw()
            pylab.show()
            rect=[]
            raw_input()

    return tp,fp,tot
Пример #9
0
def plot_grid(lon, lat, dhdt, cell=None, plot_cell=False, contourf=True):
    fig = plt.figure()
    m = viz.make_proj_stere(BBOX_REG)
    lon, lat = np.meshgrid(lon, lat)
    xx, yy = m(lon, lat)
    dhdt = np.ma.masked_invalid(dhdt)
    m.pcolormesh(xx, yy, dhdt, cmap=CMAP, vmin=-ABS_VAL, vmax=ABS_VAL, alpha=1)
    p_ = m.drawparallels(np.arange(-90.,-60, 5), labels=[0,0,0,1], color='0.8')
    m_ = m.drawmeridians(np.arange(-180,180., 10), labels=[1,0,0,0], color='0.8')
    ###
    '''
    xx, yy = np.loadtxt('/Users/fpaolo/data/masks/scripps/scripps_iceshelves_v1_geod.txt', usecols=(0,1), unpack=True, comments='%')
    xx, yy = m(xx, yy)
    m.plot(xx, yy, 'o', markersize=0.1)
    '''
    ###
    #m.plot(x, y, 'mo', markersize=8)
    if plot_cell:
        lon, lat = util.box(cell)
        x, y = m(lon, lat)
        m.plot(x, y, 'k', linewidth=2)
    if contourf:
        fig2 = plt.figure()
        m.contourf(xx, yy, dhdt, 25, cmap=CMAP)

    #plt.colorbar().set_label(LABEL)
    viz.colorbar(fig, CMAP, (-ABS_VAL,ABS_VAL))

    '''
    w = 50.0 / (axis[1] - axis[0])
    rect = 0.142 - w, 0.08, 2 * w, 0.02
    cmap = CMAP
    viz.colorbar(fig, cmap, colorlim, legend, rect, ticks, ticklabels, 
        size=7, weight='bold', color='k', edgecolor='w')
    leg = fig.add_axes([0, 0, 1, 1])
    leg.set_axis_off()
    viz.text(leg, 0.70, 0.90, title, ha='center', va='top', size=10,
        weight='bold', color='k', edgecolor='w')
    '''
    return fig
Пример #10
0
def test(thr,cfg,it=9):
    
    #cfg.test=True
    import util
    #it=it
    models=util.load("%s%d.model"%(cfg.testname,it))
    #skip occlusion
    #for l in models:
    #    del l["occl"]

    w=[]
    rho=[]
    cfg.mythr=thr
    #for l in range(cfg.numcl):
    #    w.append(util.ModeltoW(models[l],cfg.usemrf,cfg.usefather,cfg.k,lastlev=1))
    #    rho.append(models[l]["rho"])
    #cfg.mythr=cfg.mythr*numpy.mean([numpy.sum(x**2) for x in w])#-numpy.mean(rho)
    #raw_input()    
    #cfg.mythr=cfg.mythr#-numpy.mean(rho)
    if cfg.multipr==1:
        numcore=None
    else:
        numcore=cfg.multipr

    mypool = Pool(numcore)
    if cfg.db=="inria":
        if cfg.select=="pos":
            tsImages=getRecord(InriaTestData(basepath=cfg.dbpath),cfg.maxtest)
        else:
            tsImages=getRecord(InriaTestFullData(basepath=cfg.dbpath),cfg.maxtest)
        if select=="dir":#"." or select[0]=="/"
            import glob
            #lst=glob.glob("/home/marcopede/ivan/zebra/CVC_Zebra1/*.jpeg")[150:]
            lst=glob.glob("/media/ca0567b8-ee6d-4590-8462-0d093addb4cf/video/*.png")
            lst.sort()
            lst=lst[3900:]
            total=len(lst)
            tsImages=numpy.zeros(total,dtype=[("id",numpy.int32),("name",object),("bbox",list)])
            for idl,l in enumerate(lst):
                tsImages[idl]["id"]=idl
                tsImages[idl]["name"]=l#l.split("/")[-1]
                tsImages[idl]["bbox"]=None             
        else:
            tsImages=getRecord(VOC07Data(select=cfg.select,cl="%s_test.txt"%cfg.cls,
                    basepath=cfg.dbpath,#"/home/databases/",
                    usetr=True,usedf=False),cfg.maxtest)
    elif cfg.db=="cvc02":
        #tsImages=getRecord(CVC02test(),cfg.maxtest)
        tsImages=getRecord(CVC02test(basepath="/media/OS/data/DATASET-CVC-02/CVC-02-System/",
                images="/sequence-15/color/",
                annotations="/sequence-15/annotations/",),cfg.maxtest)
        tsImagesFull=tsImages
    elif cfg.db=="ivan":
        stest=10000
        #tsImages=getRecord(ImgFile("/media/OS/data/PVTRA101/CLEAR06_PVTRA101a01_502_Bbox.txt",imgpath="/media/OS/data/PVTRA101/images/"),stest+cfg.maxtest)[stest:]
        #tsImages=getRecord(ImgFile("/media/OS/data/PVTRA101a19/GrTr_CLEAR06_PVTRA101a19.txt",imgpath="/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19/",sort=True,amin=1000),cfg.maxtest)[:600]#[:1950]#the other frames do not have GT
        #tsImages=getRecord(ImgFile("/media/OS/data/PVTRA101a19/GrTr_CLEAR06_PVTRA101a19_only12.txt",imgpath="/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19/",sort=True,amin=100),cfg.maxtest)[:(1950/12)]#the other frames do not have GT
        #tsImages=getRecord(ImgFile("/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19_people_Celik_allfr.txt",imgpath="/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19/",sort=True,amin=100),cfg.maxtest)#pedestrian
        #tsImages=getRecord(ImgFile("/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19_vehicles_Celik_allfr.txt",imgpath="/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19/",sort=True,amin=100),cfg.maxtest)#vechicles
        tsImages=getRecord(ImgFile("/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19_PV_Celik_allfr.txt",imgpath="/media/OS/data/PVTRA101a19/CLEAR06_PVTRA101a19/",sort=True,amin=100),cfg.maxtest)#pedestrian+vechicles
        tsImagesFull=tsImages
        
    #mypool = Pool(numcore)
 
    print "Test"
    print "Pruning Threshold:",cfg.mythr
    numhog=0
    initime=time.time()
    detlist=[]
    mycfg=copy.copy(cfg)
    mycfg.numneg=0
    mycfg.show=False
    arg=[[i,tsImages[i]["name"],None,models,mycfg] for i in range(len(tsImages))]
    t=time.time()
    if not(cfg.multipr):
        itr=itertools.imap(detectWrap,arg)        
    else:
        itr=mypool.imap(detectWrap,arg)
    pylab.figure(20)
    pylab.clf()
    ax = pylab.subplot(111)
    img=util.myimread(tsImages[0]["name"],resize=cfg.resize)
    pylab.ioff()
    axes=pylab.Axes(pylab.gcf(), [.0,.0,1.0,1.0]) # [left, bottom, width, height] where each value is between 0 and 1
    pylab.gcf().add_axes(axes) 
    pylab.axis("off")          
    aim=pylab.imshow(img,interpolation="nearest",animated=True)
    pylab.axis((0,img.shape[1],img.shape[0],0))           
    pylab.draw()
    pylab.show()
    for ii,res in enumerate(itr):
        totneg=0
        fuse=[]
        for mix in res:
            tr=mix[0]
            fuse+=mix[1]
            numhog+=mix[3]
        #for h in fuse:
        #    h["scr"]+=models[h["cl"]]["ra"]
        rfuse=tr.rank(fuse,maxnum=300)
        nfuse=tr.cluster(rfuse,ovr=cfg.ovrasp,inclusion=False)
        #print "----Test Image %d----"%ii
        print "----Test Image %s----"%tsImages[ii]["name"].split("/")[-1]
        for idl,l in enumerate(nfuse):
            #print "DET:",l["bbox"]
            #raw_input()
            #if l["bbox"][0]/cfg.resize<125:
            #    nfuse.pop(idl)
            #    continue
            detlist.append([tsImages[ii]["name"].split("/")[-1].split(".")[0],l["scr"],l["bbox"][1]/cfg.resize,l["bbox"][0]/cfg.resize,l["bbox"][3]/cfg.resize,l["bbox"][2]/cfg.resize])
        print "Detections:",len(nfuse)
        if cfg.show:
            if cfg.show==True:
                showlabel=False#"Parts"#False#"Parts"
            else:
                showlabel=False
            pylab.figure(20)
            xx=pylab.gca()            
            del xx.texts[:]
            del xx.lines[:]
            #print pylab.gca().images
            #pylab.ioff()
#            axes=pylab.Axes(pylab.gcf(), [.0,.0,1.0,1.0]) # [left, bottom, width, height] where each value is between 0 and 1
#            pylab.gcf().add_axes(axes) 
#            pylab.axis("off")
            #img=util.myimread(tsImages[ii]["name"],resize=cfg.resize)
            img=pylab.imread(tsImages[ii]["name"])#myimread has memory problems!!!!!!!
            #pylab.clf()
            aim.set_array(img)
            #ims=pylab.imshow(img,interpolation="nearest",animated=True)
            tr.show(nfuse,parts=showlabel,thr=0,maxnum=100)
            pylab.axis((0,img.shape[1],img.shape[0],0))           
            pylab.draw()
            pylab.show()
            #print ax.images
            #raw_input()
        showGT=True
        if showGT:
            bb=tsImages[ii]["bbox"]
            for mbb in bb:
                util.box(mbb[0], mbb[1], mbb[2], mbb[3], col='r', lw=2)
            pylab.axis((0,img.shape[1],img.shape[0],0))
            pylab.draw()
            #raw_input()
        if select=="dir":
            #RSZ=0.5
            f=pylab.figure(11,figsize=(9,5))
            pylab.ioff()
            pylab.clf()
            axes=pylab.Axes(f, [.0,.0,1.0,1.0]) # [left, bottom, width, height] where each value is between 0 and 1
            f.add_axes(axes) 
            img=util.myimread(tsImages[ii]["name"],resize=cfg.resize)
            pylab.imshow(img,interpolation="nearest",animated=True)
            #raw_input()
            pylab.axis("off")
            tr.show(nfuse,parts=True,thr=-0.99,scr=True)
            pylab.axis((0,img.shape[1],img.shape[0],0))
            pylab.ion()
            pylab.draw()
            pylab.show()  
            #raw_input()
            pylab.savefig("/media/ca0567b8-ee6d-4590-8462-0d093addb4cf/video/det/"+tsImages[ii]["name"].split("/")[-1].split(".")[0]+".png")  
    del itr
    
    #tp,fp,scr,tot=VOCpr.VOCprlistfastscore(tsImages,detlist,numim=cfg.maxpostest,show=False,ovr=0.5)
    #tp,fp,scr,tot=VOCpr.VOCprRecord_wrong(tsImages,detlist,show=False,ovr=0.5)
    tp,fp,scr,tot=VOCpr.VOCprRecord(tsImages,detlist,show=False,ovr=0.5)
    pylab.figure(15)
    pylab.clf()
    rc,pr,ap=VOCpr.drawPrfast(tp,fp,tot)
    pylab.figure(16)
    pylab.clf()
    fppi,miss,ap=VOCpr.drawMissRatePerImage(tp,fp,tot,len(tsImages))
    pylab.draw()
    pylab.show()
    sfdsd
    #pylab.savefig("%s_ap%d_test%s%.1f.png"%(testname,it,select,cfg.mythr))
    tottime=((time.time()-initime))
    print "Threshold used:",cfg.mythr
    print "Total number of HOG:",numhog
    print "AP(it=",it,")=",ap
    print "Testing Time: %.3f s"%tottime#/3600.0)
    #results={"det":detlist,"ap":ap,"tp":tp,"fp":fp,"pr":pr,"rc":rc,"numhog":numhog,"mythr":cfg.mythr,"time":tottime}
    #util.savemat("%s_ap%d_test_thr_%.3f.mat"%(cfg.testname,it,cfg.mythr),results)
    #util.save("%s_ap%d_test_thr_%.3f.dat"%(testname,it,cfg.mythr),results)
    #util.savedetVOC(detlist,"%s_ap%d_test_thr_%.3f.txt"%(testname,it,cfg.mythr))
    #fd=open("%s_ap%d_test%s.txt"%(cfg.testname,it,select),"a")
    #fd.write("Threshold used:%f\n"%cfg.mythr)
    #fd.write("Total number of HOG:%d\n"%numhog)
    #fd.write("Average precision:%f\n"%ap)
    #fd.write("Testing Time: %.3f s\n\n"%tottime)
    #fd.close()
    return ap,numhog
Пример #11
0
def VOCprRecord_wrong(gtImages,detlist,show=False,usetr=True,usedf=False,ovr=0.5):
    """
        calculate the precision recall curve
    """
    dimg={}
    tot=0
    for idx in range(len(gtImages)):
        rect=gtImages[idx]["bbox"][:]
        #if idx>288:
        #    print idx,rect
        if rect!=[]:
            #print gtImages.getImageName(idx).split("/")[-1].split(".")[0]
            dimg[gtImages[idx]["name"].split("/")[-1].split(".")[0]]={"bbox":rect,"det":[False]*len(rect)}
        tot=tot+len(rect)
    imname=[]
    cnt=0
    tp=numpy.zeros(len(detlist))
    fp=numpy.zeros(len(detlist))
    thr=numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx,detbb in enumerate(detlist):
        #print detbb[1]
        found=False
        maxovr=0
        #gtdet=[False]
        gt=0
        if dimg.has_key(detbb[0]):
            rect=dimg[detbb[0]]["bbox"]
            found=False
            for ir,r in enumerate(rect):
                #gtdet.append(False)
                rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
                #print "GT:",r
                #print "DET:",rb
                covr=overlap(rb,r)
                if covr>=maxovr:
                    maxovr=covr
                    gt=ir
                    #dimg[detbb[0]].remove(r)
                    #found=True
                    #break
        if maxovr>ovr:
            #if not(dimg[detbb[0]]["det"][gt]):
            tp[idx]=1
            #dimg[detbb[0]]["det"][gt]=True
            #else:
            #    fp[idx]=1
        else:
            fp[idx]=1
        thr[idx]=detbb[1]
        if show:
            prec=numpy.sum(tp)/float(numpy.sum(tp)+numpy.sum(fp))
            rec=numpy.sum(tp)/tot
            print "Scr:",detbb[1],"Prec:%.3f"%prec,"Rec:%.3f"%rec
            ss=raw_input()
            if ss=="s" or not(found):
                pylab.ioff()
                img=gtImages.getImageByName2(detbb[0])
                pylab.figure(1)
                pylab.clf()
                pylab.imshow(img)
                rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
                for r in rect:
                    pylab.figure(1)
                    pylab.ioff()
                    box(r[0],r[1],r[2],r[3],'b',lw=1.5)
                if found:
                    box(rb[0],rb[1],rb[2],rb[3],'g',lw=1.5)
                else:
                    box(rb[0],rb[1],rb[2],rb[3],'r',lw=1.5)
                pylab.draw()
                pylab.show()
                rect=[]

    return tp,fp,thr,tot
Пример #12
0
def VOCprRecordthr(gtImages,detlist,show=False,ovr=0.5,pixels=None):
    """
        calculate the precision recall curve
    """
    dimg={}
    tot=0
    posd=[]
    for idx in range(len(gtImages)):
        rect=gtImages[idx]["bbox"][:]
        #if idx>288:
        #    print idx,rect
        if rect!=[]:
            #print gtImages.getImageName(idx).split("/")[-1].split(".")[0]
            dimg[gtImages[idx]["name"].split("/")[-1].split(".")[0]]={"bbox":rect,"det":[False]*len(rect)}
            for i, recti in enumerate(rect):
                if recti[5] == 0:
                    tot=tot+1

    imname=[]
    cnt=0
    tp=numpy.zeros(len(detlist))
    fp=numpy.zeros(len(detlist))
    thr=numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx,detbb in enumerate(detlist):
        #print detbb[1]
        found=False
        maxovr=0
        #gtdet=[False]
        gt=0
        if dimg.has_key(detbb[0]):
            rect=dimg[detbb[0]]["bbox"]
            found=False
            for ir,r in enumerate(rect):
                #gtdet.append(False)
                rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
                #print "GT:",r
                #print "DET:",rb
                if pixels==None:
                    covr=overlap(rb,r)
                else:
                    covr=overlapx(rb,r,pixels)
                if covr>=maxovr:
                    maxovr=covr
                    gt=ir
                    #dimg[detbb[0]].remove(r)
                    #found=True
                    #break

        if maxovr>ovr:
            if dimg[detbb[0]]["bbox"][gt][5] == 0:
                if not(dimg[detbb[0]]["det"][gt]):
                    tp[idx]=1
                    dimg[detbb[0]]["det"][gt]=True
                    posd.append(detbb[1])
                else:
                    fp[idx]=1
        else:
            fp[idx]=1

########### PASCAL 2010
#    if ovmax>=VOCopts.minoverlap
#        if ~gt(i).diff(jmax)
#            if ~gt(i).det(jmax)
#                tp(d)=1;            % true positive
#		        gt(i).det(jmax)=true;
#            else
#                fp(d)=1;            % false positive (multiple detection)
#            end
#        end
#    else
#        fp(d)=1;                    % false positive
#    end
########################



        thr[idx]=detbb[1]
        if show:
            prec=numpy.sum(tp)/float(numpy.sum(tp)+numpy.sum(fp))
            rec=numpy.sum(tp)/tot
            print "Scr:",detbb[1],"Prec:%.3f"%prec,"Rec:%.3f"%rec
            ss=raw_input()
            if ss=="s" or not(found):
                pylab.ioff()
                img=gtImages.getImageByName2(detbb[0])
                pylab.figure(1)
                pylab.clf()
                pylab.imshow(img)
                rb=(float(detbb[3]),float(detbb[2]),float(detbb[5]),float(detbb[4]))
                for r in rect:
                    pylab.figure(1)
                    pylab.ioff()
                    box(r[0],r[1],r[2],r[3],'b',lw=1.5)
                if found:
                    box(rb[0],rb[1],rb[2],rb[3],'g',lw=1.5)
                else:
                    box(rb[0],rb[1],rb[2],rb[3],'r',lw=1.5)
                pylab.draw()
                pylab.show()
                rect=[]

    return tp,fp,thr,tot,posd
Пример #13
0
def VOCprlistfast(gtImages,
                  detlist,
                  show=False,
                  usetr=True,
                  usedf=False,
                  ovr=0.5):
    """
        calculate the precision recall curve
    """
    dimg = {}
    tot = 0
    for idx in range(gtImages.getTotal()):
        rect = gtImages.getBBox(idx)
        if rect != []:
            dimg[gtImages.getImageName(idx).split("/")[-1].split(".")
                 [0]] = rect
        tot = tot + len(rect)
        #print tot
    imname = []
    cnt = 0
    tp = numpy.zeros(len(detlist))
    fp = numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx, detbb in enumerate(
            detlist):  #detlist[sortlist]):#gtImages.getTotal()):
        found = False
        if dimg.has_key(detbb[0]):
            rect = dimg[
                detbb[0]]  #gtImages.getBBox(idx,usetr=usetr,usedf=usedf)
            #print rect
            found = False
            for r in rect:
                rb = (float(detbb[3]), float(detbb[2]), float(detbb[5]),
                      float(detbb[4]))
                if overlap(rb, r) >= ovr:
                    dimg[detbb[0]].remove(r)
                    found = True
                    break
        if found:
            tp[idx] = 1  #.append(float(detbb[1]))
        else:
            fp[idx] = 1  #.append(float(detbb[1]))
        if show:
            pylab.ioff()
            img = gtImages.getImageByName2(detbb[0])
            pylab.figure(1)
            pylab.clf()
            pylab.imshow(img)
            rb = (float(detbb[3]), float(detbb[2]), float(detbb[5]),
                  float(detbb[4]))
            for r in rect:
                pylab.figure(1)
                pylab.ioff()
                box(r[0], r[1], r[2], r[3], 'b', lw=1.5)
            if found:
                box(rb[0], rb[1], rb[2], rb[3], 'g', lw=1.5)
            else:
                box(rb[0], rb[1], rb[2], rb[3], 'r', lw=1.5)
            pylab.draw()
            pylab.show()
            rect = []
            raw_input()

    return tp, fp, tot
Пример #14
0
def VOCprRecordOptim(gtImages, detlist, show=False, ovr=0.5, pixels=None):
    """
        calculate the precision recall curve
    """
    tx = []
    ty = []
    sx = []
    sy = []
    dimg = {}
    tot = 0
    for idx in range(len(gtImages)):
        rect = gtImages[idx]["bbox"][:]
        if rect != []:
            dimg[gtImages[idx]["name"].split(
                "/")[-1].split(".")[0]] = {"bbox": rect, "det": [False] * len(rect)}
            for i, recti in enumerate(rect):
                if recti[5] == 0:
                    tot = tot + 1

    imname = []
    cnt = 0
    tp = numpy.zeros(len(detlist))
    fp = numpy.zeros(len(detlist))
    thr = numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx, detbb in enumerate(detlist):
        found = False
        maxovr = 0
        gt = 0
        if dimg.has_key(detbb[0]):
            rect = dimg[detbb[0]]["bbox"]
            found = False
            for ir, r in enumerate(rect):
                rb = (float(detbb[3]), float(detbb[2]),
                      float(detbb[5]), float(detbb[4]))
                if pixels == None:
                    covr = overlap(rb, r)
                else:
                    covr = overlapx(rb, r, pixels)
                if covr >= maxovr:
                    maxovr = covr
                    gt = ir

        if maxovr > ovr:
            if dimg[detbb[0]]["bbox"][gt][5] == 0:
                if not(dimg[detbb[0]]["det"][gt]):
                    tp[idx] = 1
                    dimg[detbb[0]]["det"][gt] = True
                    gtx = dimg[detbb[0]]["bbox"][gt][
                        3] - dimg[detbb[0]]["bbox"][gt][1]
                    dtx = detbb[4] - detbb[2]
                    gty = dimg[detbb[0]]["bbox"][gt][
                        2] - dimg[detbb[0]]["bbox"][gt][0]
                    dty = detbb[5] - detbb[3]
                    gtcx = (
                        dimg[detbb[0]]["bbox"][gt][3] + dimg[detbb[0]]["bbox"][gt][1]) / 2.
                    dtcx = (detbb[4] + detbb[2]) / 2.
                    gtcy = (
                        dimg[detbb[0]]["bbox"][gt][2] + dimg[detbb[0]]["bbox"][gt][0]) / 2.
                    dtcy = (detbb[5] + detbb[3]) / 2.
                    tx.append((gtcx - dtcx) / float(dtx))
                    ty.append((gtcy - dtcy) / float(dty))
                    sx.append(gtx / float(dtx))
                    sy.append(gty / float(dty))
                else:
                    fp[idx] = 1
        else:
            fp[idx] = 1

        thr[idx] = detbb[1]
        if show:
            prec = numpy.sum(tp) / float(numpy.sum(tp) + numpy.sum(fp))
            rec = numpy.sum(tp) / tot
            print("Scr:", detbb[1], "Prec:%.3f" % prec, "Rec:%.3f" % rec)
            ss = raw_input()
            if ss == "s" or not(found):
                pylab.ioff()
                img = gtImages.getImageByName2(detbb[0])
                pylab.figure(1)
                pylab.clf()
                pylab.imshow(img)
                rb = (float(detbb[3]), float(detbb[2]),
                      float(detbb[5]), float(detbb[4]))
                for r in rect:
                    pylab.figure(1)
                    pylab.ioff()
                    box(r[0], r[1], r[2], r[3], 'b', lw=1.5)
                if found:
                    box(rb[0], rb[1], rb[2], rb[3], 'g', lw=1.5)
                else:
                    box(rb[0], rb[1], rb[2], rb[3], 'r', lw=1.5)
                pylab.draw()
                pylab.show()
                rect = []

    return tp, fp, thr, tot, tx, ty, sx, sy
Пример #15
0
    #det=util.load("./data/CRF/12_10_02_parts_full/bicycle2_testN1_final.det")["det"]
    #det=util.load("./data/CRF/12_10_02_parts_full/bicycle2_testN2_final.txt")
    #fl=open("./data/CRF/12_10_02_parts_full/bicycle2_testN2_final.txt")
    fl=open("./data/inria1_inria3.txt")
    det=fl.readlines()
    imgpath=cfg.dbpath+"VOC2007/VOCdevkit/VOC2007/JPEGImages/"#VOC
    imgpath=cfg.dbpath+"INRIAPerson/Test/pos/"#inria
    for idl,l in enumerate(det):
        imname,scr,b0,b1,b2,b3=l.split()
        try:
            img=util.myimread(imgpath+imname+".png")
        except:
            img=util.myimread(imgpath+imname+".jpg")
        pl.figure(100)        
        pl.clf()
        pl.imshow(img)
        util.box(int(b1),int(b0),int(b3),int(b2),"w",lw=2)
        pl.title("Rank:%d Scr:%.3f"%(idl,float(scr)))
        pl.axis([0,img.shape[1],img.shape[0],0])
        #detectCRF.visualize2([l],2,img,text="rank:%d"%(idl))
        pl.draw()
        pl.show()
        raw_input()







Пример #16
0
def bar_gen(xpos):
    topPos = random.randint(round(figure_size/10), round(figure_size*2/5))
    topbar = box(xpos, 0, h = topPos, w = 25)
    bottombar = box(xpos, topPos + gapDistance , h = figure_size - topPos - gapDistance, w= 25)

    return [topbar, bottombar]
Пример #17
0
def viewDet(gtImages,detfile,opt="all",usetr=True,usedf=False,stop=True,t=0.5):
    detf=open(detfile,"r")
    detect=detf.readlines()
    detlst=numpy.zeros((len(detect),5))
    namelst=[]
    pylab.ioff()
    for id,el in enumerate(detect):
        aux=el.split()
        namelst.append(aux[0])
        detlst[id,:]=aux[1:]
    srt=numpy.argsort(-detlst[:,0])
    imname=[]
    cnt=0
    ovr=0.49
    #print trPosImages.getTotal()
    tp=[]
    fp=[]
    tot=0
    pylab.figure()
    bb=numpy.zeros((4))
    for id in range(detlst.shape[0]):
        pylab.ioff()
        abb=detlst[srt[id]]
        conf=abb[0]
        bb[0]=abb[2];bb[1]=abb[1];bb[2]=abb[4];bb[3]=abb[3]
        pylab.clf()
        img=gtImages.getImageByName2(namelst[srt[id]])
        gtbb=gtImages.getBBoxByName(namelst[srt[id]],usetr=usetr,usedf=usedf)
        found=False
        for l in range(len(gtbb)):
            pylab.imshow(img)
            pylab.title("%s Confidence: %f"%(namelst[srt[id]],float(conf)))
            #box(gtbb[l][0],gtbb[l][1],gtbb[l][2],gtbb[l][3],col='b',lw="2")
            print overlap(bb[:],gtbb[l][:4])
            if overlap(bb[:],gtbb[l][:4])>0:
                if overlap(bb[:],gtbb[l][:4])>ovr:
                    box(gtbb[l][0],gtbb[l][1],gtbb[l][2],gtbb[l][3],col='y',lw="2")
                    box(bb[0],bb[1],bb[2],bb[3],col='g',lw="2")
                    pylab.show()
                    pylab.draw()
                    if stop:
                        raw_input()
                    else:
                        time.sleep(t)
                    found=True
                else:
                    box(gtbb[l][0],gtbb[l][1],gtbb[l][2],gtbb[l][3],col='y',lw="1")
                    #box(bb[0],bb[1],bb[2],bb[3],col='g',lw="2")
                    #raw_input()
            else:
                pass
                #pylab.imshow(img)
                #box(bb[0],bb[1],bb[2],bb[3],col='r',lw="2")
        if not(found):
            pylab.imshow(img)
            box(bb[0],bb[1],bb[2],bb[3],col='r',lw="2")
            pylab.show()
            pylab.draw()
            if stop:
                raw_input()
            else:
                time.sleep(t)
Пример #18
0
def VOCprRecord_wrong(gtImages,
                      detlist,
                      show=False,
                      usetr=True,
                      usedf=False,
                      ovr=0.5):
    """
        calculate the precision recall curve
    """
    dimg = {}
    tot = 0
    for idx in range(len(gtImages)):
        rect = gtImages[idx]["bbox"][:]
        #if idx>288:
        #    print idx,rect
        if rect != []:
            #print gtImages.getImageName(idx).split("/")[-1].split(".")[0]
            dimg[gtImages[idx]["name"].split("/")[-1].split(".")[0]] = {
                "bbox": rect,
                "det": [False] * len(rect)
            }
        tot = tot + len(rect)
    imname = []
    cnt = 0
    tp = numpy.zeros(len(detlist))
    fp = numpy.zeros(len(detlist))
    thr = numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx, detbb in enumerate(detlist):
        #print detbb[1]
        found = False
        maxovr = 0
        #gtdet=[False]
        gt = 0
        if dimg.has_key(detbb[0]):
            rect = dimg[detbb[0]]["bbox"]
            found = False
            for ir, r in enumerate(rect):
                #gtdet.append(False)
                rb = (float(detbb[3]), float(detbb[2]), float(detbb[5]),
                      float(detbb[4]))
                #print "GT:",r
                #print "DET:",rb
                covr = overlap(rb, r)
                if covr >= maxovr:
                    maxovr = covr
                    gt = ir
                    #dimg[detbb[0]].remove(r)
                    #found=True
                    #break
        if maxovr > ovr:
            #if not(dimg[detbb[0]]["det"][gt]):
            tp[idx] = 1
            #dimg[detbb[0]]["det"][gt]=True
            #else:
            #    fp[idx]=1
        else:
            fp[idx] = 1
        thr[idx] = detbb[1]
        if show:
            prec = numpy.sum(tp) / float(numpy.sum(tp) + numpy.sum(fp))
            rec = numpy.sum(tp) / tot
            print "Scr:", detbb[1], "Prec:%.3f" % prec, "Rec:%.3f" % rec
            ss = raw_input()
            if ss == "s" or not (found):
                pylab.ioff()
                img = gtImages.getImageByName2(detbb[0])
                pylab.figure(1)
                pylab.clf()
                pylab.imshow(img)
                rb = (float(detbb[3]), float(detbb[2]), float(detbb[5]),
                      float(detbb[4]))
                for r in rect:
                    pylab.figure(1)
                    pylab.ioff()
                    box(r[0], r[1], r[2], r[3], 'b', lw=1.5)
                if found:
                    box(rb[0], rb[1], rb[2], rb[3], 'g', lw=1.5)
                else:
                    box(rb[0], rb[1], rb[2], rb[3], 'r', lw=1.5)
                pylab.draw()
                pylab.show()
                rect = []

    return tp, fp, thr, tot
Пример #19
0
def viewSortDet(gtImages,
                detlist,
                numim=numpy.inf,
                opt="all",
                usetr=True,
                usedf=False,
                ovr=0.5):
    dimg = {}
    tot = 0
    for idx in range(min(gtImages.getTotal(), numim)):
        rect = gtImages.getBBox(idx)
        if rect != []:
            #print gtImages.getImageName(idx).split("/")[-1].split(".")[0]
            dimg[gtImages.getImageName(idx).split("/")[-1].split(".")
                 [0]] = rect
        tot = tot + len(rect)
    imname = []
    cnt = 0
    tp = numpy.zeros(len(detlist))
    fp = numpy.zeros(len(detlist))
    thr = numpy.zeros(len(detlist))
    detlist.sort(cmpscore)
    for idx, detbb in enumerate(detlist):
        #print detbb[1]
        found = False
        if dimg.has_key(detbb[0]):
            rect = dimg[detbb[0]]
            found = False
            for r in rect:
                rb = (float(detbb[3]), float(detbb[2]), float(detbb[5]),
                      float(detbb[4]))
                #print "GT:",r
                #print "DET:",rb
                if overlap(rb, r) >= ovr:
                    dimg[detbb[0]].remove(r)
                    found = True
                    break
        if found:
            tp[idx] = 1
        else:
            fp[idx] = 1
        thr[idx] = detbb[1]
        if show:
            pylab.ioff()
            prec = numpy.sum(tp) / float(numpy.sum(tp) + numpy.sum(fp))
            rec = numpy.sum(tp) / tot
            print "Scr:", detbb[1], "Prec:", prec, "Rec:", rec
            img = gtImages.getImageByName2(detbb[0])
            pylab.figure(1)
            pylab.clf()
            pylab.imshow(img)
            rb = (float(detbb[3]), float(detbb[2]), float(detbb[5]),
                  float(detbb[4]))
            for r in rect:
                pylab.figure(1)
                pylab.ioff()
                box(r[0], r[1], r[2], r[3], 'b', lw=1.5)
            if found:
                box(rb[0], rb[1], rb[2], rb[3], 'g', lw=1.5)
            else:
                box(rb[0], rb[1], rb[2], rb[3], 'r', lw=1.5)
            pylab.draw()
            pylab.show()
            rect = []
            raw_input()

    return tp, fp, thr, tot
Пример #20
0
def VOCprlist(gtImages,detlist,show=False,usetr=True,usedf=False,ovr=0.5):
    """
        calculate the precision recall curve
    """
    #detf=open(detfile,"r")
    #detect=detf.readlines()
    imname=[]
    cnt=0
    #ovr=0.49
    #print trPosImages.getTotal()
    tp=[]
    fp=[]
    tot=0
    for idx in range(gtImages.getTotal()):
        print gtImages.getImageName(idx)
        if show:
            img=gtImages.getImage(idx)
            pylab.figure(1)
            pylab.clf()
            pylab.imshow(img)
        #pyr=HOGcompute.HOGcrop(img,interv=interv)
        #pyr.pad()
        #pyr.pad()
        #pyr.contrast()
        rect=gtImages.getBBox(idx,usetr=usetr,usedf=usedf)
        print rect
        if show:
            for r in rect:
                pylab.figure(1)
                pylab.ioff()
                box(r[0],r[1],r[2],r[3],'b',lw=1.5)
                #raw_input()
        tot=tot+len(rect)
        #print len(rect),rect
        #print rect
        for l in detlist:
            data=l#.split(" ")
            if data[0]==gtImages.getImageName(idx).split("/")[-1].split(".")[0]:
                notfound=True
                rb=[float(data[3]),float(data[2]),float(data[5]),float(data[4])]
                if show:
                    pylab.ioff()
                    pylab.text(rb[1],rb[0],data[1])
                for id,r in enumerate(rect):
                    #pylab.figure(1)
                    #box(r[0],r[1],r[2],r[3],'b',lw=1.5)
                    #print "entered",data
                    #rb=[float(data[3]),float(data[2]),float(data[5]),float(data[4])]
                    #print rb,r,overlap(rb,r)
                    #pylab.text(rb[1],rb[0],data[1])
                    if overlap(rb,r)>=ovr:
                        if show:
                            pylab.ioff()
                            box(rb[0],rb[1],rb[2],rb[3],'g',lw=1.5)
                        del rect[id]
                        tp.append(float(data[1]))
                        notfound=False
                        break
                if notfound==True:
                    if show:
                        pylab.ioff()
                        box(rb[0],rb[1],rb[2],rb[3],'r',lw=1)                        
                    fp.append(float(data[1]))
                #print len(tp),len(fp),tot            
            #break
        if show:
            pylab.figure(1)
            pylab.show()
            pylab.draw()
        #raw_input()
    return tp,fp,tot
Пример #21
0
comments are sub par
"""

pygame.init()
figure_size = 500
window = pygame.display.set_mode((figure_size, figure_size))

def draw_text(surf, text, size, x, y):
    font = pygame.font.Font(pygame.font.match_font('arial'), size)
    text_surface = font.render(text, True, (255, 255, 255))
    text_rect = text_surface.get_rect()
    text_rect.midtop = (x, y)
    surf.blit(text_surface, text_rect)

floorTop = 50 # distance from the bottom
player = box(100, floorTop)

floor = [box(-15, 0, h = figure_size)]

dis = 12.5 # distance between each block
for i in range(1, math.ceil(figure_size/dis)):
    colo = sequencial_color(floor[i-1].color, step = 20)
    floor.append(box(i*dis, 0, color = colo, h = figure_size))

floorVelo = 5
floorLen = len(floor)


player = box(50, figure_size-floorTop-100)
keys = pygame.key.get_pressed()
playerVelo = 0