Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. Imports Emgu.CV
  2. Imports Emgu.CV.CvEnum
  3. Imports Emgu.CV.Structure
  4. Imports Emgu.CV.UI
  5. Imports Emgu.CV.Util
  6.  
  7. Imports BGAPI2
  8. Imports BGAPI2.Events
  9. Imports BGAPI2.Exceptions
  10.  
  11. Public Class FrmMain
  12. 'Dim CapImg As New Capture()
  13. 'Dim filename As String
  14.  
  15. Dim systemList As BGAPI2.SystemList
  16. Dim mSystem As BGAPI2.System
  17. Dim sSystemID As String
  18.  
  19. Dim interfaceList As BGAPI2.InterfaceList
  20. Dim mInterface As BGAPI2.Interface
  21. Dim sInterfaceID As String
  22.  
  23. Dim deviceList As BGAPI2.DeviceList
  24. Dim mDevice As BGAPI2.Device
  25. Dim sDeviceID As String
  26.  
  27. Dim datastreamList As BGAPI2.DataStreamList
  28. Dim mDataStream As BGAPI2.DataStream
  29. Dim sDataStreamID As String
  30.  
  31. Dim bufferList As BGAPI2.BufferList
  32. Dim mBuffer As BGAPI2.Buffer
  33.  
  34. Dim mDeviceNodeList As BGAPI2.NodeMap
  35.  
  36. Dim iDeviceIPAddress, iDeviceSubnetMask, iDeviceSubnet, iInterfaceSubnet As Long
  37.  
  38.  
  39. Private Sub FrmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  40. '############################### SYSTEM INFO ###############################
  41. systemList = systemList.Instance
  42. systemList.Refresh()
  43. Label1.Text = "Detected Systems: " & systemList.Count
  44.  
  45. For Each sys_pair As KeyValuePair(Of String, BGAPI2.System) In BGAPI2.SystemList.Instance
  46. sys_pair.Value.Open()
  47. sSystemID = sys_pair.Key
  48. mSystem = systemList(sSystemID)
  49. Label8.Text = "System Name: " & sys_pair.Value.FileName
  50. Label9.Text = "System Type: " & sys_pair.Value.TLType
  51. Label10.Text = "System Version: " & sys_pair.Value.Version
  52. Next
  53.  
  54. '############################### INTERFACE INFO ###############################
  55. interfaceList = mSystem.Interfaces
  56. interfaceList.Refresh(100)
  57. Label2.Text = "Inerfaces count: " & interfaceList.Count
  58.  
  59. For Each ifc_pair As KeyValuePair(Of String, BGAPI2.Interface) In interfaceList
  60. ifc_pair.Value.Open()
  61. sInterfaceID = ifc_pair.Key
  62. mInterface = interfaceList(sInterfaceID)
  63. Label11.Text = "Interface ID: " & ifc_pair.Value.Id
  64. Label12.Text = "Interface Type: " & ifc_pair.Value.TLType
  65. Label13.Text = "Interface Name: " & ifc_pair.Value.DisplayName
  66. Next
  67.  
  68. '############################### DEVICE INFO ###############################
  69. deviceList = mInterface.Devices
  70. deviceList.Refresh(100)
  71. Label3.Text = "Detected Devices: " & deviceList.Count
  72.  
  73. For Each dev_pair As KeyValuePair(Of String, BGAPI2.Device) In deviceList
  74. dev_pair.Value.Open()
  75. sDeviceID = dev_pair.Key
  76. mDevice = deviceList(sDeviceID)
  77. Label14.Text = "Device ID: " & dev_pair.Key
  78. Label15.Text = "Device Model: " & dev_pair.Value.Model
  79. Label16.Text = "Device Serial Number: " & dev_pair.Value.SerialNumber
  80. Label17.Text = "Device Vendor: " & dev_pair.Value.Vendor
  81. Label18.Text = "Device TLType: " & dev_pair.Value.TLType
  82. Label19.Text = "Device UserID: " & dev_pair.Value.DisplayName
  83.  
  84. If dev_pair.Value.TLType = "GEV" Then
  85. mDeviceNodeList = dev_pair.Value.NodeList
  86. iDeviceIPAddress = mDeviceNodeList("GevDeviceIPAddress").Value
  87. Label21.Text = "Device IP Address: " & iDeviceIPAddress
  88. End If
  89. Next
  90.  
  91.  
  92. '############################### DATASTREAM INFO ###############################
  93. datastreamList = mDevice.DataStreams
  94. datastreamList.Refresh()
  95. Label4.Text = "Detected datastreams: " & datastreamList.Count
  96.  
  97. For Each dst_pair As KeyValuePair(Of String, BGAPI2.DataStream) In datastreamList
  98. dst_pair.Value.Open()
  99. sDataStreamID = dst_pair.Key
  100. mDataStream = datastreamList(sDataStreamID)
  101. Label20.Text = "DataStream ID: " & dst_pair.Key
  102. Next
  103.  
  104. '############################### BUFFER INFO ###############################
  105. bufferList = mDataStream.BufferList
  106.  
  107. For i = 0 To 3
  108. mBuffer = New BGAPI2.Buffer()
  109. bufferList.Add(mBuffer)
  110. Next
  111.  
  112. Label5.Text = "Announced buffers: " & bufferList.Count
  113.  
  114.  
  115. For Each buf_pair As KeyValuePair(Of String, BGAPI2.Buffer) In bufferList
  116. buf_pair.Value.QueueBuffer()
  117. Next
  118.  
  119. Label6.Text = "Queued buffers: " & bufferList.Count
  120.  
  121. '############################### IMAGE ACQUISITION ###############################
  122. mDataStream.StartAcquisition()
  123. mDevice.RemoteNodeList("AcquisitionStart").Execute()
  124.  
  125. Dim mBufferFilled As BGAPI2.Buffer
  126.  
  127. mBufferFilled = mDataStream.GetFilledBuffer(1000)
  128.  
  129. Label7.Text = " Image{0} " & mBufferFilled.FrameID
  130.  
  131. '############################### STOP CAMERA & RELEASE RESOURCES ###############################
  132. mDevice.RemoteNodeList("AcquisitionStop").Execute()
  133. mDataStream.StopAcquisition()
  134. bufferList.DiscardAllBuffers()
  135.  
  136. While bufferList.Count > 0
  137. mBuffer = bufferList.Values.First()
  138. bufferList.RevokeBuffer(mBuffer)
  139. End While
  140.  
  141. mDataStream.Close()
  142. mDevice.Close()
  143. mInterface.Close()
  144. mSystem.Close()
  145.  
  146. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement