GithubHelp home page GithubHelp logo

pylivelinkface's Introduction

PyLiveLinkFace

PyLiveLinkFace enables you to receive data sent from Epics LiveLinkFace App and send your own facial data to the Unreal Engine using the LiveLink Plugin via python. It's designed that you don't need to change anything inside the Unreal Engine, if you can receive facial Data from the IPhone app, this libary will also work out of the box for you. Tested with Unreal Engine 4.27.

Prerequisites

To setup the LiveLink plugin and system in Unreal, see the following tutorial: https://docs.unrealengine.com/4.27/en-US/AnimatingObjects/SkeletalMeshAnimation/FacialRecordingiPhone/

Requirements

PyLiveLinkFace needs the following python libraries:

  • numpy
  • timecode

Install

To install it, clone the git repo and install it with the setup.py file:

python setup.py install

Usage

The default LiveLinkFace App works with UDP sockets on the Port 11111. You need to open an UDP-Socket for sending or receiving the data. For example files, see the examples folder

Sending data

To send facial data to the UnrealEngine, create a new PyLiveLinkFace object, connect an UDP socket and set your desired values. Finally pack all the data via the 'encode()' into bytes and send it over the socket.

from pylivelinkface import PyLiveLinkFace, FaceBlendShape

py_face = PyLiveLinkFace()

UDP_IP = "127.0.0.1"
UDP_PORT = 11111

# connect to the udp socket of the running Unreal Project
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 
s.connect((UDP_IP, UDP_PORT))

# set the head rotation to random values             
py_face.set_blendshape(FaceBlendShape.HeadPitch, random.uniform(-1, 1))
py_face.set_blendshape(FaceBlendShape.HeadRoll,random.uniform(-1, 1))
py_face.set_blendshape(FaceBlendShape.HeadYaw, random.uniform(-1, 1))

# encode the PyLiveLinkFace data to bytes and send them
s.sendall(py_face.encode())
s.close()

Receiving data

To receive facial data from an IPhone LiveLinkFace app or another PyLiveLinkFace instance, open an UDP socket and set your desired values. Finally unpack all the data via the 'deencode()' into a PyLiveLinkFace object.

from pylivelinkface import PyLiveLinkFace, FaceBlendShape

UDP_PORT = 11111

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# open a UDP socket on all available interfaces with the given port
s.bind(("", UDP_PORT)) 
while True: 
    data, addr = s.recvfrom(1024) 
    # decode the bytes data into a PyLiveLinkFace object
    success, live_link_face = PyLiveLinkFace.decode(data)
    if success:
        # get the blendshape value for the HeadPitch and print it
        pitch = live_link_face.get_blendshape(FaceBlendShape.HeadPitch)
        print (live_link_face.name, pitch)       
        pass

s.close()

pylivelinkface's People

Contributors

jimwest avatar rohitdavas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.