簡體   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