In this tutorial, you will learn how to function your webcam on your VB.Net Project.
First of all, the following dynamic library links (.dll) needed on this tutorial can be download through the provided link below.
After downloading the needed .dll for our project. Follow these steps to complete the functionality of your webcam on your VB.Net project.
- Open your Visual Studio Application and click “New Project” and name your project as you like. In this tutorial, we named our project to Sample Webcam App.
- On the Solution Explorer, right-click the name of your project, go to Add then click Reference. (click or see the image below).
- Then, click Browse from the Reference window and we will add the .dll to the VB.Net project from the Emgu folder. Usually, the default location of the folder when installed is C:\Emgu\emgucv-windows-x86 22.214.171.1247. Then after locating the folder, go to bin and select ONLY the following: (click or see the image below).
Note: Emgu.CV.dll, Emgu.CV.UI.dll, and Emgu.Util.dll are the major .dlls needed for the project to function the webcam from your VB.Net project.
After hitting the button Add, you can see your references that the three .dll are being added to your reference. (click or see the image below).
Then drag the x86 folder from the Emgu bin folder to your project, it will look like this. (click or see image below).
Notice that I have highlighted the three .dll from the x86 folder. Delete these files because it is not necessary to have them in our project. After deleting the three .dll, select all from the x86 folder and go to properties, change the Copy to Output Directory to Copy if newer.
4. Now, we will add objects to our Form1 design, all we need to add is a PictureBox, Button and Timer. (click or see image below).
As you notice that I have emphasized the picturebox tasks, (can be seen by click the little play button at the upper right corner of the picturebox) size mode to StretchImage. This will make your picturebox capture the image from your webcam to emphasize the image that the webcam is capturing.
Now, let’s do the coding! Right click your Form1 design and click view code. After doing so, insert this code:
Public Class Form1
Dim captureimg As Capture = New Capture
Then, double click the Timer1 icon at the bottom of our design and insert this code:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
PictureBox1.Image = captureimg.QueryFrame.ToBitmap()
Then, doublic click the button and insert this code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
After doing so, run your project and click the button object. Notice that your webcam is functioning and capturing what it sees! Here’s mine. (click or see the image below).
RAR Extraction Password:
For inquires, questions or any other concerns, you can contact me through the following:
Contact No.: +639263339008
To download the sample project, click here.