当前位置:网站首页>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; }
}
边栏推荐
- redis单线程问题强制梳理门外汉扫盲
- Using Tengine to solve the session problem of load balancing
- Kubernetes - yaml file interpretation
- Didi off the shelf! Data security is national security
- Jvm-02-class loading subsystem
- [probably the most complete in Chinese] pushgateway entry notes
- 【pytorch学习笔记】Transforms
- Relationship between truncated random distribution and original distribution
- What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
- Apache ant extension tutorial
猜你喜欢

Popular understanding of linear regression (I)
![MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)

Jvm-05-object, direct memory, string constant pool

Zero copy underlying analysis

mysql innodb 存储引擎的特性—行锁剖析

Reentrantlock usage and source code analysis

【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention

C语言刷题~Leetcode与牛客网简单题

百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式

【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
随机推荐
SQL server安装位置改不了
Global and Chinese market of solder bars 2022-2028: Research Report on technology, participants, trends, market size and share
Final review points of human-computer interaction
Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
【可能是全中文网最全】pushgateway入门笔记
Global and Chinese market of trimethylamine 2022-2028: Research Report on technology, participants, trends, market size and share
Use of Tex editor
Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
[probably the most complete in Chinese] pushgateway entry notes
Can‘t connect to MySQL server on ‘localhost‘
Leetcode sword offer find the number I (nine) in the sorted array
Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock
Halcon与Winform学习第二节
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
【注意力机制】【首篇ViT】DETR,End-to-End Object Detection with Transformers网络的主要组成是CNN和Transformer
Jvm-06-execution engine
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
[transform] [practice] use pytoch's torch nn. Multiheadattention to realize self attention
Kubernetes vous emmène du début à la fin
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share