Example #1
0
 private void updateTrack(bool first)
 {
     if (_tracking != null)
     {
         VideoParser.Video video = getNearestVideo(_tracking.Lat, _tracking.Lon);
         if (video != null)
         {
             _trackVideoForm.SetVideoID(video.Id, video.Name);
             if (first)
             {
                 _trackVideoForm.Show();
                 updateCCTVFormOwner();
             }
             double    elapsed      = (DateTime.Now - _tracking.UpdateTime).TotalSeconds + _adjustment.Latency;
             double    delta        = _tracking.SOG / 216000.0 * elapsed;
             double    dy           = delta * Math.Sin((90 - _tracking.COG) * Math.PI / 180.0);
             double    dx           = delta * Math.Cos((90 - _tracking.COG) * Math.PI / 180.0);
             double    latitude     = _tracking.Lat + dy;
             double    longitude    = _tracking.Lon + dx / Math.Cos(latitude * Math.PI / 180.0);
             const int targetLength = 40;
             track(video.Id, _tracking.GetType().ToString(), _tracking.GetId(),
                   longitude, latitude, _adjustment.Height, first ? targetLength : 0, targetLength);
         }
     }
 }
Example #2
0
 private void addTrackVideo(VideoParser.Video video)
 {
     if (isTrackable(video))
     {
         _trackVideos.Add(video.Id, video);
     }
 }
        private StreamInfo[] getStreamInfos(VideoParser.Video video, int channel)
        {
            List <StreamInfo> streamList = new List <StreamInfo>();

            if (video != null)
            {
                int index = 0;
                var flags = video.Flags;
                if (video.D1Avail | video.HighDef)
                {
                    string name = video.HighDef ? "高清" : "标清";
                    streamList.Add(createStreamInfo(index++, name, 1, video.Id, channel));
                }

                if (flags.HasFlag(VideoParser.Video.ParamFlags.H264))
                {
                    streamList.Add(createStreamInfo(index++, "普清", 2, video.Id, channel));
                }

                if (flags.HasFlag(VideoParser.Video.ParamFlags.Mpeg4))
                {
                    streamList.Add(createStreamInfo(index++, video.HighDef ? "标清" : "流畅", 3, video.Id, channel));
                }
            }
            return(streamList.ToArray());
        }
Example #4
0
 static bool isTrackable(VideoParser.Video video)
 {
     return(video != null && video.PanTiltUnit != null &&
            (video.PanTiltUnit.Protocol == "USNT-ICU1" ||
             video.PanTiltUnit.Protocol == "USNT-TRX18D" ||
             video.PanTiltUnit.Protocol == "FY-SP2018" ||
             video.PanTiltUnit.Trackable));
 }
Example #5
0
 public CCTVCanvas(VideoParser.Video video, VideoParser.Camera camera, LocatorAndBorder locator)
 {
     Video    = video;
     _locator = locator;
     target   = new CCTVTarget(Video, camera);
     target.Update(Length(), ZoomFactor());
     this.Children.Add(target);
 }
Example #6
0
        private void getOnlineStatus(Dictionary <string, OnlineStatus> onlineDict, VideoParser.Video video)
        {
            string videoId = getNodeId(video.Id);

            onlineDict[videoId] = new OnlineStatus()
            {
                NodeId = videoId, Online = video.Online
            };
        }
Example #7
0
        private void Unchecked(ulong value)
        {
            var cctv = GetCCTV(value);

            if (cctv != null)
            {
                cctv.Selected = false;
            }
            _selected = null;
        }
Example #8
0
 public CCTVTarget(VideoParser.Video video, VideoParser.Camera camera)
 {
     Video     = video;
     pathLimit = newPath(System.Windows.Media.Brushes.LightYellow);
     pathView  = newPath(System.Windows.Media.Brushes.LightGreen);
     this.Children.Add(pathLimit);
     this.Children.Add(pathView);
     newPolygon();
     fillColorByOnline();
     AddLine(Video.PanTiltUnit.WideView);
     Camera = camera;
 }
Example #9
0
        private void getHierarchyInfo(string parentId, VideoParser.Video video)
        {
            string videoId = getNodeId(video.Id);

            _dictHier[videoId] = new CCTVHierarchyInfo()
            {
                Id        = videoId,
                Name      = video.Name,
                Type      = NodeType.Video,
                ParentId  = parentId,
                ElementId = videoId
            };
        }
Example #10
0
        private void Checked(VideoParser.Video video)
        {
            if (video == null)
            {
                return;
            }
            var cctv = GetCCTV(video.Id);

            if (cctv != null)
            {
                cctv.Selected = true;
                _selected     = video;
            }
        }
Example #11
0
        public void CheckNeerestPoint(Point point, ref double distCCTVNode)
        {
            if (_cctvShow == null)
            {
                return;
            }
            double dist  = 1000;
            var    video = _cctvShow.SelectedOnPoint(point, out dist);

            if (dist < distCCTVNode && dist < 20)
            {
                distCCTVNode = dist;
                Selected     = video;
            }
        }
