Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Emgu.CV
- Imports Emgu.CV.CvEnum
- Imports Emgu.CV.Structure
- Imports Emgu.CV.UI
- Imports Emgu.CV.Util
- Imports BGAPI2
- Imports BGAPI2.Events
- Imports BGAPI2.Exceptions
- Public Class FrmMain
- 'Dim CapImg As New Capture()
- 'Dim filename As String
- Dim systemList As BGAPI2.SystemList
- Dim mSystem As BGAPI2.System
- Dim sSystemID As String
- Dim interfaceList As BGAPI2.InterfaceList
- Dim mInterface As BGAPI2.Interface
- Dim sInterfaceID As String
- Dim deviceList As BGAPI2.DeviceList
- Dim mDevice As BGAPI2.Device
- Dim sDeviceID As String
- Dim datastreamList As BGAPI2.DataStreamList
- Dim mDataStream As BGAPI2.DataStream
- Dim sDataStreamID As String
- Dim bufferList As BGAPI2.BufferList
- Dim mBuffer As BGAPI2.Buffer
- Dim mDeviceNodeList As BGAPI2.NodeMap
- Dim iDeviceIPAddress, iDeviceSubnetMask, iDeviceSubnet, iInterfaceSubnet As Long
- Private Sub FrmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- '############################### SYSTEM INFO ###############################
- systemList = systemList.Instance
- systemList.Refresh()
- Label1.Text = "Detected Systems: " & systemList.Count
- For Each sys_pair As KeyValuePair(Of String, BGAPI2.System) In BGAPI2.SystemList.Instance
- sys_pair.Value.Open()
- sSystemID = sys_pair.Key
- mSystem = systemList(sSystemID)
- Label8.Text = "System Name: " & sys_pair.Value.FileName
- Label9.Text = "System Type: " & sys_pair.Value.TLType
- Label10.Text = "System Version: " & sys_pair.Value.Version
- Next
- '############################### INTERFACE INFO ###############################
- interfaceList = mSystem.Interfaces
- interfaceList.Refresh(100)
- Label2.Text = "Inerfaces count: " & interfaceList.Count
- For Each ifc_pair As KeyValuePair(Of String, BGAPI2.Interface) In interfaceList
- ifc_pair.Value.Open()
- sInterfaceID = ifc_pair.Key
- mInterface = interfaceList(sInterfaceID)
- Label11.Text = "Interface ID: " & ifc_pair.Value.Id
- Label12.Text = "Interface Type: " & ifc_pair.Value.TLType
- Label13.Text = "Interface Name: " & ifc_pair.Value.DisplayName
- Next
- '############################### DEVICE INFO ###############################
- deviceList = mInterface.Devices
- deviceList.Refresh(100)
- Label3.Text = "Detected Devices: " & deviceList.Count
- For Each dev_pair As KeyValuePair(Of String, BGAPI2.Device) In deviceList
- dev_pair.Value.Open()
- sDeviceID = dev_pair.Key
- mDevice = deviceList(sDeviceID)
- Label14.Text = "Device ID: " & dev_pair.Key
- Label15.Text = "Device Model: " & dev_pair.Value.Model
- Label16.Text = "Device Serial Number: " & dev_pair.Value.SerialNumber
- Label17.Text = "Device Vendor: " & dev_pair.Value.Vendor
- Label18.Text = "Device TLType: " & dev_pair.Value.TLType
- Label19.Text = "Device UserID: " & dev_pair.Value.DisplayName
- If dev_pair.Value.TLType = "GEV" Then
- mDeviceNodeList = dev_pair.Value.NodeList
- iDeviceIPAddress = mDeviceNodeList("GevDeviceIPAddress").Value
- Label21.Text = "Device IP Address: " & iDeviceIPAddress
- End If
- Next
- '############################### DATASTREAM INFO ###############################
- datastreamList = mDevice.DataStreams
- datastreamList.Refresh()
- Label4.Text = "Detected datastreams: " & datastreamList.Count
- For Each dst_pair As KeyValuePair(Of String, BGAPI2.DataStream) In datastreamList
- dst_pair.Value.Open()
- sDataStreamID = dst_pair.Key
- mDataStream = datastreamList(sDataStreamID)
- Label20.Text = "DataStream ID: " & dst_pair.Key
- Next
- '############################### BUFFER INFO ###############################
- bufferList = mDataStream.BufferList
- For i = 0 To 3
- mBuffer = New BGAPI2.Buffer()
- bufferList.Add(mBuffer)
- Next
- Label5.Text = "Announced buffers: " & bufferList.Count
- For Each buf_pair As KeyValuePair(Of String, BGAPI2.Buffer) In bufferList
- buf_pair.Value.QueueBuffer()
- Next
- Label6.Text = "Queued buffers: " & bufferList.Count
- '############################### IMAGE ACQUISITION ###############################
- mDataStream.StartAcquisition()
- mDevice.RemoteNodeList("AcquisitionStart").Execute()
- Dim mBufferFilled As BGAPI2.Buffer
- mBufferFilled = mDataStream.GetFilledBuffer(1000)
- Label7.Text = " Image{0} " & mBufferFilled.FrameID
- '############################### STOP CAMERA & RELEASE RESOURCES ###############################
- mDevice.RemoteNodeList("AcquisitionStop").Execute()
- mDataStream.StopAcquisition()
- bufferList.DiscardAllBuffers()
- While bufferList.Count > 0
- mBuffer = bufferList.Values.First()
- bufferList.RevokeBuffer(mBuffer)
- End While
- mDataStream.Close()
- mDevice.Close()
- mInterface.Close()
- mSystem.Close()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement