- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Someone please help, It is urgent!
Now that I have face animation based on emotion done, I have optimization issue.
The framerate drops severely when I turn on RSHandler.cs and SenseToolkitManager.cs. The most bottleneck seems to be happening from RSHandler.cs's Update() which I pasted below. (Also attached for RSHandler.cs code)
I am wondering if it(blue text) is correct way to get emotion data. It doesn't make sense to Init in every Update(), but when I take the sm.Init(); out, the emotion tracking doesn't work. If it is in the Update, it works but uses up 99% of the CPU.
Am I missing something?
Thanks!
Priya
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you attach your RSHandler.cs code? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
David Lu (Intel) wrote:
Could you attach your RSHandler.cs code? Thanks!
Here it is.
using UnityEngine; using System.Collections; using RSUnityToolkit; public class RSHandler : MonoBehaviour { public static bool oneHandDetected = false; public GameObject RSImage; InGameUIPanelManager UIPM; PXCMSenseManager sm; FaceTrackingRule _faceTrackingRule = null; BlendShapeTarget BSTarget_surprise; BlendShapeTarget BSTarget_negative; BlendShapeTarget BSTarget_positive; pxcmStatus emotionFrame; PXCMEmotion em; PXCMEmotion.EmotionData emotion_surprise; PXCMEmotion.EmotionData emotion_negative; PXCMEmotion.EmotionData emotion_positive; // Use this for initialization void Start () { UIPM = FindObjectOfType<InGameUIPanelManager>(); sm = PXCMSenseManager.CreateInstance(); sm.EnableEmotion(); RSImage.SetActive(false); BSTarget_surprise = FindObjectOfType<ann_blendshapeLinker>().blendShapeTargetScripts[0]; BSTarget_negative = FindObjectOfType<ann_blendshapeLinker>().blendShapeTargetScripts[1]; BSTarget_positive = FindObjectOfType<ann_blendshapeLinker>().blendShapeTargetScripts[3]; } // Update is called once per frame void Update () { if (Input.GetKeyDown(KeyCode.I)) { RSImage.SetActive(!RSImage.activeSelf); } sm.Init(); emotionFrame = sm.AcquireFrame(true); em = sm.QueryEmotion(); //print("em : " + em); em.QueryEmotionData(0, PXCMEmotion.Emotion.EMOTION_PRIMARY_SURPRISE, out emotion_surprise); em.QueryEmotionData(0, PXCMEmotion.Emotion.EMOTION_PRIMARY_SADNESS, out emotion_negative); em.QueryEmotionData(0, PXCMEmotion.Emotion.EMOTION_PRIMARY_JOY, out emotion_positive); BSTarget_surprise.weight = emotion_surprise.intensity * 1.25f; BSTarget_negative.weight = emotion_negative.intensity * 1f; BSTarget_positive.weight = emotion_positive.intensity * 1f; //if (BSTarget_surprise.weight > 1) BSTarget_surprise.weight = 1; //if (BSTarget_negative.weight > 1) BSTarget_negative.weight = 1; //if (BSTarget_positive.weight > 1) BSTarget_positive.weight = 1; } void OnOneHandDetected(EventTrigger e) { print("OnOneHandDetected called"); print("EventSource : " + e.EventSource); print("TriggerAttributeName : " + e.TriggerAttributeName); print("Source : " + e.Source); print("FriendlyName : " + e.FriendlyName); if (e.Source == "Hand Detected") { oneHandDetected = true; } else if (e.Source == "Hand Lost") { oneHandDetected = false; } } void OnTwoHandsDetected(EventTrigger e) { print("OnTwoHandsDetected called " + UIPM); if(UIPM.state != InGameUIPanelManager.UIState.FAILED) UIPM.RestartStage(); /* else if (e.Source == "Hand Lost") { twoHandsDetected = false; }*/ } bool popupLock = false; void OnFaceLost(EventTrigger e) { if (popupLock == true) return; print("Come closer"); GO_RSNotice.SetActive(true); popupLock = true; } void OnFaceDetected(EventTrigger e) { if (popupLock == false) return; print("Hide"); GO_RSNotice.SetActive(false); popupLock = false; } public GameObject GO_RSNotice; }

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page