Iterating vertex of every frame in Blender I built a human model in Blender first and then loaded a bvh file into ths model. Now I have 200 frames which show a running scene in Blender. I can iterate every frame. I want to get all the vertex coordinates from the 200 frames. I did it with the following code segment, but, want is to get the vertex coordinates of the original human model.

Can someone help me?    

for frame in range(scene.frame_start, scene.frame_end):
    scene.frame_set(frame)
    scene.update()
    bpy.ops.object.mode_set(mode='OBJECT',toggle = True)
    obj = bpy.context.active_object
    loops = len(obj.data.loops)
    verts = len(obj.data.vertices)
    mat = bpy.context.active_object.matrix_world
    vertex = [mat * verts.co for verts in obj.data.vertices]
    the_file = "pointCloud_f" + str('{:03d}'.format(scene.frame_current)) + ".ply"
    print("loading "+the_path + the_file+'\n')
    with open(the_path + the_file, 'w') as wFile:
        wFile.write(headerOfPLY)
        count = 0
        for vcol in obj.data.vertex_colors:
            colors={}
            for i in range(loops):
                v=obj.data.loops[i].vertex_index
                c = vcol.data[i].color
                colors[v]=c
        for j in range(len(vertex)):
            wFile.write('%f %f %f %d %d %d \n' %(vertex[j].x,vertex[j].y,vertex[j].z,int(colors[j].r*255),int(colors[j].g*255),int(colors[j].b*255)))
    print("writing completed!")
    wFile.close()
return {'FINISHED'}


Shape of frame 1 of the scene


Shape of original human model
The mesh data always contains the original locations of vertices. Not sure if it is the only way but you can use object.to_mesh to get a copy of the mesh data that is deformed.

import bpy

obj = bpy.context.active_object
scn = bpy.context.scene

mod_mesh = obj.to_mesh(scn, True, 'RENDER')

for v in mod_mesh.vertices:
    print(v.co)


Note that this creates a new mesh object, so as you are iterating over each frame you will want to remove each copy as you go with -

bpy.data.meshes.remove(mod_mesh)