albersmc / android-augment-reality-framework

Automatically exported from code.google.com/p/android-augment-reality-framework
GNU General Public License v3.0
0 stars 0 forks source link

How to optimize the rendering performance for AR Objects(Markers) #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the expected output? What do you see instead?
 - Slow rendering of AR(Augmented Reality) Objects(Markers)

What version of the product are you using? On what operating system?
 - Android

Please provide any additional information below.
Can you please tune your code for best rendering performance?
The frame-rate for rendering the AR scene when the camera moves.
Or, can you share the clue for optimizing the rendering performance by myself 
in the code?

Original issue reported on code.google.com by ali.yas...@gmail.com on 26 Dec 2013 at 10:20

GoogleCodeExporter commented 9 years ago
The code has been optimized for performance already. Are you using collision 
detection? That'll cause some slowness in rendering.

The first places to look are the SensorsActivity class and the Marker class. 
The SensorsActivity class does the heavy math of converting your 3D position 
into a 2D position. The Marker update method is used to update each Markers 
matricies based upon the matricies calculated in SensorsActivity, the draw 
method is used to update the graphical representation of the Marker based upon 
the matricies populated in the update method. Also check out the 
AugmentedReality class because it ties those two classes together.

Original comment by phishman3579@gmail.com on 26 Dec 2013 at 3:05

GoogleCodeExporter commented 9 years ago

Original comment by phishman3579@gmail.com on 26 Dec 2013 at 3:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Also.. You may think it's rendering slowly but it's the low pass filter (which 
is used to smooth out the Markers). Disable the LowPassFilter by making alpha 1 
in the class or by removing it all together in SensorsActivity by commenting 
out the lines below:

        if (evt.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
/*
            smooth = LowPassFilter.filter(0.5f, 1.0f, evt.values, grav);
            grav[0] = smooth[0];
            grav[1] = smooth[1];
            grav[2] = smooth[2];
*/
            grav[0] = evt.values[0];
            grav[1] = evt.values[1];
            grav[2] = evt.values[2];
        } else if (evt.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
/*
            smooth = LowPassFilter.filter(2.0f, 4.0f, evt.values, mag);
            mag[0] = smooth[0];
            mag[1] = smooth[1];
            mag[2] = smooth[2];
*/
            mag[0] = evt.values[0];
            mag[1] = evt.values[1];
            mag[2] = evt.values[2];
        }

Original comment by phishman3579@gmail.com on 27 Dec 2013 at 12:07

GoogleCodeExporter commented 9 years ago
If you update your repo; I've added a boolean called useSmoothing in 
AugmentedReality which you can use to enable and disable smoothing. It's is 
enabled by default.

Original comment by phishman3579@gmail.com on 27 Dec 2013 at 12:41

GoogleCodeExporter commented 9 years ago
And one last thing... You'll likely "see" better performance by setting 
"SENSOR_DELAY_GAME" in SensorsActivity:

sensorMgr.registerListener(this, sensorGrav, SensorManager.SENSOR_DELAY_GAME);
sensorMgr.registerListener(this, sensorMag, SensorManager.SENSOR_DELAY_GAME);

Original comment by phishman3579@gmail.com on 27 Dec 2013 at 3:18

GoogleCodeExporter commented 9 years ago
Awesome phishman! you did a great work. i have downloaded the latest code 
having "useSmoothing" variable, previously it was not exists. Secondly, i 
changed "SENSOR_DELAY_GAME" to "SENSOR_DELAY_FASTEST" with "useSmoothing=true". 
After that, the result was just awesome..
Anyways, i also want to see one thing more in this opensource project, that is,
- App should work fine both in Landscape and Portrait mode auto orientation 
change. Currently, developers are bound to only support single mode at a time.

Original comment by ali.yas...@gmail.com on 27 Dec 2013 at 7:10

GoogleCodeExporter commented 9 years ago
Yea, I haven't find a elegant way to detect and auto orient the markers. I am 
still looking into it.

Original comment by phishman3579@gmail.com on 30 Dec 2013 at 8:36

GoogleCodeExporter commented 9 years ago

Original comment by phishman3579@gmail.com on 30 Dec 2013 at 8:36

GoogleCodeExporter commented 9 years ago
Mixare has implemented such a functionality (auto-rotate the marker on 
orientation change).  I am not an AR Expert, so i cant modify your code for 
such a complex feature but can refer you to see the mixare code, so that you 
will be definitely able to develop this feature in no time.

Original comment by ali.yas...@gmail.com on 1 Jan 2014 at 7:15

GoogleCodeExporter commented 9 years ago
I actually have most of what I need already implementation. I am still working 
on the "touch" and "collision" detection. Once that is complete I'll merge into 
master. If you don't need those features, you can use the rotation_branch of 
the AR code.

https://code.google.com/p/android-augment-reality-framework/source/browse/?name=
rotation_branch

Original comment by phishman3579@gmail.com on 2 Jan 2014 at 2:22

GoogleCodeExporter commented 9 years ago
that's nice. thanks a lot. that's what i need.

Original comment by ali.yas...@gmail.com on 3 Jan 2014 at 7:03

GoogleCodeExporter commented 9 years ago
OK, great. Let me know if you run into any problems.

Original comment by phishman3579@gmail.com on 3 Jan 2014 at 12:34

GoogleCodeExporter commented 9 years ago
I don't think you need the features but I found a solution to "touch" and 
"collision detection". I believe the rotation_branch is 100% in working 
condition with auto-rotation of Markers. Once I am done testing, I'll likely 
merge into master.

Original comment by phishman3579@gmail.com on 3 Jan 2014 at 9:35

GoogleCodeExporter commented 9 years ago
sure

Original comment by ali.yas...@gmail.com on 4 Jan 2014 at 10:11