1 using System;
2 using Systemollections.Generic;
3 using SystemponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using Cognex.VisionPro;
10 using Cognex.VisionPro.ImageFile;
11 using System.IO;
12 using PylonC.NET;
13 using System.Runtime.InteropServices;
14 using System.Threading;
15
16 namespace Demo
17
36
37 private void DisplayImage(object sender, EventArgs e)
38
45
46 }
47
48
49 private void StopPlay_button_Click(object sender, EventArgs e)
50
57
58
59 //线程回调函数
60 public void ThreadFunction()
61
89 }
90
91
92 ///balser sdk/
93 private PYLON_DEVICE_HANDLE hDev = new PYLON_DEVICE_HANDLE(); /* Handle for the pylon device. */
94 private uint numDevices; /* Number of available devices. */
95 private const int numGrabs = 1000; /* Number of images to grab. */
96 private PylonBuffer<Byte> imgBuf = null; /* Buffer used for grabbing. */
97
98 //打开相机
99 public void OpenCameraSoftTrigger()
100
113 else
114
118
119 /* Before using the device, it must be opened. Open it for configuring parameters and for grabbing images. */
120 Pylon.DeviceOpen(hDev, PylonPylonAccessModeControl | PylonPylonAccessModeStream);
121
122 /* Set the pixel format to Mono8, where gray values will be output as 8 bit values for each pixel. */
123 /* ... Check first to see if the device supports the Mono8 format. */
124 isAvail = Pylon.DeviceFeatureIsAvailable(hDev, "EnumEntry_PixelFormat_Mono8");
125
126 if (!isAvail)
127
131
132 /* ... Set the pixel format to Mono8. */
133 Pylon.DeviceFeatureFrString(hDev, "PixelFormat", "Mono8");
134
135 /* Disable acquisition start trigger if available. */
136 isAvail = Pylon.DeviceFeatureIsAvailable(hDev, "EnumEntry_TriggerSelector_AcquisitionStart");
137 if (isAvail)
138
142
143
144 /* Disable frame burst start trigger if available */
145 isAvail = Pylon.DeviceFeatureIsAvailable(hDev, "EnumEntry_TriggerSelector_FrameBurstStart");
146 if (isAvail)
147
151
152 /* Disable frame start trigger if available */
153 isAvail = Pylon.DeviceFeatureIsAvailable(hDev, "EnumEntry_TriggerSelector_FrameStart");
154 if (isAvail)
155
159
160 /* For GigE cameras, we recmend increasing the packet size for better
161 performance. If the network adapter supports jumbo frames, set the packet
162 size to a value > 1500, e.g., to 8192. In this sample, we only set the packet size
1 to 1500. */
164 /* ... Check first to see if the GigE camera packet size parameter is supported and if it is writable. */
165 isAvail = Pylon.DeviceFeatureIsWritable(hDev, "GevSCPSPacketSize");
166
167 if (isAvail)
168
172
173 }
174
175
176 //采集单张图像
177 public void SnapAcquisitionSoftTrigger(ref byte[] ImageBufferPtr)
178
195 else
196
199
200 }
201
202 }
203 }
上一篇:VisionPro PMAlign基本使用
下一篇:显微镜分辨率:概念、因素和计算
C VisionPro









