java.lang.Object | |
↳ | com.nuwarobotics.service.facecontrol.UnityFaceManager |
Nuwa Face is a Activity which constructed with the Unity engine.
The face control mechanism receives instructions via android service AIDL. It will init and binding service when constructing the new NuwaRobotAPI object, use UnityFaceManager object to call face control instruction.
>
// get control object mRobotAPI.initFaceControl(mContext, mContext.getClass().getName(), FaceControlConnect); UnityFaceManager mFaceManager = mRobotAPI.UnityFaceManager.getInstance(); ... mFaceManager.showUnity(); mFaceManager.mouthOn(200); ... //after no more use(ex:activity suspend), release object mFaceManager.release();Declare ServiceConnection of Face Service
ServiceConnectListener FaceControlConnect = new ServiceConnectListener() { @Override public void onConnectChanged(ComponentName componentName, boolean b) { Log.d(TAG, "faceService onbind : " + b); } };Play a facial expression (json file which pre-define by nuwa)
String json = "J2_Hug"; IonCompleteListener.Stub mListener = new IonCompleteListener.Stub() { @Override public void onComplete(String s) throws RemoteException { Log.d("FaceControl", "onMotionComplete:" + s ); } }; mFaceManager.playMotion(json,mListener);To receive callback of Face Touch
mController.registerCallback(new UnityFaceCallback()); class UnityFaceCallback extends UnityFaceCallback { @Override public void on_touch_left_eye() { Log.d("FaceControl", "on_touch_left_eye()"); } @Override public void on_touch_right_eye() { Log.d("FaceControl", "on_touch_right_eye()"); } @Override public void on_touch_nose() { Log.d("FaceControl", "on_touch_nose()"); } @Override public void on_touch_mouth() { Log.d("FaceControl", "on_touch_mouth()"); } @Override public void on_touch_head() { Log.d("FaceControl", "on_touch_head()"); } @Override public void on_touch_left_edge() { Log.d("FaceControl", "on_touch_left_edge()"); } @Override public void on_touch_right_edge() { Log.d("FaceControl", "on_touch_right_edge()"); } @Override public void on_touch_bottom() { Log.d("FaceControl", "on_touch_bottom()"); } }
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
enum | UnityFaceManager.MouthOnType |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | FACE_CONTROL_ACTION_V1 | ||||||||||
int | FACE_CONTROL_VERSION_NONE | ROBOT VERSION NOT SUPPORT FACE CONTROL API | |||||||||
int | FACE_CONTROL_VERSION_V1 | ROBOT VERSION SUPPORT FACE CONTROL API V1 | |||||||||
int | FACE_CONTROL_VERSION_V2 | ROBOT VERSION SUPPORT FACE CONTROL API V2 |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static int |
getDeviceSupport(Context context)
Get Does Robot Version support Face Control API
| ||||||||||
static UnityFaceManager | getInstance() | ||||||||||
void |
hideFace()
hide face from UI foreground
| ||||||||||
boolean |
isServiceConnected()
check is app aidl still connected to nuwa face
| ||||||||||
void |
mouthEmotionOn(long moveSpeed, int EmotionType)
NOTICE : NOT SUPPORT YET, Under planning.
| ||||||||||
void |
mouthOff()
close face mouth
| ||||||||||
void |
mouthOn(long speed)
Start face mouth move.
| ||||||||||
boolean |
playMotion(String json, IonCompleteListener listener)
play unity face motion method
| ||||||||||
boolean |
registerCallback(UnityFaceCallback callback)
register FaceControl listener
| ||||||||||
void |
release()
release Face Control module.
| ||||||||||
void |
showFace()
show face (bring to foreground UI)
| ||||||||||
boolean |
unregisterCallback(UnityFaceCallback callback)
unregister FaceControl listener
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
ROBOT VERSION NOT SUPPORT FACE CONTROL API
ROBOT VERSION SUPPORT FACE CONTROL API V1
ROBOT VERSION SUPPORT FACE CONTROL API V2
Get Does Robot Version support Face Control API
if(mFaceManager.getDeviceSupport(context) != 0){ //support Face Control }else{ //not support Face control }
hide face from UI foreground
check is app aidl still connected to nuwa face
NOTICE : NOT SUPPORT YET, Under planning.
Move mouth with a emotion index
moveSpeed | speed of mouth move |
---|---|
EmotionType | index of emotion |
close face mouth
Start face mouth move. (usually use on speaking)
speed | Mouth animation speed by millisecond (lower value make faster mouth move) |
---|
play unity face motion method
json | unity face motion key |
---|---|
listener | callback for motion complete |
register FaceControl listener
callback | callback class |
---|
release Face Control module.
show face (bring to foreground UI)
unregister FaceControl listener
callback | callback |
---|