Commit d5eb241b LN

hoimage改为直接返回方式

1 个父辈 df6b8e9d
...@@ -305,11 +305,11 @@ namespace CodeLibrary ...@@ -305,11 +305,11 @@ namespace CodeLibrary
return null; return null;
} }
HObject map; HObject map;
bool result= Camera._cam.CaptureOnImage(camerName,out map); map = Camera._cam.CaptureOnImage(camerName );
if (result&&map == null) if ( map == null)
{ {
Camera._cam.Close(camerName); Camera._cam.Close(camerName);
result = Camera._cam.CaptureOnImage(camerName, out map); map = Camera._cam.CaptureOnImage(camerName );
} }
return map; return map;
} }
...@@ -552,15 +552,15 @@ namespace CodeLibrary ...@@ -552,15 +552,15 @@ namespace CodeLibrary
for (int index = 1; index <= whileCount; index++) for (int index = 1; index <= whileCount; index++)
{ {
task = Task.Factory.StartNew(delegate { //task = Task.Factory.StartNew(delegate {
label5.Text = "扫码测试_" + index; label5.Text = "扫码测试_" + index;
HObject ho_Image = null; HObject ho_Image = null;
try try
{
ho_Image = Camera._cam.CaptureOnImage(camerName );
if ( ho_Image != null)
{ {
bool result = Camera._cam.CaptureOnImage(camerName, out ho_Image);
if (result && ho_Image != null)
{
//ClearPicImg(); //ClearPicImg();
// ShowImage(ho_Image); // ShowImage(ho_Image);
HDLogUtil.info(" 相机【" + camerName + "】获取图片完成,开始扫码"); HDLogUtil.info(" 相机【" + camerName + "】获取图片完成,开始扫码");
...@@ -595,19 +595,19 @@ namespace CodeLibrary ...@@ -595,19 +595,19 @@ namespace CodeLibrary
HDLogUtil.error("ScanDemo[" + index + "]出错:" + ex.ToString()); HDLogUtil.error("ScanDemo[" + index + "]出错:" + ex.ToString());
} }
finally finally
{
if (ho_Image != null)
{ {
if (ho_Image != null) ho_Image.Dispose();
{ ho_Image = null;
ho_Image.Dispose();
ho_Image = null;
}
} }
}
}); //});
task.Wait(); //task.Wait();
//GC.Collect(); //GC.Collect();
//Thread.Sleep(100); //Thread.Sleep(100);
task.Dispose(); //task.Dispose();
Thread.Sleep(5); Thread.Sleep(5);
} }
this.Enabled = true; this.Enabled = true;
......
...@@ -37,8 +37,8 @@ namespace CodeLibrary ...@@ -37,8 +37,8 @@ namespace CodeLibrary
{ {
MessageBox.Show(selCamera); MessageBox.Show(selCamera);
return null; return null;
} }
Camera._cam.CaptureOnImage(camerName,out ho_image); ho_image= Camera._cam.CaptureOnImage(camerName );
return ho_image; return ho_image;
} }
private void btnOpen_Click(object sender, EventArgs e) private void btnOpen_Click(object sender, EventArgs e)
......
...@@ -228,14 +228,14 @@ namespace CodeLibrary ...@@ -228,14 +228,14 @@ namespace CodeLibrary
} }
return null; return null;
} }
public override bool CaptureOnImage(string name,out HObject hoImage) public override HObject CaptureOnImage(string name )
{ {
hoImage = null; HObject hoImage = null;
int index = cameraName.FindIndex(s => s == name); int index = cameraName.FindIndex(s => s == name);
if (index == -1) if (index == -1)
{ {
_errInfo = name + "Not find"; _errInfo = name + "Not find";
return false ; return hoImage;
} }
if (cameraCurr[index] != null) if (cameraCurr[index] != null)
{ {
...@@ -258,7 +258,7 @@ namespace CodeLibrary ...@@ -258,7 +258,7 @@ namespace CodeLibrary
if (!grabResult.IsValid || !grabResult.GrabSucceeded) if (!grabResult.IsValid || !grabResult.GrabSucceeded)
{ {
_errInfo = grabResult.ErrorDescription; _errInfo = grabResult.ErrorDescription;
return false ; return hoImage;
} }
//相机像素数据 //相机像素数据
...@@ -274,19 +274,19 @@ namespace CodeLibrary ...@@ -274,19 +274,19 @@ namespace CodeLibrary
if (hand.IsAllocated) hand.Free(); if (hand.IsAllocated) hand.Free();
_errInfo = "OK"; _errInfo = "OK";
return true ; return hoImage;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_errInfo = ex.Message; _errInfo = ex.Message;
return false ; return hoImage;
} }
finally finally
{ {
// cameraCurr[index].MV_CC_StopGrabbing_NET(); // cameraCurr[index].MV_CC_StopGrabbing_NET();
} }
return false ; return hoImage;
} }
} }
......
...@@ -112,7 +112,7 @@ namespace CodeLibrary ...@@ -112,7 +112,7 @@ namespace CodeLibrary
// public abstract bool GrabContinuous(int index); // public abstract bool GrabContinuous(int index);
// public abstract void GrabStop(int index); // public abstract void GrabStop(int index);
public abstract Bitmap GrabOneImage(string name); public abstract Bitmap GrabOneImage(string name);
public abstract bool CaptureOnImage(string name,out HObject hoImage); public abstract HObject CaptureOnImage(string name );
} }
} }
...@@ -342,15 +342,15 @@ namespace CodeLibrary ...@@ -342,15 +342,15 @@ namespace CodeLibrary
return _image; return _image;
} }
} }
public override bool CaptureOnImage(string name,out HObject hoImage) public override HObject CaptureOnImage(string name )
{ {
hoImage = null; HObject hoImage = null;
int index = cameraName.FindIndex(s => s == name); int index = cameraName.FindIndex(s => s == name);
if (index == -1) if (index == -1)
{ {
_errInfo = name + "Not find"; _errInfo = name + "Not find";
HDLogUtil.error("CaptureOnImage [" + name + "] error : " + _errInfo); HDLogUtil.error("CaptureOnImage [" + name + "] error : " + _errInfo);
return false ; return hoImage;
} }
if (cameraCurr[index] != null) if (cameraCurr[index] != null)
{ {
...@@ -369,7 +369,7 @@ namespace CodeLibrary ...@@ -369,7 +369,7 @@ namespace CodeLibrary
{ {
_errInfo = "Can not grab one : " + rtn; _errInfo = "Can not grab one : " + rtn;
HDLogUtil.error("CaptureOnImage [" + name + "] error : " + _errInfo); HDLogUtil.error("CaptureOnImage [" + name + "] error : " + _errInfo);
return false ; return hoImage;
} }
int nRet = cameraCurr[index].MV_CC_GetImageBuffer_NET(ref FrameInfo, 1000); int nRet = cameraCurr[index].MV_CC_GetImageBuffer_NET(ref FrameInfo, 1000);
...@@ -391,7 +391,7 @@ namespace CodeLibrary ...@@ -391,7 +391,7 @@ namespace CodeLibrary
} }
} }
//return ho_Imagetemp; //return ho_Imagetemp;
return true; return hoImage;
} }
else else
{ {
...@@ -401,7 +401,7 @@ namespace CodeLibrary ...@@ -401,7 +401,7 @@ namespace CodeLibrary
catch (Exception ex) catch (Exception ex)
{ {
_errInfo = ex.Message; _errInfo = ex.Message;
return false ; return hoImage;
} }
finally finally
{ {
...@@ -415,7 +415,7 @@ namespace CodeLibrary ...@@ -415,7 +415,7 @@ namespace CodeLibrary
HDLogUtil.error(" [" + name + "] MV_CC_FreeImageBuffer_NET 出错:" + ex.ToString()); HDLogUtil.error(" [" + name + "] MV_CC_FreeImageBuffer_NET 出错:" + ex.ToString());
} }
} }
return false ; return hoImage;
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!