Auto Follow: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 22: Line 22:
       _autoFollow.TargetItem = new TrackAutoFollowSource { ItemId = _trackLayer.Selected.First() };
       _autoFollow.TargetItem = new TrackAutoFollowSource { ItemId = _trackLayer.Selected.First() };
   }
   }
[[Category:Draw objects]]
[[Category:Tracks]]


   else if (_drawObjectLayer.SelectedDrawObjectIds.Count() > 0)
   else if (_drawObjectLayer.SelectedDrawObjectIds.Count() > 0)

Revision as of 14:59, 13 August 2024

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() };
   }

[[Category:Draw objects]]
[[Category:Tracks]]

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