Commit d5eb241b LN

hoimage改为直接返回方式

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