-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Here we go... (Project ready to compile/run. Tested on Win7/Win 8.1, x64 and x86)
- Loading branch information
Showing
46 changed files
with
314,462 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.30723.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Face(andmore)Tracker", "Face(andmore)Tracker\Face(andmore)Tracker.csproj", "{4704C95D-2D13-4F45-8095-F107BA12199D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Debug|Any CPU.ActiveCfg = Release|Any CPU | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Debug|Any CPU.Build.0 = Release|Any CPU | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Debug|x64.ActiveCfg = Debug|x64 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Debug|x64.Build.0 = Debug|x64 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Debug|x86.ActiveCfg = Debug|x86 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Debug|x86.Build.0 = Debug|x86 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Release|x64.ActiveCfg = Release|x64 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Release|x64.Build.0 = Release|x64 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Release|x86.ActiveCfg = Release|x86 | ||
{4704C95D-2D13-4F45-8095-F107BA12199D}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Application x:Class="FaceFinderDemo.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace FaceFinderDemo | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using Emgu.CV; | ||
using FaceFinderDemo.ImageProcessing; | ||
|
||
namespace FaceFinderDemo.Camera | ||
{ | ||
public class CameraDevice : ImageProcessor, IDisposable | ||
{ | ||
public bool IsCapturing { get { return isCapturing; }} | ||
|
||
Mat capturedImage; | ||
Capture camera; | ||
bool disposed; | ||
int frameRate; | ||
int frameCount; | ||
bool isCapturing; | ||
|
||
public CameraDevice() | ||
{ | ||
capturedImage = new Mat(); | ||
} | ||
|
||
public void StartCamera(int cameraIndex) | ||
{ | ||
if (isCapturing) | ||
{ | ||
return; | ||
} | ||
CvInvoke.UseOpenCL = false; | ||
camera = new Capture(cameraIndex); | ||
camera.ImageGrabbed += CapOnImageGrabbed; | ||
camera.Start(); | ||
isCapturing = true; | ||
} | ||
|
||
public void StopCamera() | ||
{ | ||
if (!isCapturing) | ||
{ | ||
return; | ||
} | ||
|
||
camera.ImageGrabbed -= CapOnImageGrabbed; | ||
camera.Stop(); | ||
camera.Dispose(); | ||
isCapturing = false; | ||
} | ||
|
||
private void CapOnImageGrabbed(object sender, EventArgs e) | ||
{ | ||
frameCount++; | ||
//Debug.WriteLine("Frames: " + frameCount); | ||
camera.Retrieve(capturedImage); | ||
OnImageAvailable(capturedImage); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (disposed) | ||
{ | ||
return; | ||
} | ||
|
||
capturedImage.Dispose(); | ||
|
||
if (isCapturing) | ||
{ | ||
StopCamera(); | ||
} | ||
|
||
disposed = true; | ||
} | ||
|
||
protected override void OnImageReceived(Mat image) | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
using AForge.Video.DirectShow; | ||
|
||
namespace FaceFinderDemo.Camera | ||
{ | ||
/// <summary> | ||
/// EMGU CV doesn't support detecting available cameras, so we use directshow for it. | ||
/// </summary> | ||
public static class DeviceEnumerator | ||
{ | ||
public static List<string> GetDeviceNames() | ||
{ | ||
var devices = new List<string>(); | ||
FilterInfoCollection videoDevices = new FilterInfoCollection( | ||
FilterCategory.VideoInputDevice); | ||
for (int i = 0; i != videoDevices.Count; i++) | ||
{ | ||
var dev = videoDevices[i]; | ||
devices.Add(dev.Name); | ||
} | ||
// OpenCV seems to handle the order in the other direction | ||
devices.Reverse(); | ||
return devices; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Timers; | ||
using Emgu.CV; | ||
using Emgu.CV.CvEnum; | ||
using FaceFinderDemo.ImageProcessing; | ||
|
||
namespace FaceFinderDemo.Camera | ||
{ | ||
public class ImageDevice : ImageProcessor, IDisposable | ||
{ | ||
public bool IsSending { get { return isSending; } } | ||
|
||
public int FrameRate { get; set; } | ||
|
||
bool disposed; | ||
Mat image; | ||
bool isSending; | ||
Timer sendTimer; | ||
object sync = new object(); | ||
|
||
public ImageDevice() | ||
{ | ||
sendTimer = new Timer(); | ||
sendTimer.Interval = 100; | ||
sendTimer.Elapsed += SendTimerOnElapsed; | ||
} | ||
|
||
void SendTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) | ||
{ | ||
if (image == null) | ||
return; | ||
|
||
sendTimer.Stop(); | ||
lock (elapsedEventArgs) | ||
{ | ||
OnImageAvailable(image.Clone()); | ||
} | ||
sendTimer.Start(); | ||
} | ||
|
||
public void StartSending() | ||
{ | ||
if (isSending) | ||
return; | ||
|
||
sendTimer.Start(); | ||
|
||
isSending = true; | ||
} | ||
|
||
public void StopSending() | ||
{ | ||
if (!isSending) | ||
return; | ||
|
||
sendTimer.Stop(); | ||
|
||
isSending = false; | ||
} | ||
|
||
public bool LoadFromFile(string imageFile) | ||
{ | ||
lock (sync) | ||
{ | ||
if (image != null) | ||
{ | ||
image.Dispose(); | ||
} | ||
try | ||
{ | ||
var imageLoaded = new Mat(imageFile, LoadImageType.Color); | ||
if (imageLoaded.IsEmpty) | ||
return false; | ||
|
||
image = imageLoaded; | ||
return true; | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (disposed) | ||
{ | ||
return; | ||
} | ||
|
||
if (image != null) | ||
{ | ||
image.Dispose(); | ||
} | ||
|
||
disposed = true; | ||
} | ||
|
||
protected override void OnImageReceived(Mat image) | ||
{ | ||
|
||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Face(andmore)Tracker/Converters/InverseBooleanConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Windows.Data; | ||
|
||
namespace FaceFinderDemo.Converters | ||
{ | ||
[ValueConversion(typeof(bool), typeof(bool))] | ||
public class InverseBooleanConverter : IValueConverter | ||
{ | ||
#region IValueConverter Members | ||
|
||
public object Convert(object value, Type targetType, object parameter, | ||
System.Globalization.CultureInfo culture) | ||
{ | ||
if (targetType != typeof(bool)) | ||
throw new InvalidOperationException("The target must be a boolean"); | ||
|
||
return !(bool)value; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, | ||
System.Globalization.CultureInfo culture) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace FaceFinderDemo.Converters | ||
{ | ||
[ValueConversion(typeof(bool), typeof(Visibility))] | ||
public class VisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
bool flag = false; | ||
if (value is bool) | ||
{ | ||
flag = (bool)value; | ||
} | ||
else if (value is bool?) | ||
{ | ||
bool? nullable = (bool?)value; | ||
flag = nullable.HasValue ? nullable.Value : false; | ||
} | ||
return (flag ? Visibility.Visible : Visibility.Hidden); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.