forked from marcopede/CFdet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detectINRIA.py
66 lines (55 loc) · 1.49 KB
/
detectINRIA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#scan an image with the standard method and with our CtF way
import util2
import pyrHOG2
import time
def showImage(img,title=""):
import pylab
pylab.figure()
pylab.ioff()
pylab.clf()
pylab.axis("off")
pylab.title(title)
pylab.imshow(img,interpolation="nearest",animated=True)
modelname="./data/INRIA/inria_bothfull";it=7
import sys
if len(sys.argv)>1:
imname=sys.argv[1]
else:
imname="test1.png"
#load the model
m=util2.load("%s%d.model"%(modelname,it))
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()
pylab.show()
dettime2=res[2]
numhog2=res[3]
print "Number of computed HOGs:",numhog2
print
print "Time Speed-up: %.3f "%(dettime1/dettime2)
print "HOG Speed-up: %.3f "%(numhog1/float(numhog2))