/// <summary> /// PTZ 控制 开始 /// </summary> /// <param name="nvr"></param> /// <param name="cha"></param> /// <param name="dir"></param> /// <param name="speed"></param> void NvrInterface.nvrPtzStart(int session, int cha, PTZ_DIR dir, int speed) { int d = 0; int sp = (int)(speed * 0.7); switch (dir) { case PTZ_DIR.UP: d = 21; break; case PTZ_DIR.RIGHT: d = 24; break; case PTZ_DIR.DOWN: d = 22; break; case PTZ_DIR.LEFT: d = 23; break; case PTZ_DIR.UP_RIGHT: d = 26; break; case PTZ_DIR.DOWN_RIGHT: d = 28; break; case PTZ_DIR.DONN_LEFT: d = 27; break; case PTZ_DIR.UP_LEFT: d = 25; break; } CHCNetSDK.NET_DVR_PTZControlWithSpeed_Other(session - 1, cha, d, 0, sp); }
/// <summary> /// PTZ控制开始 /// </summary> /// <param name="nvr"></param> /// <param name="channel"></param> /// <param name="dir"></param> /// <param name="speed"></param> public void ptzCtlStart(int nvr, int channel, PTZ_DIR dir, int speed) { NVR_INFO nvrInfo = (NVR_INFO)nvrConfig[nvr]; if (nvrInfo == null) { return; } if (nvrInfo.session < 1) { return; } NvrInterface nvrAdp = (NvrInterface)nvrAdapters[nvrInfo.type]; if (nvrAdp == null) { return; } nvrAdp.nvrPtzStart(nvrInfo.session, channel, dir, speed); }
/// <summary> /// 视频鼠移动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void videoBox_MouseMove(object sender, MouseEventArgs e) { // 中心点 int m_x = this.Width / 2; int m_y = this.Height / 2; // 角度 -180~+180 double angle = 180 * Math.Atan2(m_y - e.Y, e.X - m_x) / Math.PI; if (angle >= -22.5 && angle < 22.5) { this.Cursor = this.cur_right; ptzDirection = PTZ_DIR.RIGHT; } else if (angle >= 22.5 && angle < 67.5) { this.Cursor = this.cur_up_right; ptzDirection = PTZ_DIR.UP_RIGHT; } else if (angle >= 67.5 && angle < 112.5) { this.Cursor = this.cur_up; ptzDirection = PTZ_DIR.UP; } else if (angle >= 112.5 && angle < 167.5) { this.Cursor = this.cur_up_left; ptzDirection = PTZ_DIR.UP_LEFT; } else if (angle >= 167.5 || angle <= -167.5) { this.Cursor = this.cur_left; ptzDirection = PTZ_DIR.LEFT; } else if (angle < -22.5 && angle >= -67.5) { this.Cursor = this.cur_down_right; ptzDirection = PTZ_DIR.DOWN_RIGHT; } else if (angle < -67.5 && angle >= -112.5) { this.Cursor = this.cur_down; ptzDirection = PTZ_DIR.DOWN; } else if (angle < -112.5 && angle >= -167.5) { this.Cursor = this.cur_down_left; ptzDirection = PTZ_DIR.DONN_LEFT; } // 距离中心的距离(1~10),表示PTZ速度 double i = Math.Sqrt(Math.Pow(e.X - m_x, 2) + Math.Pow(e.Y - m_y, 2)); int d = (int)((i / m_y) * 10); if (d <= 10) { ptzSpeed = d; } else { ptzSpeed = 10; } }