Hii, Does anyone know whether Vuforia provides API to display the frame rate per second during rendering the 3D Object?
Just don't use a Toast;
the tutorial explains you how to display a Toast, as a simple example of how to trigger something on the Java UI, but you should then use the UI components that you find most appropriate;
for instance, you could show a TextView (e.g. create the TextView in the onCreate method of your ImageTargets.java and then update its text value during tracking, using TextView.setText("some message") at runtime)
Thanks for the clarifications; now it looks clearer ;-)
the reason why the frame rate is higher when the target is detected (and the 3D augmentation is rendered) is most likely because the underlying Vuforia process to search and find a target in your image is rather expensive (thus impacting the frame rate), compared to the processing of just tracking the object in space (when it has already been found);
in other words, Vuforia scans and process your image and makes quite a bit of heavy calculations until the target is "found"; then, once it is found (detected) from that moment on, the target does not need to be discovered anymore, it just needs to be tracked in space (which is a fairly inexpensive process for the CPU), so the CPU has to do less computations and the frame rate goes up.
About your second question, you can take inspiration from this article, which explains how to do someting in Java (for instance show a view) when a target is detected:
Hii, Okay firstly I clarified my questions. I just realise that renderFrame() always get called as onDrawFrame() get called, am I right? what I found here is when my virtual object appear during tracking, its frame rate increases rather than decreases and I did not know what probably the cause is. And my second question, I intend to display frame rate only when my virtual object comes up.
Hi, concerning your first question, not sjure why the frame rate goes up (instead of going down as you would expect); but that could find its reason in how the rendering thread decides to update the view, I would not worry about that, unless you have specific concerns with that.
About your second question, I'm not sure to understand it; the renderFrame() method is called from within the onDrawFrame() in Java, so you can determine easily when that method is called the first time, just put some code in Java (for instance you can put an integer counter in Java, or similar solutions...)
Hi, thanks for your help. I have implemented as you said, however, I found out that the framerate during rendering frame is bigger than when renderFrame is not getting called (30 and 20 for each average frame rate) . do you have any idea why was it that?
second thing is, I want to start display framerate as renderFrame() get called, but the constraint is it return void value. How to check whenever a method get called or not?
You can use the function elapsedRealTime() to measure time deltas between consecutive calls to onDrawFrame() in ImageTargetsRenderer.java
see also here:
Note, once you have the time-delta in milliseconds, you can obtain the frame rate as follows:
double deltaTimeSeconds = deltaTimeMilliseconds / 1000.0;
double frameRate = 1.0 / deltaTimeSeconds;
Then, you can display your measurements in a TextView, as I said.
Yeah, I would prefer to do this in Java in the onDrawFrame() method. But in this method, I want to start counting frame rate as the renderFrame() get called. The problem is renderFrame() method return void so that I did not know what value to compare to start counting as renderFrame() get called. Can you give a hint how to do that in Java?
No, Vuforia does not have such API; however, implementing time measurement between consecutive frames can be done easily (you can do it either in CPP in the renderFrame() method, or in Java in the onDrawFrame() method of the Renderer class); the way you display the number on the screen is then up to your coding preferences (for instance you could use a TextView on the Java side)
Are you sure you want to delete this message?
Are you sure you want to delete this conversation?