Exemplo n.º 1
0
def testVideoGeneration():
    samp = loadBVHFile(os.path.join(os.path.dirname(__file__),
        '../system/walk.bvh'), 0.01)
    spl = SplinedBodyModel(samp)

    positionEstimator = ContactTrackingKalmanFilter(
            SampledBodyModel.structureCopy(samp),
            initialTime = spl.startTime,
            initialPosition = spl.position(spl.startTime),
            initialVelocity = spl.velocity(spl.startTime))

    dt = 0.01
    sampleTimes = np.arange(spl.startTime + dt, spl.endTime, dt)

    for t in sampleTimes:
        data = [{'jointName' : p.name,
                'linearAcceleration' : p.acceleration(t)}
            for p in spl.joints]
        positionEstimator(data, t)

    outdir = tempfile.mkdtemp()
    filename = os.path.join(outdir, 'movie.avi')

    autoPositionCamera()
    renderSolenoidCoil(
        SolenoidMagneticField(200,20,0.05,0.2, AffineTransform()))
    createVideo(filename, [BodyModelRenderer(spl),
        VelocityVectorRenderer(spl.getPoint('ltoes_end')),
        ContactProbabilityRenderer(spl)],
        spl.startTime, spl.startTime + 1, 3, (320, 200))
    assert os.path.exists(filename)
    shutil.rmtree(outdir)