Triggering different media for different markers

Apr 20, 2014 at 2:11 PM
Hi I'm using the Windows Phone 8 Sample kit, I've got it to detect different markers, I just need it to display specific media (text, video, image based on radio button selection) on-top of specific marker patterns e.g. SLAR marker displays vid1, L marker displays vid2 etc. I am unsure of the Syntax for this, could someone help me?
Coordinator
Apr 20, 2014 at 2:17 PM
See the samples there's at last one sample which shows exactly what you are trying to achieve using the markers confidence value.
Apr 20, 2014 at 4:12 PM
Thanks for the reply teichgraf, I've downloaded the source code and I'm checking them out now but can't seem to spot it, could you give me the name? Is it a Windows Phone compatible sample/code?
Coordinator
Apr 20, 2014 at 5:15 PM
No, it's a Silverlight sample. The name on the project homepage is Silverlight Projection Sample. Search for Confidence.
Apr 20, 2014 at 5:33 PM
Edited Apr 20, 2014 at 5:45 PM
Cool I've managed to find the confidence snippet, however when I try input it into my Windows phone project, it says the confidence property does not exist, the code I'm trying to convert/adapt to work with Windows Phone 8 is this:
if (resultL != null)
{
if(resultL.Confidence > 0.5)
         ApplyTransformation(GrdARContent1, resultL.Transformation);
Am I along the right lines? If you could tell me how to apply this into the windows phone 8 environment that would be great. It's for my final year university project and I'm running out of time to try and adapt it, please sir.

Here's the code I'm trying to change to have a confidence property:
 if (rd.HasResults)
                {
                    var world = centerAtOrigin * scale * rd[0].Transformation;
                    var d = Matrix3DFactory.CreateViewportProjection(world, Matrix3D.Identity, arDetector2.Projection, viewport);
                    matrix3DProjection.ProjectionMatrix = d;
                }
Apr 21, 2014 at 2:33 PM
I'm awaiting your reply, considering there is no defined "confidence" parameter in a SLARToolkit Windows Phone environment, what's the next best solution?
Coordinator
Apr 21, 2014 at 2:52 PM
It's there, of course you need to adapt the demos. It's as easy as combining the Silverlight sample mentioned earlier with the WP sample. Honestly, if you are in your final year you should be able to combine two samples into one. :)

dr[0] accesses one DetectionResult of the result collection and this has the Confidence property like so:
var confidence = dr[0].Confidence;
Apr 21, 2014 at 5:43 PM
Edited Apr 21, 2014 at 5:53 PM
Cheers big man :)

Thanks for that little explanation, so that number in the square brackets defines which detection result is being accessed? so if it was dr[1] it would detect all markers in dr[1]? I'll try and see what I can come up with, and I will report my progress as I go along, I may ask for more pointers/help on here if that's ok? Would save me so much time though if you could show me more detailed breakdown of the Syntax, Only reason I ask is because I'm not a coder, actually I'm really rubbish at it, my course is Multimedia Computing but I have to do some coding obviously to demonstrate the "computing" aspect of my degree. So what may seem simple to you is really confusing to me! :) 8 days left until deadline and counting haha.
Coordinator
Apr 21, 2014 at 6:59 PM
Go to http://slartoolkit.codeplex.com/SourceControl/latest
and download the Zip file there which contains all the samples.
Apr 24, 2014 at 5:52 PM
Edited Apr 24, 2014 at 6:16 PM
Hey teichgraf, any chance you can point me towards which elements from the Silverlight Sample need transferring over to the WP Sample? I been trying for the past few days and I've made some changes but the results aren't working right, it's driving me crazy, please if you can give a little more guidance it would be very kind of you you're the only that can. I honestly apologise for the hassle and appreciate your help thus far :)
Apr 24, 2014 at 6:14 PM
Edited Apr 24, 2014 at 6:15 PM
Am I along the right lines with this code?
if (dr.HasResults !=null)
               {
                    var resultSlar = dr.Where(r => r.Marker == markerSlar).FirstOrDefault();
                    if (resultSlar == null)
                    {
                        resultSlar = dr[0];
                    }
                    if (dr[0].Confidence > 1)
                    {
                        var world = centerAtOrigin * scale * resultSlar.Transformation;

var m = Matrix3DFactory.CreateViewportProjection(world, Matrix3D.Identity, arDetector.Projection, viewport);

 matrix3DProjection.ProjectionMatrix = m;
Apr 24, 2014 at 6:20 PM
Edited Apr 24, 2014 at 6:21 PM
I've split the media types in the XAML into two separate canvas's with two separate names, e.g. Img1 is in Canvas1 and should be applied when SLAR marker is in sight, Video1 is in Canvas2 and should be applied when L marker is in sight. I just need to figure out how to apply transformations to the specific canvas's via their names as I saw that's how it's done in the Silverlight Sample, I just can't figure out how to arrange and name the syntax for the WP sample.
Apr 24, 2014 at 8:55 PM
Unless I'm looking at the wrong sample? Could you indicate as to which sample it is that does the Confidence media change as stated out of:

SLARToolkit3DSample
SLARToolkitBalderSample
SLARToolkitBeginnersGuide
SLARToolkitSample
Apr 24, 2014 at 9:41 PM
The only one with any elaborate mention of Confidence is the SLARToolkit3DSample, I just don't understand how you would assign confidence onto different media even after looking at it, I tried grouping the Matrix3D scale, transform properties into a "Private Void ApplyTransform" group but don't quite understand how to apply it to the given media even after grouping them into the relevant Canvas's in the XAML.
Apr 24, 2014 at 10:26 PM
I think the key is in the "Private Void ApplyTransformation" how would you group and apply all the transformations in the WP sample i.e Scale etc into a group then use that group to apply the transformations to the Grid/Canvas elements?