若何应用Android SDK检讨跟踪的状况
本文先容了一个示例,关于您可以在运行时履行的目的治理器义务。
当前帧中被检测和跟踪的图像目的可以经由过程TrackableResult objects列表来拜访。鄙人面的示例中,代码做了以下工作:
- 遍历状况对象的跟踪成果
获得各目的的姿势信息
基于目的的名字修正衬着纹理。
参阅:
若何应用可追踪的基类
留意:现实绘制的代码没显示。
- // Did we find any trackables this frame?
-
- for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
-
- {
-
- // Get the trackable result:
-
- const QCAR::TrackableResult* result = state.getTrackableResult(tIdx);
-
- const QCAR::Trackable & trackable = result->getTrackable ();
-
- QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());
-
- // Choose the texture based on the target name:
-
- int textureIndex;
-
- if (strcmp(trackable.getName(), "stones") == 0)
- textureIndex = 0;
-
- else if (strcmp(trackable.getName(), "chips") == 0)
-
- textureIndex = 1;
-
- else
-
- textureIndex = 2;
-
- const Texture* const thisTexture = textures[textureIndex];
-
-
- // ... render actual geometry
-
- // ...
- }
复制代码 |