Actually I have experienced working with Open CV 2.3 and Visual Studio 2010 while doing my thesis for my undergraduate study, I also wrote some tutorial, but I lost the articles because someone destroyed my website haha anyhow, after 5 years, I started my master degree and somehow get stuck with vision again. But this time, I tried to write something in C#, and openCV cannot afford that, so I use EmguCV as a C# wrapper of OpenCV library. This is just beginning, I hope the rest of my journey would be easy haha

My Weapons:

  • Visual Studio 2015 Express
  • Windows 10 Education
  • Kinect Camera V2


  • EmguCV 3.1.0 , as per this date, this is the newest version. Follow the instruction in the website. Basically, the newer version was easy to install. They provided .exe file to be executed.
  • After finished, building the Emgu.CV.Example.sln from the installation folder (this is also could be found in the website). This step is for retrieving related library that will be used for program development. Just give some note to change the Build Properties into x64 machine. I got many errors and exception because of this. Right Click in the solution file then click Properties.

  • Now, you must have seen Emgu.CV.UI.dll , Emgu.CV.World.dll , etc in the bin folder. For now, it’s enough.

Building My First WPF Application using EmguCV

My first application is how to load an image from our computer, then convert the image into Gray Image. I have been reading many tutorials and done some troubleshooting also. I spent one whole day to troubleshooting until this program works. ūüôĀ

  • Create New WPF Application Project with Visual Studio
  • Take care of the reference library first. Add following library/ files into the project: Emgu.CV.UI, Emgu.CV.World. Emgu.Util (For the main references) and Add following existing files: opencv_core220.dll, opencv_imgproc_core220.dll, opencv_ffmpeg310_64.dll. Other than Emgu.CV.UI and Emgu.CV.World, I could not find it in the installation folder of Emgu. So I add it, and copy from example solution and paste it into my project folder.
  • Add BitmapCourseConverter.cs class from Emgu WPF folder in the installation folder. This is as converter, because WPF and Windows Form works differently. WPF uses System.Windows.Media.Imaging while Windows Form uses System.Drawing. Emgu and OpenCV were supposed to work with unmanaged code.
  • Make the simple WPF interface with Image container and Button.
   <ColumnDefinition />
   <ColumnDefinition />
   <RowDefinition Height="*"/>
   <RowDefinition Height="auto"/>
 <Image x:Name="myImage" Margin="5" />
 <Image Grid.Column="1" x:Name="myGreyImage" Margin="5"/>
 <Button Grid.Column="1" Grid.Row="1" x:Name="testButton" Content="Load Image" Click="testButton_Click" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="44" Width="92"/>
  • Insert the code into the Button Event Handler
OpenFileDialog openPic = new OpenFileDialog();
            if (openPic.ShowDialog() == true)
                Image<Bgr, byte> gambar = new Image<Bgr, byte>(openPic.FileName);
                myImage.Source = Emgu.CV.WPF.BitmapSourceConvert.ToBitmapSource(gambar);

                Image<Gray, byte> gambarAbu = gambar.Convert<Gray, byte>();
                myGreyImage.Source = Emgu.CV.WPF.BitmapSourceConvert.ToBitmapSource(gambarAbu);



If you still found error, refer to any other references: 1 | 2 |

3 thoughts on “First WPF Application with EmguCV”
    1. basically i want to add existing class easily , so i copy it to my folder, so that i dont have to go deep looking for it haha

      and why i need it? as i wrote, i need it for converting the bitmap, since the basic converter is not for wpf hehe

Leave a Reply