Example #12
0
 private void addCCTVsShow()
 {
     this.Dispatcher.BeginInvoke((Action) delegate()
     {
         VideoParser.Video selected = Selected;
         if (_cctvShow != null)
         {
             this.Children.Remove(_cctvShow);
         }
         _cctvShow = new CCTVsCanvas(_locator, _nodeTree.GetAllTrackVideos(), _videoRealtime);
         this.Children.Add(_cctvShow);
         onMapRefreshed();
         Selected = selected;
     });
 }
        TreeViewItem getVideoNode(VideoParser.Video node, bool online)
        {
            TreeViewItem item = new TreeViewItem();

            item.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            item.Header = node.Name;
            item.Tag    = node;
            if (online)
            {
                item.Foreground = Brushes.Black;
                item.ToolTip    = "在线";
            }
            else
            {
                item.Foreground = Brushes.DarkGray;
                item.ToolTip    = "不在线";
            }
            return(item);
        }
Example #14
0
        public VideoParser.Video SelectedOnPoint(System.Windows.Point point, out double dist)
        {
            VideoParser.Video key = null;
            dist = 1000;
            double distPrev = 1000;

            for (int i = 0; i < cctvs.Length; i++)
            {
                if (cctvs[i].NeerPoint(point, ref distPrev))
                {
                    if (dist > distPrev)
                    {
                        dist = distPrev;
                        key  = cctvs[i].Video;
                    }
                }
            }
            return(key);
        }
Example #15
0
 public void ShowCCTVWindow(VideoParser.Video selected)
 {
     if (_trackVideoForm != null)
     {
         if (selected != null)
         {
             try
             {
                 _trackVideoForm.SetVideoID(selected.Id, selected.Name);
                 _trackVideoForm.Show();
                 updateCCTVFormOwner();
             }
             catch (Exception ex)
             {
                 LogService.Error("CCTV播放失败!!" + Environment.NewLine + ex.ToString());
                 MessageBox.Show("CCTV播放失败!!");
             }
         }
     }
 }
Example #16
0
        private VideoParser.Video getNearestVideo(double lat, double lon)
        {
            var videos = _nodeTree.GetAllTrackVideos();

            if (videos == null)
            {
                return(null);
            }
            VideoParser.Video nearestVideo = null;
            double            minDist      = 5.0 / 60;

            foreach (var video in videos)
            {
                double dir = 90.0 - 180.0 / Math.PI * Math.Atan2(lat - video.PanTiltUnit.Latitude, lon - video.PanTiltUnit.Longitude);
                if (dir < 0)
                {
                    dir += 360.0;
                }
                double left  = video.PanTiltUnit.LeftLimit;
                double right = video.PanTiltUnit.RightLimit;
                if (right < left)
                {
                    if (dir < right)
                    {
                        dir += 360.0;
                    }
                    right += 360.0;
                }
                if (dir > left && dir < right)
                {
                    double dist = getDist(new Point(video.PanTiltUnit.Longitude, video.PanTiltUnit.Latitude), new Point(lon, lat));
                    if (dist < minDist)
                    {
                        minDist      = dist;
                        nearestVideo = video;
                    }
                }
            }
            return(nearestVideo);
        }
