Detecting other markers

Oct 11, 2010 at 9:00 AM
Edited Oct 11, 2010 at 9:01 AM

Ive been trying different markers to initiate different projection. But when i put a different marker. It will still project the same thing?

Im not very sure where the error lies. Heres my part:

 


 

if (arDetector == null)          

 {InitializeDetector(bmp.PixelWidth, bmp.PixelHeight); }

 if (arDetector2 == null)

 {InitializeDetector2(bmp.PixelWidth, bmp.PixelHeight); }            

          var detected = arDetector.DetectAllMarkers(bmp); var detected2 = arDetector2.DetectAllMarkers(bmp);

         bmp.Clear();            

         ViewportOverlay.Source = bmp;

 

if (detected.HasResults)            

{ var trans = detected[0].Transformation.ToBalderMatrix();              

 lock (this.Game.Scene.RenderableNodes)                

{                    this.currentModel = this.Car;                    this.Game.Scene.RenderableNodes.Clear();                    this.Game.Scene.AddNode(currentModel);                }

 Game.Visibility = System.Windows.Visibility.Visible;
                ApplyFinalTransformation(trans);
 }

else if (detected2.HasResults)            

{ var trans = detected2[0].Transformation.ToBalderMatrix();              

 lock (this.Game.Scene.RenderableNodes)                

{                    this.currentModel = this.Lorry;                    this.Game.Scene.RenderableNodes.Clear();                    this.Game.Scene.AddNode(currentModel);                }

 Game.Visibility = System.Windows.Visibility.Visible;
                ApplyFinalTransformation(trans);
 }

 


i have load two markers. but it will read only the first one.

Sorry have abit trouble formatting into here

 

 

Coordinator
Oct 11, 2010 at 2:53 PM

This code is hard to read and it's missing some important parts. Use the Code format tool  from the above toolbar the next time please and don't provide only small snippets.

Please see the examples that ship with the source code. The Silverlight projection and the Balder sample both use two markers. Use this code as a starter.

Oct 12, 2010 at 3:04 AM

 

            if (arDetector == null)
            {
                InitializeDetector(bmp.PixelWidth, bmp.PixelHeight);
            }

            if (arDetector2 == null)
            {
                InitializeDetector2(bmp.PixelWidth, bmp.PixelHeight);
            }
            // Detect
            var detected = arDetector.DetectAllMarkers(bmp);
            var detected2 = arDetector2.DetectAllMarkers(bmp);

            bmp.Clear();
            ViewportOverlay.Source = bmp;

            if (detected.HasResults)
            {
                var trans = detected[0].Transformation.ToBalderMatrix();
                lock (this.Game.Scene.RenderableNodes)
                {
                    this.currentModel = this.Car;
                    this.Game.Scene.RenderableNodes.Clear();
                    this.Game.Scene.AddNode(currentModel);
                }

                Game.Visibility = System.Windows.Visibility.Visible;

                ApplyFinalTransformation(trans);

                MessageBox.Show("SLAR Marker");

            }
            else
            {
                Game.Visibility = System.Windows.Visibility.Collapsed;
            }

            if (detected2.HasResults)
            {
                var trans = detected[0].Transformation.ToBalderMatrix();
                lock (this.Game.Scene.RenderableNodes)
                {
                    this.currentModel2 = this.test;
                    this.Game.Scene.RenderableNodes.Clear();
                    this.Game.Scene.AddNode(currentModel2);
                }

                Game.Visibility = System.Windows.Visibility.Visible;

                ApplyFinalTransformation2(trans);

                MessageBox.Show("detect L Marker");

            }
            else
            {
                Game.Visibility = System.Windows.Visibility.Collapsed;
            }

Sorry wasnt aware of the function.
It keep reading both markers as one. For example. if i take one of the if function. and instead of putting the SLAR marker, i put the L marker.. it will still detect the L marker


Coordinator
Oct 12, 2010 at 7:36 AM

You can't use two different MarkerDetector implementations for this scenario. It's also more overhead. One detector is sufficient.

Again, check out the samples and you will see how it works.