function onRecognitionFn(recognized, response) {
        if (recognized) {
            /* Clean Resources from previous recognitions. */
            if (World.wineLabel !== undefined) {
                World.wineLabel.destroy();
            }

            if (World.wineLabelOverlay !== undefined) {
                World.wineLabelOverlay.destroy();
            }

            /*
                To display the label of the recognized wine on top of the previously created banner, another
                overlay is defined. From the response object returned from the server the 'targetInfo.name' property
                is read to load the equally named image file. The zOrder property (defaults to 0) is set to 1 to
                 make sure it will be positioned on top of the banner.
            */
            World.wineLabel = new AR.ImageResource("assets/" + response.targetInfo.name + ".jpg", {
                onError: World.onError
            });
            World.wineLabelOverlay = new AR.ImageDrawable(World.wineLabel, 0.2, {
                translate: {
                    x: -0.37,
                    y: 0.55
                },
                zOrder: 1
            });

            /*
                When the cloud archive was created custom metadata for every target was defined. You are a free to
                choose the number of fields and there names depending on your needs. For this example
                'metadata.name' which represents the real name of the wine and 'metadata.shop_url' a url to a
                webshop stocking the particular wine were defined. To display the real name of the wine in the
                banner overlay, an AR.Label is created. The first parameter defines the text of the label, the
                second it's height in SDUs, the third parameter set's some optional options. To set the first
                parameter of the AR.Label we read the before mentioned real name from the custom metadata object.
            */
            World.wineName = new AR.Label(response.metadata.name, 0.06, {
                translate: {
                    y: 0.72
                },
                zOrder: 2
            });

            /* Destroy the augmentation if there already was one from a previous target recognition. */
            if (World.wineLabelAugmentation !== undefined) {
                World.wineLabelAugmentation.destroy();
            }

            /*
                Next a onClick handler is added to the orderNowButtonOverlay, making use of the AR.context class to
                open the shop's website in browser. Again the server response object is utilized to read the url
                from the custom metadata of the current target.
            */
            World.orderNowButtonOverlay.onClick = function() {
                AR.context.openInBrowser(response.metadata.shop_url);
            };

            /*
                The following combines everything by creating an AR.ImageTrackable using the CloudRecognitionService,
                the name of the image target and the drawables that should augment the recognized image.
            */
            World.wineLabelAugmentation = new AR.ImageTrackable(World.tracker, response.targetInfo.name, {
                drawables: {
                    cam: [World.bannerImgOverlay, World.wineLabelOverlay, World.wineName, World.orderNowButtonOverlay]
                },
                onError: World.onError
            });

            World.hideInfoBar();
        }
    }
/*
        The onRecognition callback function defines two parameters. The first parameter is a boolean value which
        indicates if the server was able to detect the target, its value will be 0 or 1 depending on the outcome.
        The second parameter a JSON Object will contain metadata about the recognized target, if no target was
        recognized the JSON object will be empty.
    */
The onRecognition callback function defines two parameters. The first parameter is a boolean value which
indicates if the server was able to detect the target, its value will be 0 or 1 depending on the outcome.
The second parameter a JSON Object will contain metadata about the recognized target, if no target was
recognized the JSON object will be empty.
The onRecognition callback function defines two parameters . The first parameter is a boolean value which indicates if the server was able to detect the target its value will be 0 or 1 depending on the outcome . The second parameter a JSON Object will contain metadata about the recognized target if no target was recognized the JSON object will be empty .
function onRecognitionFn(recognized, response) {
        if (recognized) {
            if (World.wineLabel !== undefined) {
                World.wineLabel.destroy();
            }
            if (World.wineLabelOverlay !== undefined) {
                World.wineLabelOverlay.destroy();
            }
            World.wineLabel = new AR.ImageResource("assets/" + response.targetInfo.name + ".jpg", {
                onError: World.onError
            });
            World.wineLabelOverlay = new AR.ImageDrawable(World.wineLabel, 0.2, {
                translate: {
                    x: -0.37,
                    y: 0.55
                },
                zOrder: 1
            });
            World.wineName = new AR.Label(response.metadata.name, 0.06, {
                translate: {
                    y: 0.72
                },
                zOrder: 2
            });
            if (World.wineLabelAugmentation !== undefined) {
                World.wineLabelAugmentation.destroy();
            }
            World.orderNowButtonOverlay.onClick = function() {
                AR.context.openInBrowser(response.metadata.shop_url);
            };
            World.wineLabelAugmentation = new AR.ImageTrackable(World.tracker, response.targetInfo.name, {
                drawables: {
                    cam: [World.bannerImgOverlay, World.wineLabelOverlay, World.wineName, World.orderNowButtonOverlay]
                },
                onError: World.onError
            });
            World.hideInfoBar();
        }
    }
function onRecognitionFn ( recognized , response ) { if ( recognized ) { if ( World . wineLabel !== undefined ) { World . wineLabel . destroy ( ) ; } if ( World . wineLabelOverlay !== undefined ) { World . wineLabelOverlay . destroy ( ) ; } World . wineLabel = new AR . ImageResource ( "assets/" + response . targetInfo . name + ".jpg" , { onError : World . onError } ) ; World . wineLabelOverlay = new AR . ImageDrawable ( World . wineLabel , 0.2 , { translate : { x : - 0.37 , y : 0.55 } , zOrder : 1 } ) ; World . wineName = new AR . Label ( response . metadata . name , 0.06 , { translate : { y : 0.72 } , zOrder : 2 } ) ; if ( World . wineLabelAugmentation !== undefined ) { World . wineLabelAugmentation . destroy ( ) ; } World . orderNowButtonOverlay . onClick = function ( ) { AR . context . openInBrowser ( response . metadata . shop_url ) ; } ; World . wineLabelAugmentation = new AR . ImageTrackable ( World . tracker , response . targetInfo . name , { drawables : { cam : [ World . bannerImgOverlay , World . wineLabelOverlay , World . wineName , World . orderNowButtonOverlay ] } , onError : World . onError } ) ; World . hideInfoBar ( ) ; } }
The onRecognition callback function defines two parameters.
The onRecognition callback function defines two parameters .
/* Clean Resources from previous recognitions. */ /*
                To display the label of the recognized wine on top of the previously created banner, another
                overlay is defined. From the response object returned from the server the 'targetInfo.name' property
                is read to load the equally named image file. The zOrder property (defaults to 0) is set to 1 to
                 make sure it will be positioned on top of the banner.
            */ /*
                When the cloud archive was created custom metadata for every target was defined. You are a free to
                choose the number of fields and there names depending on your needs. For this example
                'metadata.name' which represents the real name of the wine and 'metadata.shop_url' a url to a
                webshop stocking the particular wine were defined. To display the real name of the wine in the
                banner overlay, an AR.Label is created. The first parameter defines the text of the label, the
                second it's height in SDUs, the third parameter set's some optional options. To set the first
                parameter of the AR.Label we read the before mentioned real name from the custom metadata object.
            */ /* Destroy the augmentation if there already was one from a previous target recognition. */ /*
                Next a onClick handler is added to the orderNowButtonOverlay, making use of the AR.context class to
                open the shop's website in browser. Again the server response object is utilized to read the url
                from the custom metadata of the current target.
            */ /*
                The following combines everything by creating an AR.ImageTrackable using the CloudRecognitionService,
                the name of the image target and the drawables that should augment the recognized image.
            */