Coder Social home page Coder Social logo

ledrunning / facialdetection Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.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%
cameracapture csharp desktop dotnet emgu emgucv face-detection facedetection facial-detection mvvm opencv opencvsharp wpf

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.