QR / Barcode Scanner

QR / Barcode Scanner recognizes QR / Barcode.

Starting / Stopping the Scanner
Using the Scanning Information

Starting / Stopping the Scanner

To start / stop Scanner, refer to the following code.

>QR_BarcodeViewController.mm

- (void)resumeAR
{
    ...
    TrackerManager::getInstance()->startTracker(TRACKER_TYPE_CODE_SCANNER);
}

- (void)pauseAR
{
    TrackerManager::getInstance()->stopTracker();
    ...
}

Using the Scanning Information

When you illuminate QR / Barcode, the code name is displayed on the screen. Refer to the following code to use the scanning information.

>QR_BarcodeViewController.mm

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    ...
    string codeScanResult = maxstAR::TrackerManager::getInstance()->getCodeScanResult();
    
    if(codeScanResult != "")
    {
        NSString *code = [NSString stringWithCString:codeScanResult.c_str() encoding:kCFStringEncodingUTF8];
        
        NSError* error;
        NSDictionary* json = [NSJSONSerialization JSONObjectWithData:[code dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
        self.formatLabel.text = json[@"Format"];
        self.codeLabel.text =  json[@"Value"];;
        
        TrackerManager::getInstance()->stopTracker();
        [self.scanButton setAlpha:1.0f];
        [self.scanButton setEnabled:YES];
        [self.scanButton setTitle:@"Start Scan" forState:UIControlStateNormal];
    }
    ...
}