Ejemplo n.º 1
0
    def calcdX(self):
        print "calcDX"
        #        print "CurrentShape as points"
        #        print self.X

        #        print "CurrentShape as ActiveShape"
        Xshape = ActiveShape.createShape(self.X)
        #       for p in Xshape.shapePoints:
        #           print p.x, p.y

        # for pt in Xshape.shapePoints:
        #    print pt.x, pt.y
        if self.method == "grad":
            PMC = pmc(self.img, self.maxPx)
            return np.ravel(map(lambda p: PMC.calcShift(p, "tx"), Xshape.shapePoints))
        else:
            TM = TemplateMatcher(self.method, self.fSize, self.fPts)
        return np.ravel(TM.performMatching(self.img, Xshape))
Ejemplo n.º 2
0
    def calcdX(self):
        print "calcDX"
        #        print "CurrentShape as points"
        #        print self.X

        #        print "CurrentShape as ActiveShape"
        Xshape = ActiveShape.createShape(self.X)
        #       for p in Xshape.shapePoints:
        #           print p.x, p.y

        #for pt in Xshape.shapePoints:
        #    print pt.x, pt.y
        if self.method == "grad":
            PMC = pmc(self.img, self.maxPx)
            return np.ravel(
                map(lambda p: PMC.calcShift(p, 'tx'), Xshape.shapePoints))
        else:
            TM = TemplateMatcher(self.method, self.fSize, self.fPts)
        return np.ravel(TM.performMatching(self.img, Xshape))
ebenShape = ActiveShape( ebenPoints 

## draw indices
DrawFace( ebenShape, plt).labelIndices()
plt.imshow( ebenFace )
plt.set_cmap( "gray" )
plt.set_cmap( "gray" )
plt.gca().axes.xaxis.set_ticks([])
plt.gca().axes.yaxis.set_ticks([])

plt.show()




 
#### MATCHING PROCESS

# Read in image
I = cv2.imread( "C:\Users\Valerie\Desktop\MicroExpress\CASME2\CASME2_RAW\CASME2-RAW\sub01\EP02_01f\img1.jpg")
I = cv2.cvtColor( I, cv2.COLOR_BGR2GRAY)

# Align shape
asm = ActiveShapeModel( [36,31] )
asm = fh.readInASM( asm )
asm.PCA()  
appASM = ApplyASM( asm, i, tr, out, I, "SSD", 5,5 )
m, tdict = appASM.initialPosition( )

TM = TemplateMatcher( 'SSD', 5, True )
TM.performMatching(I, m)