Vuforia iOS example project can't show AR model after replace .dat and .xml image target


Keywords:ios 


Question: 

I got Vuforia official example project and someone else's Vuforia Swift project. I have to do a lot of configuration to make both projects finish compile. (something like vuforiaLicenseKey and vuforiaDataSetFile)After that, I found the AR model doesn't show on the demo image target after I replace the demo database by my database.

I have updated source code to do so. When I debug, I can see my image target has been detected. And, both official example and other one's example start draw OpenGL 3D model or draw Scene kit node. Problem is I can't see them on screen. But if I configure example database back, I can see the AR view working.

The below code is the swift project example from yshrkt/VuforiaSampleSwift . It is working, and the condition of trackerableName == "coaster" is true. It means the app detected the coaster image.

 func vuforiaManager(_ manager: VuforiaManager!, didUpdateWith state: VuforiaState!) {
    for index in 0 ..< state.numberOfTrackableResults {
        let result = state.trackableResult(at: index)
        let trackerableName = result?.trackable.name
        //print("\(trackerableName)")

        if trackerableName == "coaster" {
            boxMaterial.diffuse.contents = UIColor.yellow

            if lastSceneName != "coaster" {
                manager.eaglView.setNeedsChangeSceneWithUserInfo(["scene" : "coaster"])
                lastSceneName = "coaster "
            }
        } else {
            print("\(trackerableName?.description)")
            boxMaterial.diffuse.contents = UIColor.blue

            if lastSceneName != "chips" {
                manager.eaglView.setNeedsChangeSceneWithUserInfo(["scene" : "chips"])
                lastSceneName = "chips"
            }
        }

    }
}

And, it invoked the below fun. Everything looks right.

(void)setNeedsChangeSceneWithUserInfo: (NSDictionary*)userInfo {
    SCNScene* scene = [self.sceneSource sceneForEAGLView:self userInfo:userInfo];
    if (scene == nil) {
        return;
    }

    SCNCamera* camera = [SCNCamera camera];
    _cameraNode = [SCNNode node];
    _cameraNode.camera = camera;
    _cameraNode.camera.projectionTransform = _projectionTransform;
   [scene.rootNode addChildNode:_cameraNode];

    _renderer.scene = scene;
   _renderer.pointOfView = _cameraNode;
}

Same project, before I update my image target database, it works fine, detect image target then draw model on AR view. But, after I replace database it only can detect image target, it can't draw model on AR view anymore.


1 Answer: 

Two possible things that may explain this - if your target size is wrong or if there's something wrong in the 'coaster' scene. You should first try to use the 'coaster' scene with the 'chips' target. If you can see the scene, the problem is probably with your target size. If it doesn't work, try using you new target with the 'chips' scene. This should help you isolate the problem, and perhaps bring more details here.