- Install Emgucv library which is a version for C#.
- Create new WindowsFormsApplication on Visual Studio named QRCodedetection or whatever you want
- Copy Emgucv dll files (opencv_contrib231.dll etc)which are located in bin folder to your own project's bin folder
- Go to your project
- Project-> Add Reference-> Browse add opencv dll files which you copied before
Go to your project designer part. And add one button which is named captureButton to capture a stream, UImageBox to display captured video. and make 2 label to see the result of decoded qrcode.
Double click in your button on designer and copy below
Double click in your button on designer and copy below
if (capture == null){try{capture = new Capture();}catch (NullReferenceException exception){MessageBox.Show(exception.Message);}}if (capture != null){if (Capturing){captureButton.Text = "Start Capture";Application.Idle -= Main;}else{captureButton.Text = "Stop Capture";Application.Idle += Main;}Capturing = !Capturing;}}private void Release(){if (capture != null)capture.Dispose();}
Capture capture;And those variables should be declared
bool Capturing;
Bitmap bimap;
private Reader reader;
private Hashtable hint;
Now let's do decoding part.
- download zxing.dll file
- Copy to your project bin folder
- Add to your project same with emgucv
- Copy them top of your program