Example #17
0
 public void UpdateVideo(VideoParser.Video video)
 {
     target.Update(video);
 }
        private void classifyInfo(VideoParser.Front front, VideoParser.Video video, int channel, string serverId)
        {
            //在线标识。
            var videoId = getNodeId(video.Id);

            if (video.DvrChannel > 0)
            {
                channel = video.DvrChannel;
            }

            _onlineStatus[videoId] = new CCTVOnlineStatus()
            {
                VideoId = videoId, Online = video.Online
            };

            CCTVStaticInfo info = new CCTVStaticInfo()
            {
                VideoId   = videoId,
                Name      = video.Name,
                ImageType = video.HighDef ? ImageType.HighDef : ImageType.Unknow,
                Platform  = CCTVPlatformType.CCTV1,
                Streams   = getStreamInfos(video, channel),
            };

            if (video.PanTiltUnit != null && video.PanTiltUnit.Trackable)
            {
                var ptz = video.PanTiltUnit;
                info.Latitude  = ptz.Latitude;
                info.Longitude = ptz.Longitude;
                info.Altitude  = ptz.Altitude;
                //生成摄像机象限信息
                CCTVCameraLimits camera = new CCTVCameraLimits()
                {
                    VideoId     = info.VideoId,
                    UpLimit     = ptz.UpLimit,
                    DownLimit   = ptz.DownLimit,
                    LeftLimit   = ptz.LeftLimit,
                    RightLimit  = ptz.RightLimit,
                    MaxViewPort = ptz.WideView,
                    MinViewPort = ptz.TeleView
                };
                _cameras[camera.VideoId] = camera;
            }
            else
            {
                VideoPosition videoPosition;
                if (_vpSync.TryGetValue(info.VideoId, out videoPosition))
                {
                    info.Latitude  = videoPosition.Latitude;
                    info.Longitude = videoPosition.Longitude;
                    info.Altitude  = videoPosition.Altitude;
                    info.Heading   = videoPosition.Heading;
                    info.ViewPort  = videoPosition.ViewPort;
                }
            }
            _statics[info.VideoId] = info;

            //视频跟踪
            var vTrackHost = ImageTrackInfoProvider.Instance.GetImageTrackHost(video.Id);

            if (!string.IsNullOrWhiteSpace(vTrackHost))
            {
                var vTrack = new CCTVVideoTrack()
                {
                    Ip      = vTrackHost,
                    RpcPort = 8068,
                    SubPort = 8061,
                    VideoId = info.VideoId
                };
                _videoTracks[vTrack.VideoId] = vTrack;
            }


            //生成设备信息。
            CCTVDeviceInfo di = new CCTVDeviceInfo()
            {
                VideoId           = info.VideoId,
                DeviceType        = DeviceType.HikIP,
                PreferredServerId = serverId,
                User     = front.User,
                Password = front.Pass,
                Port     = front.Port
            };

            //大于33的认为是IP直连。
            if (channel >= 33)
            {
                di.Ip = video.Host;
            }
            else
            {
                di.Ip = front.Host;
            }
            _devices[di.VideoId] = di;

            //TODO:生成控制信息。徐测试以此方法生成是否可行。
            CCTVControlConfig cc = new CCTVControlConfig()
            {
                VideoId   = info.VideoId,
                Type      = getControlType(video.PanTiltUnit),
                Ip        = di.Ip,
                Port      = di.Port,
                Channel   = channel,
                AuxSwitch = getAuxSwitch(video.PanTiltUnit)
            };

            _controls[cc.VideoId] = cc;
        }
Example #19
0
        private void getStaticInfo(Dictionary <string, CCTVStaticInfo> staticDict, VideoParser.Front front, VideoParser.Video video, int channel)
        {
            CCTVStaticInfo info = new CCTVStaticInfo()
            {
                VideoId      = getNodeId(video.Id),
                Name         = video.Name,
                IP           = front.Host,
                HighDef      = video.HighDef,
                PanTilt      = video.PanTiltUnit != null && (video.PanTiltUnit.EightDirections || video.PanTiltUnit.FourDirections),
                Zoom         = video.PanTiltUnit != null && video.PanTiltUnit.Zoom,
                AuxSwitch    = getAuxSwitch(video.PanTiltUnit),
                VideoAnalyze = video.VideoAnalyze,
                TargetTrack  = video.PanTiltUnit != null && video.PanTiltUnit.Trackable,
                Streams      = getStreamInfos(video),
            };

            info.ImageTrackHost = ImageTrackInfoProvider.Instance.GetImageTrackHost(video.Id);
            info.ImageTrack     = !string.IsNullOrEmpty(info.ImageTrackHost);
            if (video.DvrChannel > 0)
            {
                channel = video.DvrChannel;
            }
            info.DvrChannelInfo = getDvrChannelInfo(front, channel);

            if (info.TargetTrack && video.PanTiltUnit != null)
            {
                var ptz = video.PanTiltUnit;
                info.Latitude  = ptz.Latitude;
                info.Longitude = ptz.Longitude;
                info.Altitude  = ptz.Altitude;
                info.TrackInfo = new TrackVideoInfo()
                {
                    UpLimit     = ptz.UpLimit,
                    DownLimit   = ptz.DownLimit,
                    LeftLimit   = ptz.LeftLimit,
                    RightLimit  = ptz.RightLimit,
                    MaxViewPort = ptz.WideView,
                    MinViewPort = ptz.TeleView,
                };
            }
            else
            {
                VideoPosition videoPosition;
                if (_videoPosSync.TryGetValue(info.VideoId, out videoPosition))
                {
                    info.Latitude  = videoPosition.Latitude;
                    info.Longitude = videoPosition.Longitude;
                    info.Altitude  = videoPosition.Altitude;
                    info.Heading   = videoPosition.Heading;
                    info.ViewPort  = videoPosition.ViewPort;
                }
            }

            staticDict[info.VideoId] = info;
        }
Example #20
0
 public CameraGeometryObj(VideoParser.Video video, VideoParser.Camera camera)
 {
 }
Example #21
0
        private void getHierarchyInfo(Dictionary <string, HierarchyInfo> hierarchyDict, string parentId, VideoParser.Video video)
        {
            string videoId = getNodeId(video.Id);

            hierarchyDict[videoId] = new HierarchyInfo()
            {
                NodeId   = videoId,
                Name     = video.Name,
                Type     = "Video",
                ParentId = parentId,
            };
        }