Cloud Recognition

Related documentations
Target Manager
Recommended Conditions for Target Images
Tracker Coordinate System

You can recognize and track 2D images registered on MAXST Developer Site to enhance the 3D content, video images, and Chroma key images.

Apply Tracker secretID / secretKey
Create Instance
Start / Stop Tracker
Use the Tracking information

Apply Tracker secretID / secretKey

>CloudRecognizerViewController.mm

- (void)startEngine
{
    ...
    secretId = @"32b41d66c392447795564.......";
    secretKey = @"c40d6fbca31e4d03baa677........";
    ...
    
    [trackingManager setCloudRecognitionSecretId:secretId secretKey:secretKey];
    [trackingManager startTracker:TRACKER_TYPE_CLOUD_RECOGNIZER];
}

Create Instance

>CloudRecognizerViewController.mm

- (void)viewDidLoad
{
    ...
    trackingManager = [[MasTrackerManager alloc] init];
    cameraDevice = [[MasCameraDevice alloc] init];
    ...
}

Start / Stop Tracker

Please refer to the following code to start/stop the Tracker.

>CloudRecognizerViewController.mm

- (void)resumeAR
{
    ...
    [trackingManager startTracker:TRACKER_TYPE_CLOUD_RECOGNIZER];
}

- (void)pauseAR
{
    [trackingManager stopTracker];
    ...
}

Use the Tracking Information

Print or display on the screen the images registered at Target Manager/Cloud on MAXST Developer Site. You can retrieve the data through the Name or MetaData of the images.

In order to apply the tracking results to an augmented object, refer to the following codes.

>CloudRecognizerViewController.mm

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    ...
    MasTrackingState *trackingState = [trackingManager updateTrackingState];
    MasTrackingResult *result = [trackingState getTrackingResult];
    
    MasTrackedImage *trackedImage = [trackingState getImage];
    [backgroundCameraQuad draw:trackedImage projectionMatrix:[cameraDevice getBackgroundPlaneProjectionMatrix]];

    matrix_float4x4 projectionMatrix = [cameraDevice getProjectionMatrix];
    int trackingCount = [result getCount];
    
    if(trackingCount == 1)
    {
        MasTrackable *trackable = [result getTrackable:0];
        
        NSString* cloudName = [trackable getCloudName];
        NSString* cloudMetaData = [trackable getMetaData];
        
        if([cloudName isEqualToString:@"Lego"]) {
            if([videoCaptureController getState] == PLAYING)
            {
                [videoCaptureController play];
                [videoCaptureController update];
                
                [videoPanelRenderer setVideoTextureId:[videoCaptureController getOpenglesTextureId]];
                [videoPanelRenderer setProjectionMatrix:projectionMatrix];
                [videoPanelRenderer setPoseMatrix:[trackable getPose]];
                [videoPanelRenderer setTranslation:0.0f y:0.0f z:0.0f];
                [videoPanelRenderer setScale:0.11f y:-0.065f z:1.0f];
                [videoPanelRenderer draw];
            }
        } else if([cloudName isEqualToString:@"Glacier"]) {
            [texturedCube setProjectionMatrix:projectionMatrix];
            [texturedCube setPoseMatrix:[trackable getPose]];
            [texturedCube setTranslation:0.0f y:0.0f z:-0.025f];
            [texturedCube setScale:0.115f y:0.082f z:0.05f];
            [texturedCube draw];
        } else if([cloudName isEqualToString:@"Blocks"]) {
            [coloredCube setProjectionMatrix:projectionMatrix];
            [coloredCube setPoseMatrix:[trackable getPose]];
            [coloredCube setTranslation:0.0f y:0.0f z:-0.025f];
            [coloredCube setScale:0.115f y:0.082f z:0.05f];
            [coloredCube draw];
        }
    } else {
        [videoCaptureController pause];
    }
    ...
}
  • If the name of the image registered on MAXST Developer Site is "Lego", the video will be augmented. "Lego" can retrieve the Meta data registered on site with MetaData. The image with the current name "Lego" contains the phrase "Welcome to Maxst" in MetaData.

  • On the Image of "Glacier", a box with image texture will be augmented. In MetaData, you can see the website address "developer.maxst.com".

  • You can find a white box on the image of "Blocks" and the MetaData has a Json phrase : { "success": true }

In regard to the scale of the content, if you registered RealWidth as '0.12m' on MAXST Developer Site you should apply '0.12' to Scale to view the contents as a whole image.