WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 03-30-2010, 04:13 PM
Adam Adam is offline
Member
 
Join Date: Apr 2005
Posts: 13
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.
Attached Thumbnails
Click image for larger version

Name:	Socket.jpg
Views:	2743
Size:	98.1 KB
ID:	362  
Reply With Quote
  #2  
Old 03-31-2010, 06:54 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #3  
Old 04-02-2010, 02:47 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
Adam, I've sent you a private message.
Reply With Quote
  #4  
Old 04-16-2010, 12:55 PM
Adam Adam is offline
Member
 
Join Date: Apr 2005
Posts: 13
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)
Reply With Quote
Reply


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
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


All times are GMT -7. The time now is 03:38 PM.


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