繁体   English   中英

如何通过按钮实现IP摄像机(ONVIF)的RelativeMove

[英]How to implement RelativeMove with buttons to an IP Camera (ONVIF)

有人可以告诉我为什么Up和Down盒可以与按钮完美配合而其他按钮则不能吗? 我尝试了两种不同的方式,一种在左侧的情况下看到,另一种在右侧的情况下看到,但两种方法都不起作用。

 void Move(String direction)
        {
            timer.Enabled = true;
            switch (direction)
            {
                case "Up ":

                    onvifPTZ.RelativeMove(0, 1f, 0, (float)Pan_Speed.Value, (float)Tilt_Speed.Value, (float)Zoom_Speed.Value);
                    break;
                case "Down":
                    onvifPTZ.RelativeMove(0, -1f, 0, (float)Pan_Speed.Value, (float)Tilt_Speed.Value, (float)Zoom_Speed.Value);
                    break;
                case "Left":
                    direction = Direction.Left.ToString();
                    onvifPTZ.RelativeMove((float)Direction.Left, 0, 0, (float)Pan_Speed.Value, (float)Tilt_Speed.Value, (float)Zoom_Speed.Value);
                    break;
                case "Right":

                    onvifPTZ.RelativeMove(-1f, 0, 0, (float)Pan_Speed.Value, (float)Tilt_Speed.Value, (float)Zoom_Speed.Value);
                    break;
            }
        }

这是我的相对Move函数。

 public int RelativeMove(float xTrans, float yTrans, float zTrans, float xSpeed , float ySpeed, float zSpeed)
        {
            // Define Translation Vector
            PTZ.PTZVector ptzTrans = new PTZ.PTZVector()
            {
                PanTilt = new PTZ.Vector2D()
                {
                    x = xTrans,
                    y = yTrans,
                    space = ptzOptions.Spaces.RelativePanTiltTranslationSpace[0].URI,
                },
                Zoom = new PTZ.Vector1D()
                {
                    x = zTrans,
                    //space = ptzOptions.Spaces.RelativeZoomTranslationSpace[0].URI,
                }
            };
            // Define Speed Vector
            PTZ.PTZSpeed ptzSpd = new PTZ.PTZSpeed()
            {
                PanTilt = new PTZ.Vector2D()
                {
                    x = xSpeed,
                    y = ySpeed,
                    //space = ptzOptions.Spaces.RelativePanTiltTranslationSpace[0].URI,
                },
                Zoom = new PTZ.Vector1D()
                {
                    x = zSpeed,
                   // space = ptzOptions.Spaces.RelativeZoomTranslationSpace[0].URI,
                }
            };

            // Move relative along vectore <ptzTrans> with speed <ptzSpd> 
            // Zoom is manipulated with <zSpeed>.
            ptzClient.RelativeMove(profiles[this.selectedProfile].token, ptzTrans, ptzSpd);

            return 0;
        }

如果有人知道我该怎么做才能起作用,请帮助:),如果有人知道如何在我不按按钮时停止运动,告诉我,导致它也无法起作用...我确实实现了并告诉相机停止在那里的运动,但是它完全没有反应。

根据您的描述,我了解到您正在尝试通过速度移动PTZ单元。 但是,这与您在代码中使用的功能RelativeMove不匹配。

根据ONVIF PTZ规格

如果一个PTZ节点支持相对的Pan / Tilt或相对的Zoom移动,则它应支持RelativeMove操作。 此操作的平移参数指定从当前位置到指示PTZ设备移动到的位置的差。 该操作分为可选的“平移/倾斜”元素和可选的“缩放”元素。 如果省略了“平移/倾斜”元素,则当前“平移/倾斜”运动将不受此命令的影响。 缩放元素也是如此。

因此,您有两个选择:

  • 验证ContinuousMove是否满足您所寻找的功能
  • 如果您确实要使用RelativeMove ,请检查ptzOptions.Spaces.RelativePanTiltTranslationSpace[0].URI是什么。 它可能是一个自定义空间,其平移和倾斜范围不同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM