public ProjectOxford()
        {
            var appSettings = ResourceLoader.GetForViewIndependentUse("AppSettings");

            visionClient  = new VisionServiceClient(appSettings.GetString("VISION_API_KEY"));
            faceClient    = new FaceServiceClient(appSettings.GetString("FACE_API_KEY"));
            emotionClient = new EmotionServiceClient(appSettings.GetString("EMOTION_API_KEY"));
        }
Exemple #2
0
        public MainPage()
        {
            InitializeComponent();

            _visionServiceClient = new VisionServiceClient("KEY", "URL");

            BindingContext = this;
        }
Exemple #3
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            // Get request body
            byte[] image = await req.Content.ReadAsByteArrayAsync();


            if (image != null)
            {
                faceServiceClient = new FaceServiceClient(GetEnvironmentVariable("FaceApiKey"), GetEnvironmentVariable("FaceApiEndpoint"));
                _visionClient     = new VisionServiceClient(GetEnvironmentVariable("ComputerVisionApiKey"), GetEnvironmentVariable("ComputerVisionApiEndpoint"));
                data = new NotificationInfo();

                try
                {
                    log.Info("Processing Image...");
                    await ProcessImage(image, log);
                }
                catch (NoGearException)
                {
                    //Send no gear event
                    data.notification = "No Safety Gear Detected";
                    await SendEventsToTopic(new Event(data, "NoGearEvent"), log);

                    return(GenerateResponse(req));
                }
                catch (UnrecognisedFaceException)
                {
                    data.notification = "Unrecognised Person";
                    //Send notification that unrecognised person is attempting to enter site
                    await SendEventsToTopic(new Event(data, "UnrecognisedFaceEvent"), log);

                    return(GenerateResponse(req));
                }
                catch (FaceAPIException)
                {
                    data.notification = "Unprocessed Image";
                    return(GenerateResponse(req));
                }
                catch (TooManyFacesException)
                {
                    data.notification = "Too many faces";
                    return(GenerateResponse(req));
                }
                catch (NoFaceException)
                {
                    data.notification = "No Face Detected";
                    return(GenerateResponse(req));
                }
            }

            return(req.CreateResponse(HttpStatusCode.BadRequest, "Image not recognised"));
        }
        public ComputerVisionService(string listingsJson, string apiKey)
        {
            if (string.IsNullOrWhiteSpace(listingsJson))
            {
                throw new ArgumentException("message", nameof(listingsJson));
            }

            if (string.IsNullOrWhiteSpace(apiKey))
            {
                throw new ArgumentException("message", nameof(apiKey));
            }

            _images = GetListingImages(listingsJson).OrderBy(image => Guid.NewGuid()).Take(20); // rate limit: 20 per min.
            _api    = new VisionServiceClient(apiKey, "https://westcentralus.api.cognitive.microsoft.com/vision/v2.0");
        }
Exemple #5
0
        /// <summary>
        /// MainViewModel constructor. Creates the required API clients and ViewModels
        /// </summary>
        public MainViewModel()
        {
            _visionClient = new VisionServiceClient("API_KEY_HERE");

            CelebrityVm     = new CelebrityViewModel(_visionClient);
            DescriptionVm   = new DescriptionViewModel(_visionClient);
            ImageAnalysisVm = new ImageAnalysisViewModel(_visionClient);
            OcrVm           = new OcrViewModel(_visionClient);
            ThumbnailVm     = new ThumbnailViewModel(_visionClient);

            _faceServiceClient = new FaceServiceClient("API_KEY_HERE");

            SimilarFaceVm      = new SimilarFaceViewModel(_faceServiceClient);
            FaceGroupingVm     = new FaceGroupingViewModel(_faceServiceClient);
            FaceVerificationVm = new FaceVerificationViewModel(_faceServiceClient);
        }
        /// <summary>
        /// LuisViewModel constructor.
        /// Creates vision client, luis client, speech-to-text and text-to-speech clients, as well as ICommand objects
        /// </summary>
        public LuisViewModel()
        {
            _bingSearch = new BingSearch();

            _visionClient = new VisionServiceClient("FACE_API_KEY", "ROOT_URI");

            _luis = new Luis(new LuisClient("LUIS_APP_ID", "LUIS_API_KEY"));
            _luis.OnLuisUtteranceResultUpdated += OnLuisUtteranceResultUpdated;

            _sttClient = new SpeechToText(_bingApiKey);
            _sttClient.OnSttStatusUpdated += OnSttStatusUpdated;

            _ttsClient = new TextToSpeech();
            _ttsClient.OnAudioAvailable += OnTtsAudioAvailable;
            _ttsClient.OnError          += OnTtsError;
            GenerateHeaders();

            RecordUtteranceCommand  = new DelegateCommand(RecordUtterance);
            ExecuteUtteranceCommand = new DelegateCommand(ExecuteUtterance, CanExecuteUtterance);
        }
