VB.NET — How to Capturing an Image From a Still Image Pin
This article shows how to use Viscomsoft VideoCap Pro SDK ActiveX to create windows form application and Capturing an Image From a Still Image Pin.
Step 1: To install the VideoCap Pro ActiveX Control, begin by launching the setup file (http://www.viscomsoft.com/demo/videocapprosetup.exe). Select the desired installation folder for the VideoCap Pro ActiveX and continue with the installation on your development computer.
Step 2: Create New Visual Basic Project, select Windows Application.
Step 3: The next step is to install VideoCap Pro ActiveX in ToolBox. Select Toolbox, select Components item, right click mouse button, select Choose Items…
Step 4: Select COM Components tab, select VideoCap Pro Control , click OK.
Step 5: Now you will see the VideoCap Pro ActiveX’s icon on toolbox, drag it to form.
Step 6: Add two combo box, two buttons, two label and savefiledialog on form. Like the following picture.
Step 7. add the following code in Form load event
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.LoadDim i As IntegerFor i = 0 To AxVideoCap1.GetDeviceCount - 1 cbovideodevice.Items.Add(AxVideoCap1.GetDeviceName(i))NextIf cbovideodevice.Items.Count > 0 Then cbovideodevice.SelectedIndex = 0End IfEnd Sub
Step 8. add the following code in Video Device Combo Box’s SelectedIndexChanged event.
Private Sub cbovideodevice_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handlescbovideodevice.SelectedIndexChangedAxVideoCap1.RefreshVideoDevice(cbovideodevice.SelectedIndex)AddStillPinVideoFormat()End Sub
Step 9 . Add AddStillPinVideoFormat() function
Private Sub AddStillPinVideoFormat()Dim i As IntegerDim strStillPinName As Stringcbostillpinformat.Items.Clear()For i = 0 To AxVideoCap1.StillPinVideoFormats.Count - 1 strStillPinName = AxVideoCap1.StillPinVideoFormats.FindVideoFormatName(i) cbostillpinformat.Items.Add(strStillPinName)NextIf cbostillpinformat.Items.Count > 0 Then cbostillpinformat.SelectedIndex = 0End IfEnd Sub
Step 10 . Add the following code in Preview button click event
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.ClickAxVideoCap1.Device = cbovideodevice.SelectedIndexAxVideoCap1.StillPinVideoFormat = cbostillpinformat.SelectedIndexAxVideoCap1.Start()End Sub
Step 11. Add the following code in Snapshot button click event
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.ClickSaveFileDialog1.Filter = "JPEG file (*.jpg)|*.jpg||"SaveFileDialog1.DefaultExt = "jpg"SaveFileDialog1.ShowDialog()AxVideoCap1.SnapShotJPEG(SaveFileDialog1.FileName, 99)End Sub
Step 12. Now run the project, select the video device, if your cameras can produce a still image separate from the capture stream, you can select Still Pin Format. Otherwise your cameras does not support Still Image Pin. Still image Pin can produce more higher quality than the images produced by the capture stream.
After you selected Still Pin Format , make sure you click Preview button first, then click the Snapshot button.
Download the source code of the Capturing an Image From a Still Image Pin Sample
Learn more about this product , please go to http://viscomsoft.com/products/videocappro