- To receive data via UDP
If you send the string "FACEMOTION3D_OtherStreaming" from the PC side to port 49993 on the iOS side, Facemotion3d will return a reply to port 49993 with UDP at 60FPS.
-Python Example
from socket import *
DstIP = "192.168.1.7"
DstPort = 49993
DstAddr = (DstIP,DstPort)
udpClntSock = socket(AF_INET, SOCK_DGRAM)
data = "FACEMOTION3D_OtherStreaming"
data = data.encode('utf-8')
udpClntSock.sendto(data,DstAddr)
server = socket(AF_INET, SOCK_DGRAM)
server.bind(("", 49983))
server.settimeout(0.05)
while True:
try:
messages, address = server.recvfrom(8192)
print(messages.decode('utf-8'))
except:
pass
-The character string sent per frame is as follows.
eyeLookOutLeft&3|mouthPressRight&14|jawForward&8|browInnerUp&19|jawLeft&4|mouthShrugUpper&28|eyeSquintLeft&4|eyeWideLeft&0|mouthPucker&5|mouthLowerDownLeft&6|eyeBlinkLeft&29|mouthShrugLower&20|mouthSmileLeft&0|cheekSquintRight&9|eyeWideRight&0|mouthFunnel&4|mouthStretchRight&13|browDownRight&2|tongueOut&0|cheekSquintLeft&8|mouthStretchLeft&17|mouthUpperUpRight&10|noseSneerLeft&28|browOuterUpLeft&0|eyeLookInRight&15|mouthDimpleRight&7|mouthRollUpper&5|mouthLowerDownRight&6|mouthClose&6|mouthFrownLeft&3|eyeBlinkRight&29|mouthFrownRight&2|mouthUpperUpLeft&11|browDownLeft&1|eyeLookOutRight&0|cheekPuff&4|eyeLookInLeft&0|mouthDimpleLeft&8|eyeLookDownLeft&36|eyeSquintRight&4|mouthRollLower&7|eyeLookUpLeft&0|eyeLookUpRight&0|mouthSmileRight&0|jawRight&0|noseSneerRight&25|mouthPressLeft&13|jawOpen&4|browOuterUpRight&0|eyeLookDownRight&36|mouthLeft&1|mouthRight&0|FM_SAD&0|FM_ANGRY&0|FM_VF&0|FM_TH&0|FM_browUpRight&0|FM_browUpLeft&0|=head#-22.167973,0.45402408,-4.8798294,-0.039975993,-0.048437987,-0.45562273|rightEye#12.759762,5.527712,1.2244859|leftEye#12.862795,1.264116,0.28145725|
-The character strings sent per frame are as follows.
BlendShape Name&Parameters (0 ~ 100) | BlendShape Names-Parameters (0 ~ 100) | .... | = head # Euler angles X (degree), Euler angles Y, Euler angles Z, Position values X, Position values Y, Position values Z | rightEye #Euler angles X, Euler angles Y, Euler angles Z | leftEye #Euler angles X, Euler angles Y, Euler angles Z |
The parameter may contain negative values or the value may exceed 100.
Angle-related data is sent in degrees, not radians.
- To receive data via TCP / IP
If it is UDP, frames may be dropped, so there is also a method of receiving with TCP / IP.
If you send the character string "FACEMOTION3D_OtherStreaming|protocol=tcp" to port 49993 on the iOS side by UDP, the data will be sent to port 49986 on the PC side.
The character string to be sent is just the character string "___FACEMOTION3D" added to the character string sent at the time of UDP.
-sample
BlendShape Name&Parameter (0 ~ 100) | BlendShape Name-Parameter (0 ~ 100) | .... | = head # Euler angles X, Euler angles Y, Euler angles Z, moving values X, moving values Y, moving values Z | rightEye #Euler angles X, Euler angles Y, Euler angles Z | leftEye #Euler angles X, Euler angles Y, Euler angles Z | ___ Facemotion3d
When receiving from iOS to PC with TCP / IP, a character string with broken frames will be sent, so use "___FACEMOTION3D" at the end as a delimiter.
To stop sending TCP / IP, send the string "StopStreaming_FACEMOTION3D" to port 49993.
-Sample Python usage example received over TCP / IP
from socket import socket, AF_INET, SOCK_DGRAM, SOCK_STREAM
#UDP send
HOST = ''
PORT = 49993
ADDRESS = "192.168.1.7" #iOS address
s = socket(AF_INET, SOCK_DGRAM)
msg = "FACEMOTION3D_OtherStreaming|protocol=tcp"
s.sendto(msg.encode(), (ADDRESS, PORT))
s.close()
#create tcp server
with socket(AF_INET, SOCK_STREAM) as tcp_server:
tcp_server.bind(('192.168.1.5', 49986)) #192.168.1.5 is pc address
tcp_server.listen(1)
while True:
conn, addr = tcp_server.accept()
with conn:
while True:
data = conn.recv(10000)
print(data.decode('utf-8'))
-To receive recorded data in iOS
If you send the character string "OtherBakeRecordedAnimation_FACEMOTION3D" to port 49993 on the iOS side by UDP, the recorded data will be sent to port 49987 on the PC side by TCP / IP.
The string that is sent is in the format [".....", ".....", "....."]___FACEMOTION3D.
The [".....", ".....", "....."] part is in JSON format and stores the same character strings used in UDP and TCP/IP.
Data recorded at 60 FPS is always stored. (Even if the processing drops to 30FPS in iOS, it will be recorded at 60FPS)
-To receive recorded data and audio in iOS
If you send the character string "OtherBakeRecordedAnimationAndAudio_FACEMOTION3D" to port 49993 on the iOS side by UDP, the recorded data will be sent to port 49987 on the PC side by TCP / IP.
The string that is sent is in the format [".....", ".....", "....."]===(Binary converted to hexadecimal string)___FACEMOTION3D.
The [".....", ".....", "....."] part is in JSON format and stores the same character strings used in UDP and TCP/IP.
-Show User that you are currently baking
To display "Currently baking" in the iOS app, send the "To hide "processing the data", send "BakeFinishOther_FACEMOTION3D" to port 49993." to port 49993.
-To start recording within the iOS app
To start recording within the iOS app, send "FACEMOTION3D_StartRecording" to port 49993.
-To stop recording within the iOS app
To stop recording within the iOS app, send "FACEMOTION3D_StopRecording" to port 49993.
-To stop streaming within the iOS app
To stop streaming within the iOS app, send "StopStreaming_FACEMOTION3D" to port 49993.
-Run the Reset Button
Send the string "FACEMOTION3D_resetButton" to iOS port 49993.
-Adding Information
-Facemotion3d will not accept external commands for 0.02 seconds once it accepts commands.
-Currently, the only server that receives commands is the UDP server. With UDP, data may sometimes be missed, so sending data about three times will increase the probability of accurate communication.
3rd party developers do not necessarily have to use the Other license.
3rd party developers can use their favorite licenses such as Unity license and Blender license to choose the type of data to send.
Please understand that the price of each license may change in the future depending on the situation.