Exemple #7
0
 /// <summary>
 /// CelebrityViewModel constructor. Assigns the <see cref="IVisionServiceClient"/> API client and creates the command object
 /// </summary>
 /// <param name="visionClient"><see cref="IVisionServiceClient"/></param>
 public CelebrityViewModel(IVisionServiceClient visionClient)
 {
     _visionClient = visionClient;
     LoadAndFindCelebrityCommand = new DelegateCommand(LoadAndFindCelebrity, CanFindCelebrity);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VisionHelper"/> class.
 /// </summary>
 /// <param name="subscriptionKey">The subscription key.</param>
 public VisionHelper(string subscriptionKey)
 {
     this.visionClient = new VisionServiceClient(subscriptionKey);
 }
Exemple #9
0
 /// <summary>
 /// ThumbnailViewModel constructor. Assigns the <see cref="IVisionServiceClient"/> API client
 /// </summary>
 /// <param name="visionClient"><see cref="IVisionServiceClient"/></param>
 public ThumbnailViewModel(IVisionServiceClient visionClient)
 {
     _visionClient = visionClient;
     Initialize();
 }
 public CognitiveClient()
 {
     _visionClient = new VisionServiceClient("<<YOUR KEY HERE>>");
 }
 public ImageCaptureService()
 {
     emotionServiceClient = ServiceLocator.GetRequiredService <IEmotionServiceClient>();
     faceServiceClient    = ServiceLocator.GetRequiredService <IFaceServiceClient>();
     visionServiceClient  = ServiceLocator.GetRequiredService <IVisionServiceClient>();
 }
Exemple #12
0
 private AnalyzerController(IVisionServiceClient visionServiceClient)
 {
     this.visionServiceClient = visionServiceClient;
 }
Exemple #13
0
 public GoatDetector(IVisionServiceClient visionServiceClient)
 {
     _visionServiceClient = visionServiceClient;
 }
Exemple #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisionHelper"/> class.
 /// </summary>
 /// <param name="subscriptionKey">The subscription key.</param>
 public VisionHelper(string subscriptionKey)
 {
     this.visionClient = new VisionServiceClient(subscriptionKey);
 }
Exemple #15
0
 /// <summary>
 /// ImageAnalysisViewModel constructor. Assigns the <see cref="IVisionServiceClient"/> API client
 /// </summary>
 public ImageAnalysisViewModel(IVisionServiceClient visionClient)
 {
     _visionClient = visionClient;
     Initialize();
 }
 /// <summary>
 /// DescriptionViewModel constructor. Assigns the <see cref="IVisionServiceClient"/> API client
 /// </summary>
 /// <param name="visionClient"><see cref="IVisionServiceClient"/></param>
 public DescriptionViewModel(IVisionServiceClient visionClient)
 {
     _visionClient = visionClient;
     Initialize();
 }
 /// <summary>
 /// OcrViewModel constructor. Assigns the <see cref="IVisionServiceClient"/> API client
 /// </summary>
 public OcrViewModel(IVisionServiceClient visionClient)
 {
     _visionClient = visionClient;
     Initialize();
 }
Exemple #18
0
        public MainPage()
        {
            InitializeComponent();

            _visionServiceClient = new VisionServiceClient("KEY", "URL");
        }
Exemple #19
0
        public VisionApi(string subscriptionKey)
        {
            Check.Required<ArgumentNullException>(() => subscriptionKey != null);

            _client = new VisionServiceClient(subscriptionKey);
        }
Exemple #20
0
 public ImageReader(Stream photo = null)
 {
     this.visionClient = new VisionServiceClient(SUBSCRIPTION_KEY);
     this.photo        = photo;
 }
Exemple #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisionProvider"/> class.
 /// </summary>
 /// <param name="subscriptionKey">The subscription key.</param>
 public VisionProvider(string subscriptionKey)
 {
     this._visionClient = new VisionServiceClient(subscriptionKey);
 }
Exemple #22
0
 public MicrosoftVisionApi(string apiKey, IVisionServiceClient visionServiceClient)
 {
     _apiKey = apiKey;
     _visionServiceClient = visionServiceClient;
 }
Exemple #23
0
        public VisionApi(string subscriptionKey)
        {
            Check.Required <ArgumentNullException>(() => subscriptionKey != null);

            _client = new VisionServiceClient(subscriptionKey);
        }
 public ImageAnalyzer()
 {
     faceDetector   = new FaceServiceClient(keyId);
     visionDetector = new VisionServiceClient(keyId);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VisionHelper"/> class.
 /// </summary>
 /// <param name="subscriptionKey">The subscription key.</param>
 /// <param name="rootApi">Root Api Url.</param>
 public VisionHelper(string subscriptionKey, string rootApi)
 {
     this.visionClient = new VisionServiceClient(subscriptionKey, rootApi);
 }
Exemple #26
0
 public ImageReader(Stream photo = null)
 {
     this.visionClient = new VisionServiceClient(SUBSCRIPTION_KEY);
     this.photo = photo;
 }