WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   about Kinect coordinate transformation (https://forum.worldviz.com/showthread.php?t=5996)

haohaoxuexi1 04-17-2017 11:24 AM

about Kinect coordinate transformation
 
Code:

import viz
import vizshape

viz.go()
grid = vizshape.addGrid()

"""
Kinect Tracker object ID's
These are not actually being using in the script but are to
help anyone who wants to get access to a specific bodypart.
For example to just get a handle to tracking data for the head use:
myHead = vrpn.addTracker( 'Tracker0@localhost', HEAD).
"""
HEAD = 0
NECK = 1
TORSO = 2
WAIST = 3
LEFTCOLLOR = 4
LEFTSHOULDER = 5
LEFTELBOW = 6
LEFTWRIST = 7
LEFTHAND = 8
LEFTFINGERTIP = 9
RIGHTCOLLAR = 10
RIGHTSHOULDER = 11
RIGHTELBOW = 12
RIGHTWRIST = 13
RIGHTHAND = 14
RIGHTFINGERTIP = 15
LEFTHIP = 16
LEFTKNEE = 17
LEFTANGLE = 18
LEFTFOOT = 19
RIGHTHIP = 20
RIGHTKNEE = 21
RIGHTANKLE = 22
RIGHTFOOT = 23

#store trackers, links, and vizshape objects
trackers = []
links = []
shapes = []

#start vrpn
vrpn = viz.addExtension('vrpn7.dle')

#now add all trackers and link a shape to it
for i in range(0, 24):
    t = vrpn.addTracker( 'Tracker0@localhost',i )
    s = vizshape.addSphere(radius=.1)
    l = viz.link(t,s)
    trackers.append(t)
    links.append(l)
    shapes.append(s)

The code above can be used to track human skeletal.

Is there a way to convert the tracking white dots always shown in front of the mainview (maybe 1 or 2 meter distance from the mainview), when the mainview changed, the white dot will also follow the mainview to change to another position.

It should be something regarding coordinate transformation.

Thanks,

haohaoxuexi1 04-17-2017 11:33 AM

also when the euler of the mainview changed, the white dot should also be changed.

looking for help,

thanks,

Jeff 04-18-2017 04:24 AM

Try the following:

Code:

#now add all trackers and link a shape to it
for i in range(0, 24):
        t = vrpn.addTracker( 'Tracker0@localhost',i )
        s = vizshape.addSphere(radius=.1)
        l = viz.link(t,s)
        #keep the sphere in the reference frame of the view
        l.postMultLinkable(viz.MainView)
        #uncomment the following line to move the sphere forward
        #l.preTrans([0,0,3])
        trackers.append(t)
        links.append(l)
        shapes.append(s)


haohaoxuexi1 04-18-2017 08:36 AM

Quote:

Originally Posted by Jeff (Post 19353)
Try the following:

Code:

#now add all trackers and link a shape to it
for i in range(0, 24):
        t = vrpn.addTracker( 'Tracker0@localhost',i )
        s = vizshape.addSphere(radius=.1)
        l = viz.link(t,s)
        #keep the sphere in the reference frame of the view
        l.postMultLinkable(viz.MainView)
        #uncomment the following line to move the sphere forward
        #l.preTrans([0,0,3])
        trackers.append(t)
        links.append(l)
        shapes.append(s)


the dots are shown in front of the screen, but it displays like scatter and it is not like human skeletal joints.

haohaoxuexi1 04-18-2017 10:52 AM

based on my own understanding, the question is how to shift the coordinate of Kinect sensor. The kinect sensor captures movement of skeletal joints. and when the mainview moved, the tracking coordinate still stay in the global coordinate of Vizard software itself.

is there a way to change the origin of Kinect sensor instantly for example (1 or 2 meters in front of the mainview position). when the mainview moved, it will move along with mainview, in that way, the tracking skeletal joints can be shown in front of the mainview all the time.

Thanks,

Jeff 04-19-2017 09:39 PM

Does the following work?

Code:

for i in range(0, 24):
        t = vrpn.addTracker( 'Tracker0@localhost',i )
        s = vizshape.addSphere(radius=.1)
        s.setReferenceFrame(viz.RF_VIEW)
        l = viz.link(t,s)
        #change z value to move sphere closer/farther from view
        l.postTrans([0,0,2])
        trackers.append(t)
        links.append(l)
        shapes.append(s)


haohaoxuexi1 04-20-2017 01:26 PM

Quote:

Originally Posted by Jeff (Post 19357)
Does the following work?

Code:

for i in range(0, 24):
        t = vrpn.addTracker( 'Tracker0@localhost',i )
        s = vizshape.addSphere(radius=.1)
        s.setReferenceFrame(viz.RF_VIEW)
        l = viz.link(t,s)
        #change z value to move sphere closer/farther from view
        l.postTrans([0,0,2])
        trackers.append(t)
        links.append(l)
        shapes.append(s)


The skeletal appears in front of the mainview but I wish to obtain the position of the skeletal joints in global coordinate.

When I apply "pos_s = s.getPosition() print pos_s" to the code, it seems the position is still their local position, is there a method using coordinate transformation to achieve keeping skeletal appearing in front of the mainview.

waiting for the reply

haohaoxuexi1 04-20-2017 02:28 PM

I made a simple code to explain my problem
Code:

import viz
import vizshape

viz.go()
grid = vizshape.addGrid()
viz.MainView.setPosition(0,1,-5)

#now the sphere should be around 7 meters away from the main
s = vizshape.addSphere(radius=0.1)
s.setPosition([0,0,2])

I added a sphere to the scene and the scene is around 7 meters in front of the mainview.

I want to achieve that when the position of mainview moved, the sphere can move to the relative position (which is around 7 meters in front of the mainview) (defining a function to achieve it). And I also need to know the current global position of the sphere.

Hopefully, you can understand what I want to achieve. I think it is regarding coordinate transformation.

haohaoxuexi1 04-24-2017 08:28 AM

any idea Jeff?

Jeff 04-24-2017 09:55 PM

Does everything look correct with the last code I posted? If so and you need the global transform of the sphere you could try calculating it based on the view transform and the sphere's relative offset.

What are you using to control the movement of the view? When the skeleton moves is it relative to the view or does the view follow? There maybe another way of setting this up through vizconnect.

haohaoxuexi1 04-25-2017 07:50 AM

Quote:

Originally Posted by Jeff (Post 19369)
Does everything look correct with the last code I posted? If so and you need the global transform of the sphere you could try calculating it based on the view transform and the sphere's relative offset.

What are you using to control the movement of the view? When the skeleton moves is it relative to the view or does the view follow? There maybe another way of setting this up through vizconnect.

It works for the last code you give to me. But when I apply print position, it will still give the position which is the same as the skeletal stay in global coordinate(0,0,0). The position is just the relative position.

Do you know how to calculate the global position of the skeletal joints?

Thanks,

haohaoxuexi1 04-25-2017 12:09 PM

Quote:

Originally Posted by Jeff (Post 19369)
Does everything look correct with the last code I posted? If so and you need the global transform of the sphere you could try calculating it based on the view transform and the sphere's relative offset.

What are you using to control the movement of the view? When the skeleton moves is it relative to the view or does the view follow? There maybe another way of setting this up through vizconnect.

The skeletal joints move along with view, the skeletal joints are in the center of the view.

Jeff 04-26-2017 09:32 PM

1 Attachment(s)
You could try setting this up through vizconnect. The attached script shows a simple desktop example. The keyboard tracker is a substitute for a kinect tracker. Both the beachball, which is parented to the keytracker, and the view node follow the transport. The beachball's position is printed out in global coordinates.

haohaoxuexi1 04-27-2017 09:35 AM

Quote:

Originally Posted by Jeff (Post 19382)
You could try setting this up through vizconnect. The attached script shows a simple desktop example. The keyboard tracker is a substitute for a kinect tracker. Both the beachball, which is parented to the keytracker, and the view node follow the transport. The beachball's position is printed out in global coordinates.

thanks a lot

I will try to figure it out.


All times are GMT -7. The time now is 08:58 PM.

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