Image processing researcher needs help posing bones via script!

Hi everyone,

******** Background, you can skip this if you want ***************
I’m not a regular here, I’m not even an artist but I need your help. I’m a graduate student researching activity recognition which in short is recognizing actions of humans in video sequences (is this guy wielding a gun or talking on his cellphone) via computer.

My approach uses a database of a human in different poses to which I compare each frame of the video. If I can recognize the pose of the human in each video frame I can take that sequence of poses and classify it as an activity.

I need to pose a blender model (of a human) in thousands of predetermined poses where the angle of each bone is specifically known.

I can currently do this one pose at a time by highlighting a bone hitting ‘r’ ‘y’ (to rotate about y axis) and then entering the desired angle. This works as I want it to because the bone rotates about its end closest to the body (ex: the upper arm rotates about the shoulder). The problem is this is too time consuming to do thousands of poses.

I have written an extremely simple python script to test posing the model automatically which I will paste at the end of this post. It simply sets the quaternion (posebone.quat) at each keyframe. The problem is that it doesn’t rotates bones around what I perceive to be the x,y and z axes. For example, if I look at the model head on with the y axis coming directly out of the screen and run the script to rotate the upper right arm about the y axis the arm comes out of the screen a bit which it shouldn’t. Its as if the origin of that rotation has axes that aren’t parallel with the major axes in the scene.

I want the script to work the same as selecting the bone and hitting ‘r’ ‘y’ then ‘angle value’.

Can anyone help! This research is specifically for the department of defense so it is definitely meaningful. Thank you very much in advance.

I am using this model (thank you Andrew Kator & Jennifer Legaz) and here is my simple and incorrect script:


import math
from math import *
import Blender
from Blender import *

scn= Scene.GetCurrent()
arm_data = Blender.Armature.Get(“Armature male”)
arm_ob = Blender.Object.Get(“Armature male”)

Assign the pose animation

pose = arm_ob.getPose()

act = arm_ob.getAction()
if not act: # Add a pose action if we dont have one
act = Armature.NLA.NewAction()

pbones = pose.bones.values()

angle = -.57

#No rotation for first frame
frame = 1
pbones[39].quat[:] = 1.000,0.0000,0.0000,0.0000
pbones[39].insertKey(arm_ob, frame, Object.Pose.ROT)

#Rotate upper right arm 90 degrees about the y axis (or so I thought)
frame = 2
pbones[39].quat[:] = cos(angle/2),0.0000,sin(angle/2),0.0000
pbones[39].insertKey(arm_ob, frame, Object.Pose.ROT)