Example #1
0
        /// <summary>
        /// Initializes Oxford API. Builds existing whitelist or creates one if one does not exist.
        /// </summary>
        public async static Task <bool> InitializeOxford()
        {
            // Attempts to open whitelist folder, or creates one
            StorageFolder whitelistFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(GeneralConstants.WhiteListFolderName, CreationCollisionOption.OpenIfExists);

            // Creates a new instance of the Oxford API Controller
            FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;

            // Attempts to open whitelist ID file, or creates one
            StorageFile WhiteListIdFile = await whitelistFolder.CreateFileAsync("WhiteListId.txt", CreationCollisionOption.OpenIfExists);

            // Reads whitelist file to get whitelist ID and stores value
            string savedWhitelistId = await FileIO.ReadTextAsync(WhiteListIdFile);

            // If the ID has not been created, creates a whitelist ID
            if (savedWhitelistId == "")
            {
                string id = Guid.NewGuid().ToString();
                await FileIO.WriteTextAsync(WhiteListIdFile, id);

                savedWhitelistId = id;
            }

            // Builds whitelist from exisiting whitelist folder
            await sdkController.CreateWhitelistFromFolderAsync(savedWhitelistId, whitelistFolder, null);

            // Return true to indicate that Oxford was initialized successfully
            return(true);
        }
Example #2
0
 /// <summary>
 /// Accepts the name of a visitor. Removes them from whitelist.
 /// </summary>
 public async static void RemoveUserFromWhitelist(string name)
 {
     // Acquires instance of Oxford SDK controller
     FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;
     // Asynchronously remove user from whitelist
     await sdkController.RemovePersonFromWhitelistAsync(name);
 }
        /// <summary>
        /// Checks to see if a whitelisted visitor is in passed through image. Returns list of whitelisted visitors. If no authorized users are detected, returns an empty list.
        /// </summary>
        public async static Task <List <string> > IsFaceInWhitelist(StorageFile image)
        {
            FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;
            List <string>     matchedImages = await sdkController.FaceRecognizeAsync(image);

            return(matchedImages);
        }
Example #4
0
        /// <summary>
        /// Checks to see if a whitelisted visitor is in passed through image. Returns list of whitelisted visitors. If no authorized users are detected, returns an empty list.
        /// </summary>
        public async static Task <Dictionary <HSFace, HSPerson> > IsFaceInWhitelist(StorageFile image)
        {
            FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;

            return(await sdkController.FaceRecognizeAsync(image));

            /* List<string> matchedImages = new List<string>();
             * matchedImages = await sdkController.FaceRecognizeAsync(image);
             *
             * return matchedImages;*/
        }
 /// <summary>
 /// Accepts an image file and the name of a visitor. Associates photo with exisiting visitor.
 /// </summary>
 public async static void AddImageToWhitelist(StorageFile imageFile, string name)
 {
     try {
         // Acquires instance of Oxford SDK controller
         FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;
         // Asynchronously adds image to whitelist
         await sdkController.AddImageToWhitelistAsync(imageFile, name);
     }
     catch {
         Debug.WriteLine("Failed to add image.");
     }
 }
Example #6
0
 /// <summary>
 /// Accepts a user name and the folder in which their identifying photos are stored. Adds them to the whitelist.
 /// </summary>
 public async static void AddUserToWhitelist(string name, StorageFolder photoFolder)
 {
     try
     {
         // Acquires instance of Oxford SDK controller
         FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;
         // Asynchronously adds user to whitelist
         await sdkController.AddPersonToWhitelistAsync(photoFolder, name);
     }
     catch (Exception)
     {
         Debug.WriteLine("Failed to add user to whitelist.");
     }
 }
Example #7
0
 /// <summary>
 /// Accepts the name of a visitor. Removes them from whitelist.
 /// </summary>
 public async static void RemoveUserFromWhitelist(string name)
 {
     try
     {
         // Acquires instance of Oxford SDK controller
         FaceApiRecognizer sdkController = FaceApiRecognizer.Instance;
         // Asynchronously remove user from whitelist
         await sdkController.RemovePersonFromWhitelistAsync(name);
     }
     catch (Exception)
     {
         Debug.WriteLine("Fail to deleted user");
     }
 }