Exemple #1
0
def detectWrap(a):
    t=time.time()
    i=a[0]
    imname=a[1]
    bbox=a[2]
    m=a[3]
    cfg=a[4]
    if cfg.show:
        img=util.myimread(imname)
        pylab.figure(10)
        pylab.ioff()
        pylab.clf()
        pylab.axis("off")
        pylab.imshow(img,interpolation="nearest",animated=True) 
    if bbox!=None:
        gtbbox=[{"bbox":x} for x in bbox]   
    else:
        gtbbox=None
    f=pyrHOG2.pyrHOG(imname,interv=10,savedir=cfg.savedir+"/hog/",notload=not(cfg.loadfeat),notsave=not(cfg.savefeat),hallucinate=cfg.hallucinate,cformat=True)
    res=pyrHOG2.detect(f,m,gtbbox,hallucinate=cfg.hallucinate,initr=cfg.initr,ratio=cfg.ratio,deform=cfg.deform,posovr=cfg.posovr,bottomup=cfg.bottomup,usemrf=cfg.usemrf,numneg=cfg.numneg,thr=cfg.thr,inclusion=cfg.inclusion,small=False,show=cfg.show,usefather=cfg.usefather,emptybb=True,useprior=cfg.useprior)
    if cfg.show:
        pylab.show()
#        raw_input()
    print "Detect Wrap:",time.time()-t
    return res
Exemple #2
0
def detectWrap(a):
    i=a[0]
    imname=a[1]
    bbox=a[2]
    models=a[3]
    cfg=a[4]
    if cfg.show:
        img=util.myimread(imname)
        pylab.figure(10)
        pylab.ioff()
        pylab.clf()
        pylab.axis("off")
        pylab.imshow(img,interpolation="nearest",animated=True) 
    if bbox!=None:
        gtbbox=[{"bbox":x,"img":imname.split("/")[-1]} for x in bbox]   
    else:
        gtbbox=None
    notsave=False
    #if cfg.__dict__.has_key("test"):
    #    notsave=cfg.test
    f=pyrHOG2.pyrHOG(imname,interv=10,savedir=cfg.auxdir+"/hog/",notsave=not(cfg.savefeat),notload=not(cfg.loadfeat),hallucinate=cfg.hallucinate,cformat=True)
    res=[]
    for clm,m in enumerate(models):
        res.append(pyrHOG2.detect(f,m,gtbbox,hallucinate=cfg.hallucinate,initr=cfg.initr,ratio=cfg.ratio,deform=cfg.deform,bottomup=cfg.bottomup,usemrf=cfg.usemrf,numneg=cfg.numneg,thr=cfg.thr,posovr=cfg.posovr,minnegincl=cfg.minnegincl,small=cfg.small,show=cfg.show,cl=clm,mythr=cfg.mythr,mpos=cfg.mpos,usefather=cfg.usefather,useprior=cfg.useprior,emptybb=False,K=cfg.k))
    if cfg.show:
        pylab.show()
    return res
Exemple #3
0
def detectWrap(a):
    i=a[0]
    imname=a[1]
    bbox=a[2]
    models=a[3]
    cfg=a[4]
    if cfg.show:
        img=util.myimread(imname)
        pylab.figure(10)
        pylab.ioff()
        pylab.clf()
        pylab.axis("off")
        pylab.imshow(img,interpolation="nearest",animated=True) 
    if bbox!=None:
        gtbbox=[{"bbox":x} for x in bbox]   
    else:
        gtbbox=None
    notsave=False
    #if cfg.__dict__.has_key("test"):
    #    notsave=cfg.test
    f=pyrHOG2.pyrHOG(imname,interv=10,savedir=cfg.auxdir+"/hog/",notsave=not(cfg.savefeat),notload=not(cfg.loadfeat),hallucinate=cfg.hallucinate,cformat=True)
    res=[]
    for clm,m in enumerate(models):
        res.append(pyrHOG2.detect(f,m,gtbbox,hallucinate=cfg.hallucinate,initr=cfg.initr,ratio=cfg.ratio,deform=cfg.deform,bottomup=cfg.bottomup,usemrf=cfg.usemrf,numneg=cfg.numneg,thr=cfg.thr,posovr=cfg.posovr,minnegincl=cfg.minnegincl,small=cfg.small,show=cfg.show,cl=clm,mythr=cfg.mythr,mpos=cfg.mpos,usefather=cfg.usefather,useprior=cfg.useprior,K=cfg.k))
    if cfg.show:
        pylab.show()
    return res
