public override IEnumerator Initialize(Detector detector, int discrete)
        {
            AndroidNativePlatform.detector = detector;

            // assemble the destination path where the data files will go
            affdexDataDir = Path.Combine(Application.persistentDataPath, "affdex-data");

            // Copy data files out of StreamingAssets to the destination path (if necessary)
            // Wait for it to complete before continuing
            yield return(StartCoroutine(CopyAssets()));

            // native call
            nativeHandle = affdexInitialize(discrete, affdexDataDir);

            // allocate and pin memory for the listeners
            FaceResults  faceFound    = new FaceResults(this.onFaceFound);
            FaceResults  faceLost     = new FaceResults(this.onFaceLost);
            ImageResults imageResults = new ImageResults(this.onImageResults);

            h1 = GCHandle.Alloc(faceFound, GCHandleType.Pinned);
            h2 = GCHandle.Alloc(faceLost, GCHandleType.Pinned);
            h3 = GCHandle.Alloc(imageResults, GCHandleType.Pinned);

            // native call
            affdexRegisterListeners(nativeHandle, imageResults, faceFound, faceLost);
        }
        public override IEnumerator Initialize(Detector detector, int discrete)
        {
            WindowsNativePlatform.detector = detector;

            //load our lib!
            string affdexDataPath = Application.streamingAssetsPath + "/affdex-data-3";

            Debug.Log("Hi! It's Greg.");
            affdexDataPath = affdexDataPath.Replace('/', '\\');
            Debug.Log("affdexDataPath is...");
            Debug.Log(affdexDataPath);
            nativeHandle = affdexInitialize(discrete, affdexDataPath);

            FaceResults  faceFound    = new FaceResults(this.onFaceFound);
            FaceResults  faceLost     = new FaceResults(this.onFaceLost);
            ImageResults imageResults = new ImageResults(this.onImageResults);

            h1 = GCHandle.Alloc(faceFound, GCHandleType.Pinned);
            h2 = GCHandle.Alloc(faceLost, GCHandleType.Pinned);
            h3 = GCHandle.Alloc(imageResults, GCHandleType.Pinned);

            int status = affdexRegisterListeners(nativeHandle, imageResults, faceFound, faceLost);

            Debug.Log("Registered listeners: " + status);
            yield break;
        }
        public override IEnumerator Initialize(Detector detector, int discrete)
        {
            OSXNativePlatform.detector = detector;
            String adP            = Application.streamingAssetsPath;
            String affdexDataPath = Path.Combine(adP, "affdex-data-osx");
            int    status         = 0;

            Debug.Log("Initializing detector");
            try
            {
                nativeHandle = affdexInitialize(discrete, affdexDataPath);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            Debug.Log("Initialized detector: " + status);

            FaceResults  faceFound    = new FaceResults(this.onFaceFound);
            FaceResults  faceLost     = new FaceResults(this.onFaceLost);
            ImageResults imageResults = new ImageResults(this.onImageResults);

            h1 = GCHandle.Alloc(faceFound, GCHandleType.Pinned);
            h2 = GCHandle.Alloc(faceLost, GCHandleType.Pinned);
            h3 = GCHandle.Alloc(imageResults, GCHandleType.Pinned);

            status = affdexRegisterListeners(nativeHandle, imageResults, faceFound, faceLost);
            Debug.Log("Registered listeners: " + status);
            yield break;
        }
        public void Initialize(Detector detector, int discrete)
        {
            WindowsNativePlatform.detector = detector;

            //load our lib!

            String adP = Application.streamingAssetsPath;

            String affdexDataPath = Path.Combine(adP, "affdex-data"); // Application.streamingAssetsPath + "/affdex-data";

            //String affdexDataPath = Application.dataPath + "/affdex-data";
            affdexDataPath = affdexDataPath.Replace('/', '\\');
            int status = initialize(discrete, affdexDataPath);

            Debug.Log("Initialized detector: " + status);


            FaceResults  faceFound    = new FaceResults(this.onFaceFound);
            FaceResults  faceLost     = new FaceResults(this.onFaceLost);
            ImageResults imageResults = new ImageResults(this.onImageResults);

            h1 = GCHandle.Alloc(faceFound, GCHandleType.Pinned);
            h2 = GCHandle.Alloc(faceLost, GCHandleType.Pinned);
            h3 = GCHandle.Alloc(imageResults, GCHandleType.Pinned);

            status = registerListeners(imageResults, faceFound, faceLost);
            Debug.Log("Registered listeners: " + status);
        }
Пример #5
0
        public void Initialize(Detector detector, int discrete)
        {
            WindowsNativePlatform.detector = detector;

            //load our lib!

            String adP = Application.streamingAssetsPath;

            String affdexDataPath = Path.Combine(adP, "affdex-data"); // Application.streamingAssetsPath + "/affdex-data";
            //String affdexDataPath = Application.dataPath + "/affdex-data";
            affdexDataPath = affdexDataPath.Replace('/', '\\');
            int status = initialize(discrete, affdexDataPath);
            Debug.Log("Initialized detector: " + status);

            FaceResults faceFound = new FaceResults(this.onFaceFound);
            FaceResults faceLost = new FaceResults(this.onFaceLost);
            ImageResults imageResults = new ImageResults(this.onImageResults);

            h1 = GCHandle.Alloc(faceFound, GCHandleType.Pinned);
            h2 = GCHandle.Alloc(faceLost, GCHandleType.Pinned);
            h3 = GCHandle.Alloc(imageResults, GCHandleType.Pinned);

            status = registerListeners(imageResults, faceFound, faceLost);
            Debug.Log("Registered listeners: " + status);
        }
Пример #6
0
        public override IEnumerator Initialize(Detector detector, int discrete)
        {
            iOSNativePlatform.detector = detector;
            String adP            = Application.streamingAssetsPath;
            String affdexDataPath = Path.Combine(adP, "affdex-data-ios");
            int    status         = 0;

            try
            {
                nativeHandle = affdexInitialize(discrete, affdexDataPath);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            Debug.Log("Initialized detector: " + status);

            mFaceFound    = new FaceResults(this.onFaceFound);
            mFaceLost     = new FaceResults(this.onFaceLost);
            mImageResults = new ImageResults(this.onImageResults);

            Debug.Log("mFaceFound = " + mFaceFound + ", mFaceLost = " + mFaceLost + ", mImageResults = " + mImageResults);  // SCP - TEMPORARY

            status = affdexRegisterListeners(nativeHandle, ImageCallbackProc, FaceFoundCallbackProc, FaceLostCallbackProc);
            Debug.Log("Registered listeners: " + status);
            yield break;
        }
 private static extern int affdexRegisterListeners(IntPtr handle,
                                                   [MarshalAs(UnmanagedType.FunctionPtr)] ImageResults imageCallback,
                                                   [MarshalAs(UnmanagedType.FunctionPtr)] FaceResults foundCallback,
                                                   [MarshalAs(UnmanagedType.FunctionPtr)] FaceResults lostCallback);