当前位置:网站首页>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; }
}
边栏推荐
- High quality workplace human beings must use software to recommend, and you certainly don't know the last one
- Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
- Summary of JVM knowledge points
- 【pytorch学习笔记】Datasets and Dataloaders
- 什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
- 函数栈帧的创建和销毁
- The markdown file obtains the pictures of the network and stores them locally and modifies the URL
- leetcode_ Power of Four
- Jvm-02-class loading subsystem
- Win10 enterprise 2016 long term service activation tutorial
猜你喜欢
Summary of JVM knowledge points
Dataframe returns the whole row according to the value
Jvm-09 byte code introduction
Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
GCC cannot find the library file after specifying the link library path
Didi off the shelf! Data security is national security
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
Pytoch deep learning and target detection practice notes
Functional modules and application scenarios covered by the productization of user portraits
【注意力机制】【首篇ViT】DETR,End-to-End Object Detection with Transformers网络的主要组成是CNN和Transformer
随机推荐
Unity hierarchical bounding box AABB tree
redis单线程问题强制梳理门外汉扫盲
The method of parameter estimation of user-defined function in MATLAB
Dataframe returns the whole row according to the value
Enable multi-threaded download of chrome and edge browsers
Redis cache penetration, cache breakdown, cache avalanche solution
Kubernetes advanced training camp pod Foundation
Introduction to redis master-slave, sentinel and cluster mode
【pytorch学习笔记】Datasets and Dataloaders
【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
开启 Chrome 和 Edge 浏览器多线程下载
Redis主从、哨兵、集群模式介绍
【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
Use of Tex editor
Global and Chinese market of solder bars 2022-2028: Research Report on technology, participants, trends, market size and share
Kubernetes帶你從頭到尾捋一遍
Summary of concurrent full knowledge points
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
Chapter 04_ Logical architecture