def test_computeBlockInit(self): smAngle = hogc.StatsMaker("angle") smMag = hogc.StatsMaker("magnitude") aHistTemplate = hogc.AngleHistogram(18, 0, 2*math.pi, hogc.AngleHistogram.ContributionPolicy.Magnitude, hogc.AngleHistogram.InterpolationPolicy.YesInterpolation) hog = hogc.Hog(self.hogScheme, hogc.Hog.BlockGaussianWeightingPolicy.NoGaussian, hogc.Hog.BlockNormalizationPolicy.NoNormalization) histVec = hogc.FloatVec() hog.computeBlock( self.grayImg, aHistTemplate, 2, 3, smAngle, smMag,False, histVec) print "angle stats Maker", hogc.describeStatsMaker(smAngle) print "magnitude stats Maker", hogc.describeStatsMaker(smMag) pass
def test_computeCell(self): smAngle = hogc.StatsMaker("angle") smMag = hogc.StatsMaker("magnitude") blockTopLeft = hogc.Point2i(0,0) aHist = hogc.AngleHistogram(18, 0, 2*math.pi, hogc.AngleHistogram.ContributionPolicy.Magnitude, hogc.AngleHistogram.InterpolationPolicy.YesInterpolation) hog = hogc.Hog(self.hogScheme, hogc.Hog.BlockGaussianWeightingPolicy.NoGaussian, hogc.Hog.BlockNormalizationPolicy.L2Normalization) hog.computeCell( self.grayImg, 2, 3, blockTopLeft, smAngle, smMag, aHist, False) print "angle stats Maker", hogc.describeStatsMaker(smAngle) print "magnitude stats Maker", hogc.describeStatsMaker(smMag) pass
def processDir(dirname, label): smAngle = hogc.StatsMaker("angle") smMag = hogc.StatsMaker("magnitude") hogOutput = HogOutput(dirname, label) for root, dirs, files in os.walk(dirname): for f in files: (p, e) = os.path.splitext(f) if ((e.lower() == ".png") or (e.lower() == ".jpg") or (e.lower() == ".jpeg")): try: hogResult = processImage(root, f, smAngle, smMag) hogOutput.addResult(f, hogResult) print "no exception" except RuntimeError, h: pass hogOutput.serialize() print "angle stats Maker", hogc.describeStatsMaker(smAngle) print "magnitude stats Maker", hogc.describeStatsMaker(smMag) if __name__ == "__main__": print 'processing good targets' processDir("/Users/kgeorge/Dropbox/cars/tentative/build", label=1) print 'processing bad targets' processDir("/Users/kgeorge/Dropbox/cars/bad/build", label=0) print 'processing crossvalidation targets' processDir("/Users/kgeorge/Dropbox/cars/crossvalidate/build", label=-1)
def test_Describe(self): sm = hogc.StatsMaker("mystats") description = hogc.describeStatsMaker( sm ) print "description: " , description self.assertEqual(type(description), type(""))