Exemple #4
0
def detectWrap(a):
    t = time.time()
    i = a[0]
    imname = a[1]
    bbox = a[2]
    m = a[3]
    cfg = a[4]
    if cfg.show:
        img = util.myimread(imname)
        pylab.figure(10)
        pylab.ioff()
        pylab.clf()
        pylab.axis("off")
        pylab.imshow(img, interpolation="nearest", animated=True)
    if bbox != None:
        gtbbox = [{"bbox": x} for x in bbox]
    else:
        gtbbox = None
    img = util.myimread(imname, resize=RSZ)
    f = pyrHOG2.pyrHOG(img,
                       interv=10,
                       savedir=cfg.savedir + "/hog/",
                       notload=not (cfg.loadfeat),
                       notsave=not (cfg.savefeat),
                       hallucinate=cfg.hallucinate,
                       cformat=True)
    res = pyrHOG2.detect(f,
                         m,
                         gtbbox,
                         hallucinate=cfg.hallucinate,
                         initr=cfg.initr,
                         ratio=cfg.ratio,
                         deform=cfg.deform,
                         posovr=cfg.posovr,
                         bottomup=cfg.bottomup,
                         usemrf=cfg.usemrf,
                         numneg=cfg.numneg,
                         thr=cfg.thr,
                         inclusion=cfg.inclusion,
                         small=cfg.small,
                         show=cfg.show,
                         usefather=cfg.usefather,
                         useprior=cfg.useprior,
                         nms=cfg.ovr,
                         K=cfg.k)
    if cfg.show:
        pylab.show()


#        raw_input()
    print "Detect Wrap:", time.time() - t
    return res
Exemple #5
0
def detectWrap(a):
    i = a[0]
    imname = a[1]
    bbox = a[2]
    models = a[3]
    cfg = a[4]
    if len(a) <= 5:
        imageflip = False
    else:
        imageflip = a[5]
    img = util.myimread(imname, resize=cfg.resize)
    if imageflip:
        img = util.myimread(imname, True, resize=cfg.resize)
        if bbox != None:
            bbox = util.flipBBox(img, bbox)
    if bbox != None:
        gtbbox = [{"bbox": x, "img": imname.split("/")[-1]} for x in bbox]
    else:
        gtbbox = None
    if cfg.show:
        img = util.myimread(imname, imageflip, resize=cfg.resize)
        pylab.figure(10)
        pylab.ioff()
        pylab.clf()
        pylab.axis("off")
        pylab.imshow(img, interpolation="nearest", animated=True)
    notsave = False
    #if cfg.__dict__.has_key("test"):
    #    notsave=cfg.test
    #f=pyrHOG2.pyrHOG(imname,interv=10,savedir=cfg.auxdir+"/hog/",notsave=not(cfg.savefeat),notload=not(cfg.loadfeat),hallucinate=cfg.hallucinate,cformat=True,flip=imageflip,resize=cfg.resize)
    f = pyrHOG2.pyrHOG(img,
                       interv=10,
                       savedir=cfg.auxdir + "/hog/",
                       notsave=not (cfg.savefeat),
                       notload=not (cfg.loadfeat),
                       hallucinate=cfg.hallucinate,
                       cformat=True)  #,flip=imageflip,resize=cfg.resize)
    res = []
    for clm, m in enumerate(models):
        if cfg.useRL:
            res.append(
                pyrHOG2RL.detectflip(f,
                                     m,
                                     gtbbox,
                                     hallucinate=cfg.hallucinate,
                                     initr=cfg.initr,
                                     ratio=cfg.ratio,
                                     deform=cfg.deform,
                                     bottomup=cfg.bottomup,
                                     usemrf=cfg.usemrf,
                                     numneg=cfg.numneg,
                                     thr=cfg.thr,
                                     posovr=cfg.posovr,
                                     minnegincl=cfg.minnegincl,
                                     small=cfg.small,
                                     show=cfg.show,
                                     cl=clm,
                                     mythr=cfg.mythr,
                                     mpos=cfg.mpos,
                                     usefather=cfg.usefather,
                                     useprior=cfg.useprior,
                                     K=cfg.k))
        else:
            res.append(
                pyrHOG2.detect(f,
                               m,
                               gtbbox,
                               hallucinate=cfg.hallucinate,
                               initr=cfg.initr,
                               ratio=cfg.ratio,
                               deform=cfg.deform,
                               bottomup=cfg.bottomup,
                               usemrf=cfg.usemrf,
                               numneg=cfg.numneg,
                               thr=cfg.thr,
                               posovr=cfg.posovr,
                               minnegincl=cfg.minnegincl,
                               small=cfg.small,
                               show=cfg.show,
                               cl=clm,
                               mythr=cfg.mythr,
                               mpos=cfg.mpos,
                               usefather=cfg.usefather,
                               useprior=cfg.useprior,
                               emptybb=False,
                               K=cfg.k))
    if cfg.show:
        pylab.draw()
        pylab.show()
    return res
Exemple #6
0
import pylab

#show the model
if True:
    print "Show model"
    pylab.figure(100)
    pylab.clf()
    util2.drawModel(m["ww"])
    pylab.draw()

print "---- Image %s----"%imname
print
img=util2.myimread(imname)
#compute the HOG pyramid
f=pyrHOG2.pyrHOG(img,interv=10,savedir="",notload=True,notsave=True,hallucinate=True,cformat=True)
print
print "Complete search"
showImage(img,title="Complete search")
res=pyrHOG2.detect(f,m,bottomup=True,deform=True,usemrf=True,small=False,show=True)
pylab.axis((0,img.shape[1],img.shape[0],0))
dettime1=res[2]
numhog1=res[3]
print "Number of computed HOGs:",numhog1
print
print "Coarse-to-Fine search"
import pylab
showImage(img,title="Coarse-to-Fine")
res=pyrHOG2.detect(f,m,bottomup=False,deform=True,usemrf=True,small=False,show=True)
pylab.axis((0,img.shape[1],img.shape[0],0))
pylab.draw()