Beispiel #1
0
        private async Task TakePicture(string conversID)
        {
            if (!WebcamService.IsInitialized)
            {
                await WebcamService.InitializeCameraAsync();

                await WebcamService.StartCameraPreviewAsync();
            }

            using (var stream = new InMemoryRandomAccessStream())
            {
                ImageEncodingProperties imgFormat = ImageEncodingProperties.CreatePng();

                // create storage file in local app storage
                StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(
                    "AdaPhotoTMP.png",
                    CreationCollisionOption.ReplaceExisting);

                // take photo
                await WebcamService.MediaCapture.CapturePhotoToStorageFileAsync(imgFormat, file);

                FileStream fileStream  = new FileStream(file.Path, FileMode.Open);
                Stream     streamFinal = fileStream.AsRandomAccessStream().AsStream();

                StringConstructorSDK client = new StringConstructorSDK()
                {
                    WebAppUrl = $"{ AppConfig.WebUri}"
                };

                try
                {
                    var activity = new Activity
                    {
                        From = new ChannelAccount("Jean"),
                        Text = "Picture from UWP",
                        Type = ActivityTypes.Message,
                        //Envoyer le stream
                        ChannelData = await client.PictureAnalyseAsync(AppConfig.Vision, streamFinal),
                        //ATTENTION CONVERSID DIFFERENT!!!!!
                        Name = conversID,
                        //Summary = serviceUrl
                    };
                    await _client.Conversations.PostActivityAsync(_conversation.ConversationId, activity);
                }
                catch (HttpRequestException)
                {
                    //Impossible to take picture
                }
            }
        }
Beispiel #2
0
        private async Task CameraLoadExecute()
        {
            LogHelper.Log <WebcamService>("Je me mets au travail!");

            await WebcamService.InitializeCameraAsync();

            WebcamService.CaptureElement = CaptureElement;

            await WebcamService.StartCameraPreviewAsync();

            if (WebcamService.IsInitialized && await WebcamService.StartFaceDetectionAsync(300))
            {
                WebcamService.FaceDetectionEffect.FaceDetected += OnFaceDetected;
            }
        }