University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

Using Smartbody with Kinect | General SmartBody Discussion | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Using Smartbody with Kinect
June 25, 2014
5:36 pm
Avatar
New Member
Members
Forum Posts: 1
Member Since:
June 25, 2014
sp_UserOfflineSmall Offline

Hi I have a question regarding using smartbody with kinect. 

I have successfully used smartbody to render a scene where one character (either Brad or Rachel) mimics my motions that Kinect captures. However, I run into a problem when I try to use kinect to capture two individuals and recreate the scene in smartbody where, for example, Brad would mimic my motions and Rachel would mimic my friend's motions. Do you have any advice on how to approach and fix this problem? Thank you in advance! 

 

Dennis 

June 25, 2014
11:23 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Each character has an attribute called 'receiverName' which determines the name of the originating data (by default, it's 'kinect1').

So if you send data from a different Kinect source (say, kinect2 instead of kinect1) set the attribute on the character to listen on to that channel:

 

scene.getCharacter("ChrRachel").setStringAttribute("receiverName", "kinect2")

This gives you the flexibility of mapping one-to-one or one-to-many from source to target.

 

Ari

July 24, 2014
1:06 am
Avatar
Member
Members
Forum Posts: 5
Member Since:
July 23, 2014
sp_UserOfflineSmall Offline

Hi,

I am also using Kinect to capture my subject's motions. However, I have run into a bit of a problem. How can I determine the initial positions of my subject from the retargeted quaternion data (i got the data from "mcontrol-callbacks.cpp")?. Also, if the code exists, can you please tell me where I can find the code that converts the retargeted quaternion joints to position vectors or Euler angles? If not, how can I convert the quaternion data into position vectors? Thanks so much for your help! 

July 27, 2014
10:58 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Can you explain again what you are looking for?

Right now, the Kinect tracking data can override the joint information, but for characters that have pre- or post- rotations on their joints, this can be a problem.

 

There is a controller called the MeCtDataReceiver in the file controllers/me_ct_data_receiver.h and .cpp. You can override any of the values of the joints/channels by setting these values. 

 

Ari

July 30, 2014
6:05 pm
Avatar
Member
Members
Forum Posts: 5
Member Since:
July 23, 2014
sp_UserOfflineSmall Offline

Okay cool thanks, Ari! 

August 5, 2014
10:40 pm
Avatar
Member
Members
Forum Posts: 5
Member Since:
July 23, 2014
sp_UserOfflineSmall Offline

Sorry to ask again, but I'm still having some difficulties. Can you elaborate more on how I can retrieve the retargeted position vectors for every joint at every frame? For example, I am able to retrieve all of the retargeted quaternion values for every joint at every frame in the "mcontrol_callbacks.cpp" in the "mcu_joint_datareceiver_func" function from the "retargetQuats" vector. Here is the code I used for the retargeted quaternions. 

 

if(fob.is_open()){
for (std::vector<SmartBody::SBCharacter*>::iterator iter = controlledCharacters.begin();
iter != controlledCharacters.end();
iter++)
{
SmartBody::SBCharacter* character = (*iter);
scene->getKinectProcessor()->processRetargetRotation(character->getSkeleton()->getName(),quats, retargetQuats);
if (retargetQuats.size() >= 20)
{
for (int i = 0; i < 20; i++)
{
fob << retargetQuats[i].w << " ";
fob << retargetQuats[i].x << " ";
fob << retargetQuats[i].y << " ";
fob << retargetQuats[i].z << endl;

if (retargetQuats[i].w != 0)
{
const std::string& mappedJointName = scene->getKinectProcessor()->getSBJointName(i);
if (mappedJointName != "")
character->datareceiver_ct->setLocalRotation(mappedJointName, retargetQuats[i]);
}
}
}
}
} fob.close();

 

Thanks so much again! 

August 7, 2014
1:11 am
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

You can call getPosition() on the joint to get that data:

 

SrVec pos = character->getSkeleton()->getJointByName("whatever")->getPosition();

 

or am I not understanding the problem you are having?

August 7, 2014
9:48 pm
Avatar
Member
Members
Forum Posts: 5
Member Since:
July 23, 2014
sp_UserOfflineSmall Offline

Thanks, Ari. I tried calling getPosition(), but I'm only able to retrieve the position values for the "base" joint. However, I want to obtain the position values of all 20 joints captured by the kinect at every frame. Also, it would be especially helpful if I could obtain the retargeted position values of these joints. 

August 13, 2014
5:38 pm
Avatar
Admin
Forum Posts: 52
Member Since:
August 8, 2012
sp_UserOfflineSmall Offline

To get the global position from a skeleton, you can use getMatrixGlobal :

SrVec globalPos= character->getSkeleton()->getJointByName("whatever")->getMatrixGlobal().get_translation();

 

Depending on whether the quaternions in the skeleton have been changed, sometimes the global matrices need to be updated first before retriving the data. It can be done by calling :

character->getSkeleton()->update_global_matrices();

 

Andrew

August 13, 2014
11:16 pm
Avatar
Member
Members
Forum Posts: 5
Member Since:
July 23, 2014
sp_UserOfflineSmall Offline

Thanks, Andrew. I have the position values of all the joints now, but are these joint values retargeted? 

August 13, 2014
11:22 pm
Avatar
Admin
Forum Posts: 52
Member Since:
August 8, 2012
sp_UserOfflineSmall Offline

Yes, if you are getting the joints from the character, those global positions are derived from the character's skeleton based on retargeted quaternions. It would be different from the positions in the original Kinect data, but would be the correct one for the character.

Andrew