WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 03-30-2010, 03:13 PM
Adam Adam is offline
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.

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.

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:	2334
Size:	98.1 KB
ID:	362  
Reply With Quote
Old 03-31-2010, 05: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
Old 04-02-2010, 01:47 AM
JvdBosch JvdBosch is offline
Join Date: Sep 2006
Posts: 36
Adam, I've sent you a private message.
Reply With Quote
Old 04-16-2010, 11:55 AM
Adam Adam is offline
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.



# 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
view = viz.MainView

# Load vrml and locate objects
pole = viz.add('pole.wrl')

# Set the socket parameters
host = "localhost"
port = 29129
buf = 1024
addr = (host,port)

# Create socket and bind to address

# Receive messages
while 1:
	data,addr = UDPSock.recvfrom(buf)
	if not data:
		print "Client has exited!"
		#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,"'"
# Close socket

def updateview():
	#update orientation
	euler = view.getEuler(viz.Head_ORI)
	euler[0] += HeadRot[0]
	euler[1] += HeadRot[1]
	euler[2] += HeadRot[2]
	print "\nEuler = ", euler
	#update position
	pos = view.getPosition(viz.Head_POS)
	pos[0] += HeadPos[0]
	pos[1] += HeadPos[1]
	pos[2] += HeadPos[2]
	print "\nPosition = ", pos

Reply With Quote

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
Creating a Vizard Sensor Plugin farshizzo Plug-in development 25 08-01-2019 12:24 AM
Video Stream plugin Brett Lindberg Plug-in development 7 08-18-2009 03:06 PM
Howto debug a custom plugin? reedev Plug-in development 3 04-23-2009 02:16 PM
problems with webcam plug-in v-clizzin Plug-in development 2 01-25-2008 03:06 PM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 11:01 AM

All times are GMT -7. The time now is 09:16 PM.

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