WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Vizard/Kinect Gesture Reader Code (

cmeans 04-05-2015 08:31 PM

Vizard/Kinect Gesture Reader Code
3 Attachment(s)
I'm a beginner to Vizard. I'm trying to write code that will recognize when the user has their right arm in a right angle. I'm using vizmat.AngleBetweenVectors() to try and get the angle between the right shoulder and the right hand. To my mind, if you hold your arm at a right angle, it will read ~90 degrees.
I'm encountering two problems:
1) As I move my arm back and forth, holding it at a right angle, the degrees change.
2) It's not reading 90 degrees.

Here is my code:

def RightArmAngle():
    RShoulder = vrpn.addTracker('Tracker0@localhost',RIGHTSHOULDER)
    RSpos = RShoulder.getPosition()
    RHand  =vrpn.addTracker('Tracker0@localhost',RIGHTHAND)
    RHpos = RHand.getPosition()
    RHvec = viz.Vector(RHand.getPosition(),normalize = True)
    RSvec = viz.Vector(RShoulder.getPosition(),normalize = True)
    RAVector=vizmat.AngleBetweenVector(RSvec,RHvec)#RAVector and RAAngle return the same value
    RAAngle = vizmat.AngleBetweenVector(RSpos,RHvec)
    print("r elbow:",RHvec)
    print("r shoulder:",RSvec)
    print("position Angle:", RAAngle, "vs RAVector",RAVector)

Here are some diagrams and my outputs:

Attachment 694
Raised Arm, Turned to Side. Vector Returned: ~31
Attachment 692
Right-Angled Arm, Held in Front, Vector Returned: ~23
Attachment 693
Right-Angled Arm, Held to Side, Vector Returned: ~16

I'm confused as to how thought this would be a simple way. Should I try to make a triangle instead? Or should I just be returning one Euler value and finding the angle from that?

Jeff 04-09-2015 07:01 PM

You would need to track three points (hand, elbow, and shoulder) in order to get two vectors and then calculate the angle between those.

All times are GMT -7. The time now is 04:42 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC