Giter Site home page Giter Site logo

ledrunning / facialdetection Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 2.0 32.23 MB

Simple WPF MVVM Desktop application for facial detection in real time from web camera via Emgu

C# 100.00%
emgu emgucv csharp dotnet opencvsharp opencv cameracapture desktop face-detection facedetection

facialdetection's Introduction

Simple WPF MVVM Desktop application for facial detection in real time from web camera via Emgu

This application use Emgu CV 3.2 framework from https://www.emgu.com/wiki/index.php/Main_Page

.NET Desktop

Emgu CV 3.2 version documentation available by current link: https://www.emgu.com/wiki/index.php/Version_History#Emgu.CV-3.2.0

Emgu CV 3.2 version download link https://sourceforge.net/projects/emgucv/

To run app you should download Emgu CV from link above, install it, find and put these libraries into the bin folder (Debug or Release) I used EMGU CV x64 version, so I put these libraries along this path \bin\Debug\x64

  • concrt140.dll
  • cvextern.dll
  • msvcp140.dll
  • opencv_videoio_ffmpeg411_64.dll.dll
  • vcruntime140.dll

Or you be able to insert the libraries described above into your project tree and configure files to the output folder (set it as "copy if newer or copy always")

And don't forget about haarcascade_frontalface_default.xml just set copy to output directory in your project.

Logger is available in this project it writes all error and information data into a file. You should find it in the bin folder and it called Logs

For darcula or metro themes I used WPFToolkit and WPFToolkit.DataVisualization (JenniLe, Shimmy)

To change themes manually you should comment old and uncomment required theme in App.xaml f.e Metro Dark Theme:

Theme settings in Application.Resources
   <Application.Resources>
      <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
              <!-- IG Theme -->
              <ResourceDictionary Source="Themes/IG/IG.MSControls.Core.Implicit.xaml" />
              <ResourceDictionary Source="Themes/IG/IG.MSControls.Toolkit.Implicit.xaml" />

              <!-- Metro Theme -->
              <!--<ResourceDictionary Source="Themes/Metro/Metro.MSControls.Core.Implicit.xaml" />
              <ResourceDictionary Source="Themes/Metro/Metro.MSControls.Toolkit.Implicit.xaml" /> -->

              <!-- MetroDark Theme -->
              <!--<ResourceDictionary Source="Themes/MetroDark/MetroDark.MSControls.Core.Implicit.xaml" />
              <ResourceDictionary Source="Themes/MetroDark/MetroDark.MSControls.Toolkit.Implicit.xaml" /> -->
          </ResourceDictionary.MergedDictionaries>

          <!-- <SolidColorBrush x:Key="BackgroundKey" Color="#FFFFFF" /> Color="#FF181818" -->

          <!-- Dark Theme -->
          <SolidColorBrush x:Key="BackgroundKey" Color="#FFFFFF" />

          <Style x:Key="HeaderTextBlockStyle" TargetType="TextBlock">
              <Setter Property="FontSize" Value="22" />
              <Setter Property="FontFamily" Value="Segoe UI" />
              <Setter Property="Foreground" Value="#FF00AADE" />
          </Style>

          <Style x:Key="SubHeaderTextBlockStyle" TargetType="TextBlock">
              <Setter Property="FontSize" Value="18" />
              <Setter Property="FontFamily" Value="Segoe UI" />
              <Setter Property="Foreground" Value="#FF00AADE" />
          </Style>
      </ResourceDictionary>
      </Application.Resources>

If you have any problems, you can always create an Issue!

UI Layuot:

Screenshot

facialdetection's People

Contributors

jmanwhocodes avatar ledrunning avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

facialdetection's Issues

The Convert function in the ValueConverter always throws an exception

May I ask why occasionally an exception is thrown when converting Bitmap to BitmapImage in the BitmapSourceConvert class? The exception content is: System. Runtime. InteropServices. ExternalException (0x80004005): A general error occurred in GDI+.
Strangely, if I abandon the MVVM mode and directly rewrite the Convert function in BitmapSourceConvert in MainWindow. CS file, it will not throw an exception:

        private void Capture_ImageGrabbed(object sender, EventArgs e)
        {
                Mat mat = new Mat();
                bool b = capture.Retrieve(mat, 0);
                if (b && !mat.IsEmpty)
                {
                      this.Dispatcher.Invoke(new Action(() =>
                      {
                          image1.Source = Bitmap2BitmapImage(mat.Bitmap);
                      }));
                }
        }
        private BitmapImage Bitmap2BitmapImage(Bitmap bitmap)
        {
            using (var memoryStream = new MemoryStream())
            {
                try
                {
                    bitmap.Save(memoryStream, ImageFormat.Bmp);
                    BitmapImage image = new BitmapImage();
                    image.BeginInit();
                    memoryStream.Seek(0, SeekOrigin.Begin);
                    image.StreamSource = new MemoryStream(memoryStream.ToArray());
                    image.EndInit();
                    return image;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                return new BitmapImage();
            }
        }

I want to know why.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.