#1
|
|||
|
|||
Plugin For Headtracking with webcam via FaceAPI
I would like to be able to be able to read the head position (x,y,z) and rotation values (y,p,r) from a webcam using FaceAPI and apply that data to my viewpoint in vizard and I am at a loss as to how to do this.
This video illustrates what I would like to be able to do. http://www.youtube.com/watch?v=uA8ZXPS6onk I have found some google code projects that provide this position and orientation data via a socket but I have never worked with sockets before. http://code.google.com/p/6dofstreamer/ I've attached an image of what the socket outputs. How would I go about either accessing this data from the socket to update the viewpoint, or develop my own faceapi plugin to do this automatically. Many thanks in advance to those more knowledgeable than myself. |
#2
|
|||
|
|||
Do you have more information about the FaceAPI socket protocol? Either way, you should be able to use the built-in Python socket module to receive data over the network.
|
#3
|
|||
|
|||
Adam, I've sent you a private message.
|
#4
|
|||
|
|||
I am trying to work that FACEAPI integration for headtracking via streaming position and orientation data from a socket and can't quite get it to work.
Could you look over my code and let me know what I may be doing wrong? The socket works and I can access the data, but I can't seem to get it to apply to my viewpoint. Thanks, -Adam Code:
# Import Modules import viz from socket import * import string import math # Set Global Variables global host global port global buf global addr global HeadPos global HeadRot global pos global euler global view # Run Vizard in Fullscreen viz.go() view = viz.MainView viz.mouse(viz.OFF) viz.mouse.setVisible(False) # Load vrml and locate objects viz.add('tut_ground.wrl') pole = viz.add('pole.wrl') pole.setPosition(0,0,4) # Set the socket parameters host = "localhost" port = 29129 buf = 1024 addr = (host,port) # Create socket and bind to address UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(addr) # Receive messages while 1: data,addr = UDPSock.recvfrom(buf) if not data: print "Client has exited!" break else: #print "\nReceived message '", data,"'" cp = str(data).split(' ') headposx = cp[0] headposx = float(headposx) headposy = cp[1] headposy = float(headposy) headposz = cp[2] headposz = float(headposz) headrotx = cp[3] headrotx = float(headrotx) headroty = cp[4] headroty = float(headroty) headrotz = cp[5] headrotz = float(headrotz) HeadPos = [headposx , headposy , headposz] print "\nHeadPos = ", HeadPos,"'" HeadRot = [headrotx , headroty , headrotz] print "\nHeadRot = ", HeadRot,"'" updateview() # Close socket UDPSock.close() def updateview(): viz.reset(viz.HEAD_ORI|viz.BODY_ORI|viz.HEAD_POS) #update orientation euler = view.getEuler(viz.Head_ORI) euler[0] += HeadRot[0] euler[1] += HeadRot[1] euler[2] += HeadRot[2] print "\nEuler = ", euler view.setEuler(euler,viz.Head_ORI) #update position pos = view.getPosition(viz.Head_POS) pos[0] += HeadPos[0] pos[1] += HeadPos[1] pos[2] += HeadPos[2] print "\nPosition = ", pos view.setPosition(pos[0],pos[1],pos[2]) vizact.ontimer(0,updateview) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating a Vizard Sensor Plugin | farshizzo | Plug-in development | 25 | 08-01-2019 01:24 AM |
Video Stream plugin | Brett Lindberg | Plug-in development | 7 | 08-18-2009 04:06 PM |
Howto debug a custom plugin? | reedev | Plug-in development | 3 | 04-23-2009 03:16 PM |
problems with webcam plug-in | v-clizzin | Plug-in development | 2 | 01-25-2008 04:06 PM |
Could not find plugin to load objects... | halley | Vizard | 1 | 05-30-2006 12:01 PM |