private void UserControlLoaded(object sender, RoutedEventArgs e)
      {
         // Initialize the webcam
         captureSource = new CaptureSource {VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()};

         // Desired format is 640 x 480 (good tracking results and performance)
         captureSource.VideoCaptureDevice.DesiredFormat = new VideoFormat(PixelFormatType.Unknown, 640, 480, 60);
         captureSource.CaptureImageCompleted += CaptureSourceCaptureImageCompleted;

         // Fill the Viewport Rectangle with the VideoBrush
         var vidBrush = new VideoBrush();
         vidBrush.SetSource(captureSource);
         Viewport.Fill = vidBrush;

         //  Conctruct the Detector
         arDetector = new BitmapMarkerDetector { Threshold = 200, JitteringThreshold = 1 };

         // Load the marker patterns. It has 16x16 segments and a width of 80 millimeters
         slarMarker = Marker.LoadFromResource("data/Marker_SLAR_16x16segments_80width.pat", 16, 16, 80);

         // Capture or transform periodically
         CompositionTarget.Rendering += (s, e2) =>
                                        {
                                           if (captureSource.State == CaptureState.Started)
                                           {
                                              captureSource.CaptureImageAsync();
                                           }
                                           else
                                           {
                                              Game.SetWorldMatrix(Balder.Math.Matrix.Identity);
                                           }
                                           if (Game.ParticleSystem.Particles != null && Game.ParticleSystem.Particles.Count > 0)
                                           {
                                           }
                                        };
      }
 private void InitializeDetector(int width, int height)
 {
    // Load App resources and init AR
    arDetector = new BitmapMarkerDetector();
    var marker = Marker.LoadFromResource("data/Marker_SLAR_16x16segments_80width.pat", 16, 16, 80.0);
    arDetector.Initialize(width, height, Game.Camera.Near, Game.Camera.Far, new List<Marker> {marker});
    //    Camera.CustomProjectionMatrix = arDetector.Projection.ToBalderMatrix();
 }
      private void UserControlLoaded(object sender, RoutedEventArgs e)
      {
         // Initialize the webcam
         captureSource = new CaptureSource();
         captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

         // Desired format is 640 x 480 (good tracking results and performance)
         captureSource.VideoCaptureDevice.DesiredFormat = new VideoFormat(PixelFormatType.Unknown, 640, 480, 60);
         captureSource.CaptureImageCompleted += CaptureSourceCaptureImageCompleted;

         // Fill the Viewport Rectangle with the VideoBrush
         var vidBrush = new VideoBrush();
         vidBrush.SetSource(captureSource);
         Viewport.Fill = vidBrush;

         //  Conctruct the Detector
         arDetector = new BitmapMarkerDetector { Threshold = 200, JitteringThreshold = 1 };

         // Load the marker patterns. It has 16x16 segments and a width of 80 millimeters
         slarMarker = Marker.LoadFromResource("data/Marker_SLAR_16x16segments_80width.pat", 16, 16, 80);
         lMarker = Marker.LoadFromResource("data/Marker_L_16x16segments_80width.pat", 16, 16, 80);
      }