当前位置:网站首页>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; }
}
边栏推荐
- Explanation of time complexity and space complexity
- Using notepad++ to build an arbitrary language development environment
- 基础SQL教程
- Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
- Incluxdb2 buckets create database
- 北京共有产权房出租新规实施的租赁案例
- Yolov5 series (I) -- network visualization tool netron
- 【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
- Global and Chinese market of postal automation systems 2022-2028: Research Report on technology, participants, trends, market size and share
- [pytorch learning notes] datasets and dataloaders
猜你喜欢
qt使用QZxing生成二维码
什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
函数栈帧的创建和销毁
Zero copy underlying analysis
The state does not change after the assignment of El switch
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
视觉上位系统设计开发(halcon-winform)-1.流程节点设计
Construction of operation and maintenance system
What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
随机推荐
Redis cache penetration, cache breakdown, cache avalanche solution
The first character of leetcode sword offer that only appears once (12)
高并发下之redis锁优化实战
Jvm-08-garbage collector
XWiki安装使用技巧
函数栈帧的创建和销毁
官网MapReduce实例代码详细批注
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
Summary of JVM knowledge points
运维体系的构建
Detailed comments on MapReduce instance code on the official website
Remote server background hangs nohup
Basic SQL tutorial
The state does not change after the assignment of El switch
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
Stress test WebService with JMeter
【pytorch学习笔记】Datasets and Dataloaders
el-switch 赋值后状态不变化
Global and Chinese market of iron free motors 2022-2028: Research Report on technology, participants, trends, market size and share
Jvm-04-runtime data area heap, method area