QR / Barcode Scanner
QR / Barcode Scanner recognizes QR / Barcode.
Create Instants
Starting / Stopping the Scanner
Using the Scanning Information
Create Instants
>QR_BarcodeViewController.mm
- (void)viewDidLoad { ... trackingManager = [[MasTrackerManager alloc] init]; cameraDevice = [[MasCameraDevice alloc] init]; backgroundRenderer = [[MasBackgroundRenderer alloc] init]; [MasMaxstAR onSurfaceCreated]; }
Starting / Stopping the Scanner
To start / stop Scanner, refer to the following code.
>QR_BarcodeViewController.mm
- (void)resumeAR { ... [trackingManager startTracker:TRACKER_TYPE_CODE_SCANNER]; } - (void)pauseAR { [trackingManager 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 { ... MasTrackingState *trackingState = [trackingManager updateTrackingState]; MasBackgroundTexture *backgroundTexture = [backgroundRenderer getBackgroundTexture]; [backgroundRenderer begin:backgroundTexture]; [backgroundRenderer renderBackgroundToTexture]; [backgroundRenderer end]; [backgroundQuad draw:backgroundTexture projectionMatrix:[cameraDevice getBackgroundPlaneProjectionMatrix]]; glEnable(GL_DEPTH_TEST); NSString *codeScanResult = [trackingState getCodeScanResult]; if(![codeScanResult isEqual: @""]) { NSError* error; NSData *objectData = [codeScanResult dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:NSJSONReadingMutableContainers error:&error]; self.formatLabel.text = json[@"Format"]; self.codeLabel.text = json[@"Value"];; [trackingManager stopTracker]; [self.scanButton setAlpha:1.0f]; [self.scanButton setEnabled:YES]; [self.scanButton setTitle:@"Start Scan" forState:UIControlStateNormal]; } ... }