private void DetectMarkers(WriteableBitmap bmp)
        {
            // Init. here because the captureSource.VideoCaptureDevice.DesiredFormat getter is not reliable and throws an Exception
            if (!isInit)
            {
                // Init AR
                arDetector.Initialize(bmp.PixelWidth, bmp.PixelHeight, Game.Camera.Near, Game.Camera.Far, new List <Marker> {
                    slarMarker
                });
                isInit = true;
            }

            // Detect
            var dr = arDetector.DetectAllMarkers(bmp);

            // Reused for marker highlighting
            bmp.Clear();
            ViewportOverlay.Source = bmp;

            if (dr.HasResults)
            {
                var transformation = Balder.Math.Matrix.CreateTranslation(0, -5, 0) * Balder.Math.Matrix.CreateRotationX(90) * dr[0].Transformation.ToBalder();
                Game.SetWorldMatrix(transformation);

                // Highlight detected markers
                var txt = String.Empty;
                foreach (var r in dr)
                {
                    bmp.DrawQuad((int)r.Square.P1.X, (int)r.Square.P1.Y, (int)r.Square.P2.X, (int)r.Square.P2.Y, (int)r.Square.P3.X, (int)r.Square.P3.Y, (int)r.Square.P4.X, (int)r.Square.P4.Y, Colors.Red);
                    txt += String.Format("{0}.Confidence = {1:0.00}   ", r.Marker.Name, r.Confidence);
                }
            }
        }
 private void InitializeDetector(int width, int height)
 {
     // Init AR
     arDetector.Initialize(width, height, camera.Near, camera.Far, new List <Marker> {
         slarMarker, lMarker
     });
     camera.AspectRatio = (float)width / height;
     Sun.ScreenSize     = new Vector2(width, height);
 }
Exemple #3
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 InitializeARDetector()
        {
            //  Initialize the Detector

            // Load the marker pattern. It has 16x16 segments and a width of 80 millimeters
            //creating a marker list
            markerList = new List <Marker>();
            for (int i = 0; i <= 2; i++)
            {
                Marker marker = new Marker();
                string url    = "Resources/Marker/marker" + i + ".pat";
                marker = Marker.LoadFromResource(url, 16, 16, 80);
                markerList.Add(marker);
            }
            // The perspective projection has the near plane at 1 and the far plane at 4000

            bmdList = new BitmapMarkerDetector();
            bmdList.Initialize(640, 480, 1, 4000, markerList);
        }