Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

wikitude working with titanium

$
0
0

Application type: mobile, Titanium SDK: 3.3.0, Platform & version: android : 4.4.2 Device : moto g, Host Operating System: OSX 10.9, Titanium Studio:3.3.0.

Hello everyone, I am using the titanium wikitude module which I downloaded from market place into the sample app which I downloaded from here in android.I had a few questions and looking forward to get an answere. 1) The sample app has index.html placed in Resources/android/assets/1_ImageRecognition_1_ImageOnTarget/index.html and has a tag i.e <script src="architect://architect.js"></script> which I am not able to locate in the sample app? 2 ) I am able to fire the event which is when the image is tracked by the tracker however what I want to do is notify the titanium app or in other words create some kind of handler which will quit the wikitude view and do some other processing on image target recognition? The js which does the above work around is

var World = {
    loaded : false,
 
    init : function initFn() {
        /*
         Disable all sensors in "IR-only" Worlds to save performance. If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.
         */
        AR.context.services.sensors = false;
        this.createOverlays();
    },
    createOverlays : function createOverlaysFn() {
 
        /*
         First an AR.Tracker needs to be created in order to start the recognition engine. It is initialized with a URL specific to the target collection. Optional parameters are passed as object in the last argument. In this case a callback function for the onLoaded trigger is set. Once the tracker is fully loaded the function worldLoaded() is called.
 
         Important: If you replace the tracker file with your own, make sure to change the target name accordingly.
         Use a specific target name to respond only to a certain target or use a wildcard to respond to any or a certain group of targets.
         */
 
        this.tracker = new AR.Tracker("assets/targetcollections.wtc", {
            onLoaded : this.worldLoaded
        });
 
        /*
         The next step is to create the augmentation. In this example an image resource is created and passed to the AR.ImageDrawable. A drawable is a visual component that can be connected to an IR target (AR.Trackable2DObject) or a geolocated object (AR.GeoObject). The AR.ImageDrawable is initialized by the image and its size. Optional parameters allow for position it relative to the recognized target.
         */
 
        /* Create overlay for page one */
        var imgOne = new AR.ImageResource("assets/aurusSearch.jpg");
        var overlayOne = new AR.ImageDrawable(imgOne, 1, {
            offsetX : -0.15,
            offsetY : 0
        });
 
        /*
         The last line combines everything by creating an AR.Trackable2DObject with the previously created tracker, the name of the image target and the drawable that should augment the recognized image.
         Please note that in this case the target name is a wildcard. Wildcards can be used to respond to any target defined in the target collection. If you want to respond to a certain target only for a particular AR.Trackable2DObject simply provide the target name as specified in the target collection.
         */
 
        var pageOne = new AR.Trackable2DObject(this.tracker, "*", {
            drawables : {
                cam : overlayOne
            },
 
            onEnterFieldOfVision : function(event) {
                if ('aurus' == event) {
                    require('web').openWebView('www.aurusit.com');
                }
            }
        });
 
    },
    worldLoaded : function worldLoadedFn() {
        // this is where the target collection is loaded
 
        var cssDivLeft = " style='display: table-cell;vertical-align: middle; text-align: right; width: 50%; padding-right: 15px;'";
        var cssDivRight = " style='display: table-cell;vertical-align: middle; text-align: left;'";
        document.getElementById('loadingMessage').innerHTML = "<div" + cssDivLeft + ">Scan Target &#35;1 (aurus):</div>" + "<div" + cssDivRight + "><img src='assets/aurus.jpg'></img></div>";
 
        // Remove Scan target message after 10 sec.
        setTimeout(function() {
            var e = document.getElementById('loadingMessage');
            e.parentElement.removeChild(e);
        }, 10000);
    }
};
 
World.init();
Thank you.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>