Skip to content

Commit

Permalink
Adding Oxford age and gender
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescadd committed Jun 11, 2015
1 parent bd4ef79 commit 9ddd088
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Criminalyzer/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Image Width="300" Height="300" Source="{Binding CapturedImage}"/>

<StackPanel Orientation="Vertical">
<Image Width="300" Height="300" Source="{Binding CapturedImage}"/>
<TextBlock Text="{Binding CapturedAge}"/>
<TextBlock Text="{Binding CapturedGender}"/>
</StackPanel>

<Button Grid.Row="2" Command="{Binding TakePictureCommand}">Take Picture</Button>
</Grid>
Expand Down
23 changes: 22 additions & 1 deletion Criminalyzer/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -25,9 +26,15 @@ class MainViewModel

public BitmapImage CapturedImage { get; private set; }

public string CapturedAge { get; private set; }

public string CapturedGender { get; private set; }

private FaceServiceClient _faceService;

public MainViewModel()
{

_faceService = new FaceServiceClient("9b9e6f57f27a4ce9b949c3a22dee8630");
}

protected void OnGetMugshots()
Expand Down Expand Up @@ -64,7 +71,21 @@ protected async void OnTakePicture()
bitmapImage.SetSource(fileStream);
}

using (var stream = await file.OpenAsync(FileAccessMode.Read))
{
var faceResult = await _faceService.DetectAsync(stream.AsStream());
var face = faceResult.FirstOrDefault();

if (face != null)
{
CapturedAge = face.Attributes.Age.ToString();
CapturedGender = face.Attributes.Gender;
}
}

CapturedImage = bitmapImage;

// Oxford face detection
}
else
{
Expand Down

0 comments on commit 9ddd088

Please sign in to comment.