C# 天敏 SDK3000 二次开发时出的问题?? 求解

 C# SDK3000 OCX组件二次开发时出的问题?? 求解

这是动态检测触发条件 

private void btnStartTest_Click(object sender, EventArgs e)
        {
            byte[] bytes = new byte[]{1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,25,25,25,25,25,25,25};
            string mapSize = Encoding.ASCII.GetString(bytes);
            Int32 iMotionDetect =  SDK3000ApiClass.GetMotionDetectDelegate();

            axSDK3000.EnableMotionDetect(mapSize, bytes.Length, 10, iMotionDetect);
        
        }

SDK3000ApiClass.GetMotionDetectDelegate();这是获取的指针的结果 如下:

  public static Int32 GetMotionDetectDelegate()
        {


            VCAPrcCbMotionDetectInvoke icPic = new VCAPrcCbMotionDetectInvoke(VCAPrcCbMotionDetect);
            return Marshal.GetFunctionPointerForDelegate(icPic).ToInt32();
        }

这里是委托的声明

 public delegate void VCAPrcCbMotionDetectInvoke(int dwCard, bool bMove, ref int lpContext);

 

下面是委托实例 ,每次调用的时候总是说 引用的内存为written / read 然后就崩溃拉

不知道是不是我的参数有问题,还是委托转指针用的方法不正确,请大家帮我看看,

月底要交项目,急啊,我的QQ:379446670,邮箱:520philip@163.com

请大家帮我看看

        /// <summary>
        /// 动态检测回调
        /// </summary>
        /// <param name="dwCard"></param>
        /// <param name="bMove"></param>
        /// <param name="lpContext"></param>
        public static void VCAPrcCbMotionDetect(int dwCard, bool bMove, ref int lpContext)
        {
            MessageBox.Show("MessageBoxShow!");
        }

*******************************************************************************************

 下面是使用DLL的方式

*******************************************************************************************

Com的方法不行我就改用C++ DLL调用的方法,但是结果还是在这里出问题

 public static int MotionDetectI(int nCards, bool bEnaDetect, byte[] pAreaMap, long nSizeOfMap, long nPersistTime, ref string lpContext)
        {
            VCAPrcCbMotionDetectInvoke icPic = new VCAPrcCbMotionDetectInvoke(VCAPrcCbMotionDetect);
            return VCAEnableMotionDetect(nCards, bEnaDetect, ref pAreaMap,
                nSizeOfMap, nPersistTime,ref lpContext, icPic);
        }

 

 [DllImport("sdk3000_7130.dll")]
        public static extern int VCAEnableMotionDetect(int nCards, bool bEnaDetect,ref byte[] pAreaMap, long nSizeOfMap, long nPersistTime,ref string lpContext, VCAPrcCbMotionDetectInvoke Tp);

 

  public delegate void VCAPrcCbMotionDetectInvoke(int dwCard, bool bMove, ref int lpContext);

 

/// <summary>
        /// 动态检测回调
        /// </summary>
        /// <param name="dwCard"></param>
        /// <param name="bMove"></param>
        /// <param name="lpContext"></param>
        public static void VCAPrcCbMotionDetect(int dwCard, bool bMove, ref int lpContext)
        {
            MessageBox.Show("MessageBoxShow!");
        }

 

Callback的时候老是出问题???

 

希望大家帮帮我,太难拉,搞拉两个星期,都没什么气色 ,月底工期就满拉,急求助

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码者人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值