QR Code Tracker iOS Tutorial
1. Overview
2. iOS Development
2.1 Create Instants
2.2 Start / Stop Tracker
2.3 Use Tracking Information
2.4 Change Tracking Mode
3. Reference
3.1 API Reference
3.2 Sample
1. Overview
Start developing MAXST ARSDK QR Code Tracker on iOS Platform. Refer to QR Code Tracker Introduction for detailed information.
Refer to Tracker Coordinate System to better understand 3D coordinate system of QR Code Tracker.
Prerequisites |
---|
QR Code Tracker Introduction |
Tracker Coordinate System |
2. iOS Development
Start developing on xCode using Swift. Please refer to Requirements & Supports to find out which devices are supported.
ARSDK has to properly integrate on iOS UIViewController. Refer to Life Cycle documents for detail.
2.1 Create Instants
var cameraDevice:MasCameraDevice = MasCameraDevice() var trackingManager:MasTrackerManager = MasTrackerManager()
2.2 Start / Stop Tracker
To start / stop the tracker, refer to the following code.
※ To change the tracker, destroyTracker() should be called before
@objc func resumeAR() { trackingManager.start(.TRACKER_TYPE_QR_TRACKER) openCamera() } @objc func pauseAR() { trackingManager.stopTracker() cameraDevice.stop() }
2.3 Use Tracking Information
The QR Code information is setted function 'getName' in 'MasTrackable'.
※ startTracker() should be called before
func draw(in view: MTKView) { ... let trackingState:MasTrackingState = trackingManager.updateTrackingState() let result:MasTrackingResult = trackingState.getTrackingResult() let backgroundImage:MasTrackedImage = trackingState.getImage() var backgroundProjectionMatrix:matrix_float4x4 = cameraDevice.getBackgroundPlaneProjectionMatrix() let projectionMatrix:matrix_float4x4 = cameraDevice.getProjectionMatrix() if let cameraQuad = backgroundCameraQuad { cameraQuad.setProjectionMatrix(projectionMatrix: backgroundProjectionMatrix) cameraQuad.draw(commandEncoder: commandEncoder, image: backgroundImage) } let trackingCount:Int32 = result.getCount() var recogQRCode:String = "Recognized QRCode : " if trackingCount > 0 { for i in stride(from: 0, to: trackingCount, by: 1) { let trackable:MasTrackable = result.getTrackable(i) let poseMatrix:matrix_float4x4 = trackable.getPose() recogQRCode = recogQRCode + trackable.getName() + ", " textureCube!.setProjectionMatrix(projectionMatrix: projectionMatrix) textureCube!.setPoseMatrix(poseMatrix: poseMatrix) textureCube!.setTranslation(x: 0.0, y: 0.0, z: -0.05) textureCube!.setScale(x: 1.0, y: 1.0, z: 0.1) textureCube!.draw(commandEncoder: commandEncoder) } } ... }
2.4 Change Tracking Mode
2 Tracking Modes of QR Code Tracker:
- JITTER_REDUCTION_ACTIVATION
- JITTER_REDUCTION_DEACTIVATION
- JITTER_REDUCTION_ACTIVATION: Default Setting. Jitter reduction.
trackingManager.setTrackingOption(.JITTER_REDUCTION_ACTIVATION)
- JITTER_REDUCTION_DEACTIVATION: Disable the jitter reduction option.
trackingManager.setTrackingOption(.JITTER_REDUCTION_DEACTIVATION)
3. 참조문서
QR Code Tracker 개발에 필요한 기타 참조 문서입니다.
3.1 API Reference
QR Code Tracker 사용하는 Class와 Function에 대한 설명은 다음의 API문서를 참조해 주세요.
3.2 Sample
QR Code Tracker Tutorial의 샘플 코드입니다. 샘플의 빌드와 실행에 대한 설명은 Sample 에서 확인해 주세요.