WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-17-2017, 11:24 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
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,
Reply With Quote
  #2  
Old 04-17-2017, 11:33 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
also when the euler of the mainview changed, the white dot should also be changed.

looking for help,

thanks,
Reply With Quote
  #3  
Old 04-18-2017, 04:24 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #4  
Old 04-18-2017, 08:36 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
Quote:
Originally Posted by Jeff View Post
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.
Reply With Quote
  #5  
Old 04-18-2017, 10:52 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
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,
Reply With Quote
  #6  
Old 04-19-2017, 09:39 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #7  
Old 04-20-2017, 01:26 PM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
Quote:
Originally Posted by Jeff View Post
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
Reply With Quote
  #8  
Old 04-20-2017, 02:28 PM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
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.
Reply With Quote
  #9  
Old 04-24-2017, 08:28 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
any idea Jeff?
Reply With Quote
  #10  
Old 04-24-2017, 09:55 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.
Reply With Quote
  #11  
Old 04-25-2017, 07:50 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
Quote:
Originally Posted by Jeff View Post
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,
Reply With Quote
  #12  
Old 04-25-2017, 12:09 PM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
Quote:
Originally Posted by Jeff View Post
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.
Reply With Quote
  #13  
Old 04-26-2017, 09:32 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.
Attached Files
File Type: zip vizconnect_example.zip (2.7 KB, 924 views)
Reply With Quote
  #14  
Old 04-27-2017, 09:35 AM
haohaoxuexi1 haohaoxuexi1 is offline
Member
 
Join Date: Sep 2015
Posts: 81
Quote:
Originally Posted by Jeff View Post
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.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Local coordinate and global coordinate haohaoxuexi1 Vizard 2 07-24-2016 07:21 PM
Problems with using WIRKS without the Kinect in a mirror setting Jennifer Vizard 0 06-03-2013 03:17 PM
Kinect auto selection of skeleton victorqx Vizard 0 05-29-2012 08:30 AM
Mouse 2D coordinate to viz world 3D coordinate james007 Vizard 1 10-08-2009 12:11 PM
creating multiple coordinate systems and making them visible jalvarez Vizard 1 02-27-2009 12:36 PM


All times are GMT -7. The time now is 09:38 AM.


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