当前位置:网站首页>Visual upper system design and development (Halcon WinForm) -5 camera
Visual upper system design and development (Halcon WinForm) -5 camera
2022-07-03 15:18:00 【11eleven】
Visual hardware input core camera , There are many kinds of cameras , Basically equipped with callable SDK, Used to set some basic parameters , And trigger image output . This paper takes Haikang virtual camera as an example .
Official of Haikang DEMO as follows :
int nRet;
// ch: Create device list || en: Create device list
System.GC.Collect();
cbDeviceList.Items.Clear();
nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_pDeviceList);
if (MyCamera.MV_OK != nRet)
{
MessageBox.Show("Enum Devices Fail");
return;
}
// ch: Display the device name in the form list || Display the device'name on window's list
for (int i = 0; i < m_pDeviceList.nDeviceNum; i++)
{
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
{
IntPtr buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stGigEInfo, 0);
MyCamera.MV_GIGE_DEVICE_INFO gigeInfo = (MyCamera.MV_GIGE_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
if (gigeInfo.chUserDefinedName != "")
{
cbDeviceList.Items.Add("GigE: " + gigeInfo.chUserDefinedName + " (" + gigeInfo.chSerialNumber + ")");
}
else
{
cbDeviceList.Items.Add("GigE: " + gigeInfo.chManufacturerName + " " + gigeInfo.chModelName + " (" + gigeInfo.chSerialNumber + ")");
}
}
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
{
IntPtr buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stUsb3VInfo, 0);
MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_USB3_DEVICE_INFO));
if (usbInfo.chUserDefinedName != "")
{
cbDeviceList.Items.Add("USB: " + usbInfo.chUserDefinedName + " (" + usbInfo.chSerialNumber + ")");
}
else
{
cbDeviceList.Items.Add("USB: " + usbInfo.chManufacturerName + " " + usbInfo.chModelName + " (" + usbInfo.chSerialNumber + ")");
}
}
}
//.ch: Choose the first || en: Select the first item
if (m_pDeviceList.nDeviceNum != 0)
{
cbDeviceList.SelectedIndex = 0;
}Initialization equipment .
//ch: Get the selected device information | en:Get selected device information
MyCamera.MV_CC_DEVICE_INFO device =
(MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[cbDeviceList.SelectedIndex],
typeof(MyCamera.MV_CC_DEVICE_INFO));
nRet = m_pMyCamera.MV_CC_CreateDevice_NET(ref device);
if (MyCamera.MV_OK != nRet)
{
return;
}
// ch: Turn on the device | en:Open device
nRet = m_pMyCamera.MV_CC_OpenDevice_NET();
if (MyCamera.MV_OK != nRet)
{
MessageBox.Show("Open Device Fail");
return;
}
// ch: Set the trigger mode to off || en:set trigger mode as off
m_pMyCamera.MV_CC_SetEnumValue_NET("AcquisitionMode", 2);
m_pMyCamera.MV_CC_SetEnumValue_NET("TriggerMode", 0);Turn on the device , And set the trigger mode . There are generally two modes , Continuous trigger , That is, each frame is returned , Trigger mode is to trigger and return once . Trigger mode is selected in general application scenarios .
if (m_bGrabbing)
{
m_bGrabbing = false;
// ch: Stop capturing || en:Stop grab image
m_pMyCamera.MV_CC_StopGrabbing_NET();
// ch: Control operation || en: Control operation
SetCtrlWhenStopGrab();
}
// ch: Turn off the device || en: Close device
m_pMyCamera.MV_CC_CloseDevice_NET();Remember to close when the program is closed or the camera is not in use , Otherwise, the equipment will be occupied , It will not be available next time , Only reset to initialize .
complete DEMO But in Haikang MVS Found under the software .

The design idea of camera management is roughly the same as that of previous communication , Provide functions added by camera , Package the camera SDK Provide equipment list , Right camera SN Binding , Finally, load according to the configuration .

public class CameraDeviceModel
{
public long Id { set; get; }
/// <summary>
/// equipment SN
/// </summary>
public string Sn { set; get; }
public string Name { set; get; }
public bool IsActive { set; get; } = true;
public string CameraType { set; get; }
/// <summary>
/// Communication type
/// </summary>
public CameraCommunicationTypeEnum CommunicationType { set; get; } = CameraCommunicationTypeEnum.Gige;
public CameraTypeEnum Type { set; get; }
public CameraCollectTypeEnum CameraCollectType { set; get; } = CameraCollectTypeEnum.Trigger;
public FileFormatEnum FileFormat { set; get; } = FileFormatEnum.BMP;
/// <summary>
/// time of exposure
/// </summary>
public decimal ExposureTime { set; get; }
public decimal Gain { set; get; }// gain
/// <summary>
/// Frame rate
/// </summary>
public decimal FrameRate { set; get; }
}
边栏推荐
- Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
- Halcon与Winform学习第二节
- Jvm-04-runtime data area heap, method area
- What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
- Kubernetes - yaml file interpretation
- Global and Chinese markets of AC electromechanical relays 2022-2028: Research Report on technology, participants, trends, market size and share
- Popular understanding of linear regression (I)
- 函数栈帧的创建和销毁
- Using notepad++ to build an arbitrary language development environment
- Zero copy underlying analysis
猜你喜欢

Kubernetes advanced training camp pod Foundation
![[pytorch learning notes] datasets and dataloaders](/img/c0/9cd539caff34db3cccc44505bbe3c5.png)
[pytorch learning notes] datasets and dataloaders

Série yolov5 (i) - - netron, un outil de visualisation de réseau
![[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer](/img/9b/6ca8375ef8689a80d437665909ae30.png)
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer

Solve the problem that pushgateway data will be overwritten by multiple push

Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
![[wechat applet] wxss template style](/img/28/f9d12bf761e25f9564d92697cf049d.png)
[wechat applet] wxss template style

There are links in the linked list. Can you walk three steps faster or slower

【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器

Reentrantlock usage and source code analysis
随机推荐
Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
Influxdb2 sources add data sources
Qt常用语句备忘
Relationship between truncated random distribution and original distribution
qt使用QZxing生成二维码
The method of parameter estimation of user-defined function in MATLAB
Mmdetection learning rate and batch_ Size relationship
视觉上位系统设计开发(halcon-winform)-6.节点与宫格
Global and Chinese market of transfer case 2022-2028: Research Report on technology, participants, trends, market size and share
App全局异常捕获
Jvm-02-class loading subsystem
Halcon与Winform学习第二节
[wechat applet] wxss template style
Introduction, use and principle of synchronized
Chapter 04_ Logical architecture
基于SVN分支开发模式流程浅析
Idea does not specify an output path for the module
Neon global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
There are links in the linked list. Can you walk three steps faster or slower