异常错误:对象的类型必须是 __ComObject 或是从 __ComObject 派生。在线等。。谢谢

飞飞234 飞飞234 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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 派生。

不加,也有错误,好像是内存读写错误的问题
...全文
评论 1
收藏 已收藏
分享
返回顶部
飞飞234
C# 111,129 成员 642,538 内容