Display webcam images captured with EmguCV in C#


Today I am going to show how can one easily show from webcam in PictureBox control in C#.

First download the EmguCV wrapper from here http://sourceforge.net/projects/emgucv/ then install the EmguCV wrapper.
To use this you need to add some references of EmguCV to your project. To add reference open Solution Explorer and right click on the References.

Then select Add Reference. A new window will open. From there select Browse tab.

From the folder explorer select the required dll and Click OK. Here you will need Emgu.CV.dll & Emgu.Util.dll. You are done with adding reference.

Now add a picturebox and Button to your form.Now Double Click on the Button to add code for the button. Now write the code as follow.

Now Build the project. If everything is okey then no error will occur.

Now its time to run. Now run the project. Though everything was fine it will throw en exception in the time of initialization of capture.

If you see the details you will be able to know that original exception is

“Unable to load DLL ‘opencv_core231’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)”}

That means you have to add this dll or exe s  to your debug folder. now add all the exe and dll files from of bin folder of your Emgu installed folder as follow. So that there will be no error in future.

Now run your project and Click on the Button Start. Picture box will show from the webcam live.

Thanks.

About Razib Chandra Deb

I completed my BSc in CSE from CSE Department of KUET. Currently I am working as a Software Engineer in Samsung R&D Institute Bangladesh(SRBD). I am interested in image processing.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

15 Responses to Display webcam images captured with EmguCV in C#

  1. Nice blog!! bookmark korlam 😀

  2. anh says:

    thanks so much, very helpful. good guy!!!

  3. itsho says:

    Don’t forget you should Dispose() the previous picture since you are the one who created it (with ToBitmap()). 🙂

  4. Very Awesome.
    Thanks guys keep share you knowledge

    Thanks

  5. james says:

    some dll and exe are missing in my download

  6. zain says:

    Great Blog fro beginers.

  7. Dhanil das says:

    Hiii…..if you getting the error again and again……. and you were added the reference correctly….then remove the references…. and add it again …. this will work for you

  8. shobana says:

    thank you 🙂

  9. Sergio says:

    If you already did the dll setup and still get the exception, try as follows:
    Go to Project Properties -> Application -> Target Framework, change it to .NET Framework 4, and presto! Run your application again and it should work just fine.

  10. Raghad says:

    Hi … If I want to do that in ASP.NET web application what is the control can I use it instead of ImageBox Control and what is changes I must do it on the code ?
    Many Thanks

Leave a reply to razibdeb Cancel reply