async void btnAnalizarEmociones_Clicked(object sender, EventArgs e) { if (streamCopy != null) { streamCopy.Seek(0, SeekOrigin.Begin); var emociones = await EmotionAPI.ObtenerEmociones(streamCopy); if (emociones != null) { lblResultado.Text = " ---Análisis de Emociones---"; DibujarResultados(emociones); } else { lblResultado.Text = " ---No se detectó una cara---"; } } else { lblResultado.Text = " ---No has seleccionado una imagen---"; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Get UUID _deviceID = "undefined"; _currentSession = "undefined"; // Get latest session try { var request = new RestRequest("api/users", Method.GET); request.RequestFormat = DataFormat.Json; client.ExecuteAsync(request, response => { RestSharp.Deserializers.JsonDeserializer deserialize = new RestSharp.Deserializers.JsonDeserializer(); var users = deserialize.Deserialize <List <User> >(response); if (users.Count > 0) { _deviceID = users.First().id; _currentSession = users.First().currentSession; } }); } catch (Exception e) { System.Console.WriteLine(e.Message); } // Start Emotion API _emotionAPI = new EmotionAPI(); // Start Geolocation InitializeLocationManager(); // Start Mediaplayer _player = MediaPlayer.Create(this, Resource.Raw.neutral); photoTimer = new System.Timers.Timer(5000); photoTimer.Elapsed += async(sender, e) => await TakePhoto(); photoTimer.Start(); SetContentView(Resource.Layout.Main); _textureView = FindViewById <TextureView>(Resource.Id.textureView1); _textureView.SurfaceTextureListener = this; //_pictureButton = FindViewById<Button>(Resource.Id.GetPictureButton); //_pictureButton.Click += OnActionClick; //_imageView = FindViewById<ImageView>(Resource.Id.imageView1); _newSessionButton = FindViewById <Button>(Resource.Id.newSessionButton); _newSessionButton.Click += _newSessionButton_Click; _resultTextView = FindViewById <TextView>(Resource.Id.resultText); _emotionDetailsTextView = FindViewById <TextView>(Resource.Id.emotionDetails_text); _locationText = FindViewById <TextView>(Resource.Id.location_text); }
public async Task VisionEmotionAsync(MediaFile file) { if (string.IsNullOrEmpty(ImageUrl)) { WarningText = "Please take photo first"; } else { Title = "Checking image"; var emotion = new EmotionAPI(); var result = await emotion.EmotionRecognitionWithHttpMessagesAsync(file.GetStream(), null, Constants.EmotionApiKey); var faceNo = 1; var value = ""; //var test = await cognitiveServiceVision.VisionEmotionApiRequestAsync(Constants.EmotionApiKey, ImageUrl); //Emotion[] emotionRects = await cognitiveServiceVision.VisionEmotionApiRequestAsync(Constants.FaceApiKey,ImageUrl); //var photoStream = await PclStorageStreamAsync(ImageUrl); //Emotion[] emotionRects = await UploadAndDetectEmotion(await PclStorageStreamAsync(ImageUrl)); if (result != null && result.Length > 0) { Title = "Here is the result"; foreach (var emotionRect in result) { value += $"Face{faceNo} Anger: {emotionRect.Scores.Anger} Contempt: {emotionRect.Scores.Contempt} Disgust: {emotionRect.Scores.Disgust} Fear: {emotionRect.Scores.Fear} Happiness: {emotionRect.Scores.Happiness} Neutral: {emotionRect.Scores.Neutral} Sadness: {emotionRect.Scores.Sadness} Surprise: {emotionRect.Scores.Surprise}"; faceNo++; } } else { value = "No results"; } CleanResult(); Title = value; } }
// Start is called before the first frame update void Start() { emoObj = GameObject.FindGameObjectWithTag("EditorOnly").GetComponent <EmotionAPI>(); }