You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

海康威视SDK移动侦测事件回调未触发问题求助

海康威视SDK移动侦测事件回调未触发问题求助

各位大佬好,我现在在尝试用海康威视的SDK监听摄像头的移动侦测事件,目前已经能成功登录摄像头,也完成了监听的初始化,但回调函数始终没有被触发。奇怪的是,我用浏览器访问摄像头的GET /ISAPI/Event/notification/alertStream接口时,能下载到包含所有事件的文件,说明摄像头确实能检测到移动并生成事件数据,只是SDK的回调没起作用。

以下是我的实现代码(核心逻辑正常运行,但收不到事件数据):

public void StartListening(string ipAddress, int port, string username, string password, string listenIP, ushort listenPort)
{
    if (!NET_DVR_Init())
    {
        Console.WriteLine("SDK Init failed");
        return;
    }

    NET_DVR_DEVICEINFO_V30 deviceInfo = new NET_DVR_DEVICEINFO_V30();
    int userID = NET_DVR_Login_V30(ipAddress, port, username, password, ref deviceInfo);
    if (userID < 0)
    {
        Console.WriteLine("Login failed, error: " + NET_DVR_GetLastError());
        NET_DVR_Cleanup();
        return;
    }

    // 启动事件监听
    var callbackfunc = new ALARM_CALLBACK(OnAlarmReceivedCallBack);
    int iListenHandle = NET_DVR_StartListen_V30(listenIP, listenPort, callbackfunc, IntPtr.Zero);
    if (iListenHandle < 0)
    {
        Console.WriteLine("Listen setup failed, error: " + NET_DVR_GetLastError());
        NET_DVR_Logout(userID);
        NET_DVR_Cleanup();
        return;
    }
    else
    {
        Console.WriteLine("Listen Setup success");
    }

    Console.WriteLine("Listening for motion detection events...");
    Console.WriteLine("Press any key to close connection");
    Console.ReadLine(); // 保持程序运行

    NET_DVR_Logout(userID);
    NET_DVR_Cleanup();
}

我已经尝试过的排查步骤:

  • 验证了登录凭证和网络连接都正常
  • 确认摄像头确实能检测到移动(通过alertStream接口的文件内容确认)
  • 检查过alertStream接口的事件活动,确实有移动事件生成

另外我的摄像头配置如下:

  • 事件->移动侦测
    • 启用移动侦测:是
    • 启用动态分析:是
    • 布防计划:全天
    • 联动动作->通知监控中心:是
  • 网络->高级设置
    • 报警主机IP:192.x.x.x(和监听的listenIP一致)
    • 报警主机端口:5055(和监听的listenPort一致)

想请教各位:为什么我的回调函数没有被调用?是不是还有什么SDK相关的配置步骤我漏掉了?比如需要额外给用户ID配置布防,或者回调函数的定义有什么要求?

火山引擎 最新活动