|
|
@ -57,6 +57,10 @@ namespace Rs.MotionPlat
|
|
|
|
double matchResultScore = 0.0;
|
|
|
|
double matchResultScore = 0.0;
|
|
|
|
string LightName = "";
|
|
|
|
string LightName = "";
|
|
|
|
bool bGrab = false;
|
|
|
|
bool bGrab = false;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 自定义拍照事件
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public event Action CustomDefineGrabEvent;
|
|
|
|
public CameraTemplate()
|
|
|
|
public CameraTemplate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
@ -264,16 +268,24 @@ namespace Rs.MotionPlat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void btnGrab_Click(object sender, EventArgs e)
|
|
|
|
private void btnGrab_Click(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ImageProcess.ClearManualTrigger();
|
|
|
|
|
|
|
|
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
|
|
|
|
|
|
|
|
bGrabContinue = false;
|
|
|
|
|
|
|
|
if (CustomDefineGrabEvent!=null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CustomDefineGrabEvent?.Invoke();
|
|
|
|
|
|
|
|
LoadImage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LightName = SysConfigParam.GetValue<string>(cameraName + "LightName");
|
|
|
|
LightName = SysConfigParam.GetValue<string>(cameraName + "LightName");
|
|
|
|
if (!string.IsNullOrEmpty(LightName))
|
|
|
|
if (!string.IsNullOrEmpty(LightName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(cameraName))
|
|
|
|
if (!string.IsNullOrEmpty(cameraName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImageProcess.ClearManualTrigger();
|
|
|
|
|
|
|
|
bGrabContinue = false;
|
|
|
|
|
|
|
|
bGrab = true;
|
|
|
|
bGrab = true;
|
|
|
|
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
|
|
|
|
|
|
|
|
if (ManualGrab == null)
|
|
|
|
if (ManualGrab == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IoManager.Instance.WriteOut(LightName, 0);
|
|
|
|
IoManager.Instance.WriteOut(LightName, 0);
|
|
|
@ -300,6 +312,8 @@ namespace Rs.MotionPlat
|
|
|
|
Msg.ShowError("未设置相机对应的光源,请到变量中配置!");
|
|
|
|
Msg.ShowError("未设置相机对应的光源,请到变量中配置!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
bool bGrabContinue = false;
|
|
|
|
bool bGrabContinue = false;
|
|
|
|
|
|
|
|
|
|
|
|
public void StopGrab()
|
|
|
|
public void StopGrab()
|
|
|
@ -307,13 +321,36 @@ namespace Rs.MotionPlat
|
|
|
|
bGrabContinue = false;
|
|
|
|
bGrabContinue = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void btnGrabContinue_Click(object sender, EventArgs e)
|
|
|
|
private void btnGrabContinue_Click(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bGrabContinue = !bGrabContinue;
|
|
|
|
|
|
|
|
if (bGrabContinue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
btnGrabContinue.Text = "停止取图";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
btnGrabContinue.Text = "连续取图";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CustomDefineGrabEvent!=null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Task.Run(() => {
|
|
|
|
|
|
|
|
while (bGrabContinue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bGrab = true;
|
|
|
|
|
|
|
|
ImageProcess.ClearManualTrigger();
|
|
|
|
|
|
|
|
CustomDefineGrabEvent?.Invoke();
|
|
|
|
|
|
|
|
LoadImage();
|
|
|
|
|
|
|
|
Thread.Sleep(300);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LightName = SysConfigParam.GetValue<string>(cameraName + "LightName");
|
|
|
|
LightName = SysConfigParam.GetValue<string>(cameraName + "LightName");
|
|
|
|
if (!string.IsNullOrEmpty(cameraName))
|
|
|
|
if (!string.IsNullOrEmpty(cameraName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
|
|
|
|
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
|
|
|
|
bGrabContinue = !bGrabContinue;
|
|
|
|
//bGrabContinue = !bGrabContinue;
|
|
|
|
|
|
|
|
|
|
|
|
Task.Run(() => {
|
|
|
|
Task.Run(() => {
|
|
|
|
while (bGrabContinue)
|
|
|
|
while (bGrabContinue)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -331,6 +368,13 @@ namespace Rs.MotionPlat
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnVisibleChanged(EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base.OnVisibleChanged(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadImage()
|
|
|
|
private void LoadImage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Stopwatch time = new Stopwatch();
|
|
|
|
Stopwatch time = new Stopwatch();
|
|
|
|