Auto Follow

From Maria GDK Wiki
Revision as of 14:59, 13 August 2024 by Ths (talk | contribs)
Jump to navigation Jump to search

You can set up an Auto-Follow camera to track a moving entity in the map. The auto-follow source can be either a Track, Draw object or a VideoMetadata source.

The API documentation can be found here

Each target item type has a corresponding AutoFollowSource, i.e TrackAutoFollowSource, DrawObjectAutoFollowSource and VideoMetadataAutoFollowSource. These are initialized with either an ItemId or a VideoMetadata object.

Example

The following example enables autofollow on different types of objects depending on what objects exists and are selected:

   string videoName = "Video";
   var video = _videoLayerViewModel.Videos.FirstOrDefault(metadata => metadata.Name == videoName);
   if (video != null)
   {
      _autoFollow.TargetItem = new VideoMetadataAutoFollowSource { Video = video };
   }

   else if (_trackLayer.Selected.Count() > 0)
   {
      _autoFollow.TargetItem = new TrackAutoFollowSource { ItemId = _trackLayer.Selected.First() };
   }

   else if (_drawObjectLayer.SelectedDrawObjectIds.Count() > 0)
   {
      _autoFollow.TargetItem = new DrawObjectAutoFollowSource { ItemId = _drawObjectLayer.SelectedDrawObjectIds.First() };
   }