Reference MvCameraControl.Net.dll, halconDotNet.dll in both projects
halcon.dll and hcanvas.dll should be present in the UI project's binary directory
Basic workflow
Call HKCameraManager.ScanForAttachedCameras and all attached cameras will be available via HKCameraManager.AttachedCameras
The class CameraViewModel asbstract functionality of a HKCamera and provide 4 major APIs:
varcamera1= HKCameraManager.AttachedCameras[0];
camera1.ImageAcquired +=image =>{//Your image processing logic here};// Open the camera
camera1.Open();// Start grabbing
camera1.GrabStart();// Stop grabbing
camera1.GrabStop();// Close camera
camera1.Close();
Real time mode and trigger source demo
// Turn off continuous mode
camera1.RealTimeMode =false;// Set trigger source to software
camera1.TriggerSourceType = CameraTriggerSourceType.Software
// Software trigger
camera1.SoftwareExecuteOnce();
For WPF users that follow MVVM pattern, the following bindings help you manage all the camera logics
/// <summary>/// Toggle grab start and stop/// </summary>publicboolIsGrabbing{
get {return_isGrabbing;}
set
{_isGrabbing=value;// Do not do anything meaningful before construction finishedif(value) GrabStart();else GrabStop();}}/// <summary>/// Trigger source/// </summary>publicCameraTriggerSourceTypeTriggerSourceType{
get {return_triggerSourceType;}
set
{if(value== CameraTriggerSourceType.None)return;_triggerSourceType=value;uintflag=(uint)(value== CameraTriggerSourceType.Line0 ?0:7);
_myCamera.MV_CC_SetEnumValue_NET("TriggerSource", flag);}}/// <summary>/// True to realtime mode/// False to trigger mode/// </summary>publicboolRealTimeMode{
get {return_realTimeMode;}
set
{_realTimeMode=value;uintflag=(uint)(value?0:1);
_myCamera.MV_CC_SetEnumValue_NET("TriggerMode", flag);if(value)return;// If realtime is off, reactivate trigger source
ReactivateTriggerSource();}}