我想知道在rajawali vuforia找到的标记的数量。
我们有这样的方法:
1- protected void foundFrameMarker(final int markerId, Vector3 position,Quaternion orientation) {} // this method is called when found any marker until the marker disappeared
2- public void noFrameMarkersFound() {} // this method is called when no markers appeared or found
如何使用这些方法来计算找到的标记数?还是有别的办法可以得到伯爵?
发布于 2017-09-18 08:41:58
对于循环中当前检测到的每个标记,每个帧都调用foundFrameMarker。为了计数已找到的标记,您应该在呈现器中添加一个int变量来计数它们。在呈现循环(onRenderFrame)开始时重置它,并在foundFrameMarker中增加它
public void onRenderFrame(GL10 gl) {
...
mMarkerCount = 0;
...
}
protected void foundFrameMarker(int markerId, Vector3 position, Quaternion orientation) {
mMarkerCount++;
...
}发布于 2017-09-19 15:28:52
@yakobom答案解决了这个问题,但它重复计算每个帧,因此我添加了一些代码:我初始化了另一个int以获得mMarkerCount所达到的mMarkerCount计数,在onCreate(...)中的activity中,我添加了一个计时器,它每秒钟刷新一次,将其设置为TextFeild并重置最大值。
在onCreate中的活动类中:
Thread t = new Thread() {
@Override
public void run() {
try {
while (!isInterrupted()) {
Thread.sleep(1000);
runOnUiThread(new Runnable() {
@Override
public void run() {
te.setText(mRenderer.max+"");
mRenderer.max=0;
}
});
}
} catch (InterruptedException e) {
}
}
};
t.start();在Renderer课堂上:
protected void foundFrameMarker(int markerId, Vector3 position,
Quaternion orientation) {
...
mMarkerCount++;
if (mMarkerCount > max)
max = mMarkerCount;
...
}https://stackoverflow.com/questions/46253892
复制相似问题