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
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
fig.add_axes(axes) pylab.imshow(img,interpolation="nearest",animated=True) t=time.time() #for each class for ccls in cls: print print "Class: %s"%ccls #load the class model m=util2.load("%s%d.model"%(cfg.testname%ccls,7)) res=[] t1=time.time() #for each aspect for clm,m in enumerate(m): #scan the image with left and right models res.append(pyrHOG2RL.detectflip(f,m,None,hallucinate=cfg.hallucinate,initr=cfg.initr,ratio=cfg.ratio,deform=cfg.deform,bottomup=cfg.bottomup,usemrf=cfg.usemrf,small=False,cl=clm)) fuse=[] numhog=0 #fuse the detections for mix in res: tr=mix[0] fuse+=mix[1] numhog+=mix[3] rfuse=tr.rank(fuse,maxnum=300) nfuse=tr.cluster(rfuse,ovr=0.3,inclusion=False) pylab.axis("off") #show detections tr.show(nfuse,parts=True,thr=-0.98,scr=True,maxnum=10,cls=ccls) pylab.axis((0,img.shape[1],img.shape[0],0)) print "Number of computed HOGs:",numhog print "Elapsed time: %.3f s"%(time.time()-t)