异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。在线等。。谢谢
飞飞234 2015-10-16 03:04:23 public int GetSingleResult(IntPtr pImage, int iLength, out string plate, out int color, out int plateX, out int plateY, out int plateWidth, out int plateHeight)
{
int num5;
try
{
int num = 1;
int cb = Marshal.SizeOf(typeof(CTVPlateRec.PIC_RESULTEX));
IntPtr ptr = Marshal.AllocHGlobal(cb);
Marshal.ReleaseComObject(cb);
int iImageWidth = 0;
int iImageHight = 0;
num = CTVPlateRec.CentrVideo_GetPicResult(pImage, iLength, ref iImageWidth, ref iImageHight, ptr);
CTVPlateRec.PIC_RESULTEX pic_resultex = (CTVPlateRec.PIC_RESULTEX) Marshal.PtrToStructure(ptr, typeof(CTVPlateRec.PIC_RESULTEX));
plate = pic_resultex.szPlateString;
color = pic_resultex.carColor;
plateHeight = pic_resultex.sPlateRect.bottom - pic_resultex.sPlateRect.top;
plateWidth = pic_resultex.sPlateRect.right - pic_resultex.sPlateRect.left;
plateX = pic_resultex.sPlateRect.left;
plateY = iImageHight - pic_resultex.sPlateRect.bottom;
log.Debug("车牌识别返回值:" + num);
log.Debug("车牌识别结果:" + pic_resultex.szPlateString);
Marshal.FreeHGlobal(ptr);
num5 = num;
}
catch (Exception)
{
log.Error("车牌识别错误");
throw;
}
return num5;
其中 Marshal.ReleaseComObject(cb); 这句加了 是异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。
不加,也有错误,好像是内存读写错误的问题