Face Detection with Emgu CV in C# and WPF -


i doing face detection emgu cv in c# , wpf,the problem program getting run,but nothing displayed in window-

code is-

mainwindow.xaml  <window x:class="facerecognition.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="600" width="800" loaded="window_loaded">     <grid>         <image name="image1" stretch="fill"></image>     </grid> </window>  mainwindow.xaml.cs  using system; using system.collections.generic; using system.linq; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; using emgu.cv.structure; using emgu.cv; using system.runtime.interopservices; using system.windows.threading; using system.drawing;  namespace facerecognition {     /// <summary>     /// interaction logic mainwindow.xaml     /// </summary>     public partial class mainwindow : window     {         private capture capture;         private haarcascade haarcascade;         dispatchertimer timer;         public mainwindow()         {             initializecomponent();         }          private void window_loaded(object sender, routedeventargs e)         {             capture = new capture();             haarcascade = new haarcascade(@"haarcascade_frontalface_default.xml");             timer = new dispatchertimer();             timer.tick += new eventhandler(timer_tick);             timer.interval = new timespan(0, 0, 0, 0, 1);             timer.start();         }           void timer_tick(object sender, eventargs e)         {             image<bgr, byte> currentframe = capture.queryframe();              if (currentframe != null)             {                 image<gray, byte> grayframe = currentframe.convert<gray, byte>();                  var detectedfaces = grayframe.detecthaarcascade(haarcascade)[0];                  foreach (var face in detectedfaces)                     currentframe.draw(face.rect, new bgr(0, double.maxvalue, 0), 3);                  image1.source = tobitmapsource(currentframe);             }          }           [dllimport("gdi32")]         private static extern int deleteobject(intptr o);          public static bitmapsource tobitmapsource(iimage image)         {             using (system.drawing.bitmap source = image.bitmap)             {                 intptr ptr = source.gethbitmap(); //obtain hbitmap                  bitmapsource bs = system.windows.interop.imaging.createbitmapsourcefromhbitmap(                     ptr,                     intptr.zero,                     int32rect.empty,                     system.windows.media.imaging.bitmapsizeoptions.fromemptyoptions());                  deleteobject(ptr); //release hbitmap                 return bs;             }         }     } } 

i have added references required of emgu dll files,and added opencv dll files in following folder-

d:\dot net\handouts\handoutsprogram\facerecognition\facerecognition\bin\debug 


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -