QR Code Fusion Tracker iOS Tutorial
1. Overview
2. iOS Development
2.1 Create Instants
2.2 Start / Stop Tracker
2.3 Use Tracking Information
3. Reference
3.1 API Reference
3.2 Sample
1. Overview
Develop 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 Fusion Tracker.
After target recognition and initial poses are acquired through the MAXST SDK, use ARKit for tracking.
※To use the AR Core / AR Kit, you must enter the actual size. (See Start / Stop Tracker)
Prerequisites |
---|
QR Code Fusion Tracker Introduction |
Tracker Coordinate System |
2. iOS Development
Start developing on xCode using Swift. 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 trackingManager:MasTrackerManager = MasTrackerManager()
2.2 Start / Stop Tracker
trackingManager.isFusionSupported ()
This function checks whether or not your device supports Fusion.
Return value is bool type. If true, it supports the device in use. If it is false, it does not support the device.
trackingManager.getFusionTrackingState ()
Pass the tracking status of the current Fusion.
The return value is an int of -1, which means that tracking isn't working properly, and 1 means that it's working properly.
To start / stop the tracker, refer to the following code.
func startEngine() { trackingManager.start(.TRACKER_TYPE_QR_FUSION) trackingManager.addTrackerData("{\"qr_fusion\":\"set_scale\",\"content\":\"wikipedia\", \"scale\":0.14}"); trackingManager.loadTrackerData() } @objc func resumeAR() { trackingManager.start(. TRACKER_TYPE_QR_FUSION) } @objc func pauseAR() { trackingManager.stopTracker() }
You need to pass the exact actual size as a parameter of scale via addTrackerData. (Unit: m)
Content is a phrase included in the information of the QR code.
SetScale is the actual size of the QR code. The shape of the QR code is square.
You must enter the actual size of the target. If you do not enter the correct actual size, the content will not be augmented properly.
It must be run in the following order: startTracker (), addTrackerData (), loadTrackerData ().
2.3 Use Tracking Information
The QR Code information is set as 'getName' in 'MasTrackable'.
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) } } ... }
3. References
These are additional references to develop QR Code Fusion Tracker
3.1 API Reference
Following documents explain classes and functions used to run QR Code Fusion Tracker
3.2 Sample
For information regarding sample build and run of QR Code Fusion Tracker, refer to Sample