Exemplo n.º 1
0
        /// <summary>
        /// Add Event to the queue for callback
        /// </summary>
        /// <param name="e"></param>
        internal void AddEvent(NativeEvent e)
        {
            lock (eventLock) {
                if (nativeEvents == null)
                {
                    nativeEvents = new List <NativeEvent> ();
                }

                nativeEvents.Add(e);
                hasEvents = true;
            }
            ;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loops to listen for events received from native threads
        /// </summary>
        /// <returns></returns>
        private IEnumerator ListenForEvents()
        {
            nativeEvents = new List <NativeEvent>();
            while (enabled)
            {
                yield return(new WaitForEndOfFrame());

                if (hasEvents)
                {
                    //dispatch all events stored up!
                    lock (eventLock)
                    {
                        while (nativeEvents.Count > 0)
                        {
                            NativeEvent e = nativeEvents[0];
                            nativeEvents.RemoveAt(0);

                            for (int i = 0; i < Listeners.Length; i++)
                            {
                                ImageResultsListener listener = Listeners[i];
                                if (e.type == NativeEventType.ImageResults)
                                {
                                    if (listener != null)
                                    {
                                        listener.onImageResults((Dictionary <int, Face>)e.eventData);
                                    }
                                }
                                else if (e.type == NativeEventType.FaceFound)
                                {
                                    if (listener != null)
                                    {
                                        listener.onFaceFound(Time.realtimeSinceStartup, (int)e.eventData);
                                    }
                                }
                                else if (e.type == NativeEventType.FaceLost)
                                {
                                    if (listener != null)
                                    {
                                        listener.onFaceLost(Time.realtimeSinceStartup, (int)e.eventData);
                                    }
                                }
                            }
                        }


                        hasEvents = false;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add Event to the queue for callback
        /// </summary>
        /// <param name="e"></param>
        internal void AddEvent(NativeEvent e)
        {
            lock (eventLock) {

                if (nativeEvents == null)
                    nativeEvents = new List<NativeEvent> ();

                nativeEvents.Add (e);
                hasEvents = true;
            }
            ;
        }