Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AugTech

Pages: 1 [2] 3 4 5
16
Support / Re: Info on calcAngle on SimpleVector
« on: January 09, 2014, 01:32:11 pm »
I know its an old thread, but after working on this for some time I found the following link that provides a solution to create an angle between -180' and +180' (in rads)

http://answers.unity3d.com/questions/24983/how-to-calculate-the-angle-between-two-vectors.html

Hope this helps someone else!

17
Support / Re: multi-thread unsafe operations
« on: December 19, 2013, 03:37:06 pm »
Basically the whole screen as a map;


18
Support / Re: multi-thread unsafe operations
« on: December 19, 2013, 03:07:22 pm »
Creation and texture loading (note that this part is multi-threaded and gets called for each tile loaded);

Code: [Select]
ArrayList<ARObject3D> allNewObjects = new ArrayList<ARObject3D>();

RGBColor transCol = (RGBColor)fType.getUserData().get(USER_DATA.COLOR_TRANSPARENT);
boolean makeTrans = transCol!=null && AwilaARView.USE_TRANSPARENT_RASTERS;

// Load the image to the graphics manager
byte[] bitmapData = (byte[]) feature.getAttribute(AttributeTypeImpl.IMAGE_NAME);
Bitmap bmp = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);

if (makeTrans && bmp!=null) {
bmp = GraphicsManager.getTransparentBitmap(bmp, transCol);
}

GraphicsManager.loadTexture(bmp, feature.getID(), bmp.getWidth());

// Recycle image as large...
bmp.recycle();

// Transform native bounds to lat/ lon
BoundingBox latLon = null;
try {
latLon = ProjectionUtils.reproject( feature.getBounds(), "epsg:4326");
} catch (Exception e) {
e.printStackTrace();
continue;
}
Object3D tmp = ARObjectBuilder.getPlane(latLon, trasnformECEF );

ARObjectTile obj = new ARObjectTile(tmp, feature.getID() );
feature.addObject3D(obj);
allNewObjects.add(obj);


JpctRenderer.addRemoveObjects(allNewObjects, JpctRenderer.SCENE_ADD_OBJECTS);

Load texture method;

Code: [Select]
public static String loadTexture(Bitmap bitmap, String textureName, int size) {
if (bitmap == null) return null;
if (textureName == null || textureName.equals(TEXTURE_NONE)) {
textureName = UUID.randomUUID().toString();
}
if (TextureManager.getInstance().containsTexture(textureName)) {
return textureName;
}

// Only rescale if we have to
int upper2 = upperPowerOfTwo(size);
if (upper2!=size) bitmap = BitmapHelper.rescale(bitmap, upper2, upper2);

TextureManager.getInstance().addTexture(textureName, new Texture(bitmap) );

return textureName;
}

The JpctRenderer.addRemoveObjects() method creates a Message and sends to the handler, which adds the new objects in to a Stack<ARObject3D>
During the onDrawFrame() method, the following is called/ run;

Code: [Select]
int size = objectAddList.size();
while (!objectAddList.isEmpty()) {

ARObject3D obj = objectAddList.pop();
obj.build();
theWorld.addObject(obj);
objsAdded = true;
Log.d(LOG_TAG, String.format("Added %s 1 of %s", obj.getParentFeatureID(), size ));
}

The resultant Logcat;

Code: [Select]
12-19 13:49:47.165: D/dalvikvm(23790): GC_EXPLICIT freed 1459K, 40% free 26192K/42964K, paused 11ms+5ms, total 85ms
12-19 13:49:47.165: D/Awila Renderer(23790): World was 26, now 1
12-19 13:49:50.027: I/Data Manager(23790): Loading data...
12-19 13:49:50.067: I/Data Manager(23790): osm:OSM Maps requesting 9 tiles..
12-19 13:49:51.379: I/Data Manager(23790): 1 received of 9 in OSM Maps; (1 of 9 total)
12-19 13:49:51.389: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.399: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.419: I/Data Manager(23790): 2 received of 9 in OSM Maps; (2 of 9 total)
12-19 13:49:51.419: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.429: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.439: I/Data Manager(23790): 3 received of 9 in OSM Maps; (3 of 9 total)
12-19 13:49:51.439: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.439: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.449: I/Data Manager(23790): 4 received of 9 in OSM Maps; (4 of 9 total)
12-19 13:49:51.459: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.459: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.459: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.459: D/Awila Renderer(23790): Added OSM Maps-49-8094-5393-14 1 of 4
12-19 13:49:51.459: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.459: D/Awila Renderer(23790): Added OSM Maps-47-8095-5391-14 1 of 4
12-19 13:49:51.459: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.469: D/Awila Renderer(23790): Added OSM Maps-50-8095-5393-14 1 of 4
12-19 13:49:51.469: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.469: D/Awila Renderer(23790): Added OSM Maps-48-8095-5392-14 1 of 4
12-19 13:49:51.469: I/Data Manager(23790): 5 received of 9 in OSM Maps; (5 of 9 total)
12-19 13:49:51.479: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.479: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.489: I/Data Manager(23790): 6 received of 9 in OSM Maps; (6 of 9 total)
12-19 13:49:51.489: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.489: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.499: I/Data Manager(23790): 7 received of 9 in OSM Maps; (7 of 9 total)
12-19 13:49:51.509: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.509: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.519: I/Data Manager(23790): 8 received of 9 in OSM Maps; (8 of 9 total)
12-19 13:49:51.519: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.519: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.529: I/jPCT-AE(23790): Subobject of object 529/object531 compiled to indexed fixed point data using 6/4 vertices in 0ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Object 529/object531 compiled to 1 subobjects in 2ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Subobject of object 527/object529 compiled to indexed fixed point data using 6/4 vertices in 1ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Object 527/object529 compiled to 1 subobjects in 1ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Subobject of object 525/object527 compiled to indexed fixed point data using 6/4 vertices in 0ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Object 525/object527 compiled to 1 subobjects in 1ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Subobject of object 523/object525 compiled to indexed fixed point data using 6/4 vertices in 1ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Object 523/object525 compiled to 1 subobjects in 1ms!
12-19 13:49:51.529: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.529: D/Awila Renderer(23790): Added OSM Maps-53-8094-5391-14 1 of 4
12-19 13:49:51.529: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.529: D/Awila Renderer(23790): Added OSM Maps-54-8093-5391-14 1 of 4
12-19 13:49:51.539: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.539: D/Awila Renderer(23790): Added OSM Maps-52-8094-5392-14 1 of 4
12-19 13:49:51.539: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.539: D/Awila Renderer(23790): Added OSM Maps-51-8093-5393-14 1 of 4
12-19 13:49:51.539: I/Data Manager(23790): 9 received of 9 in OSM Maps; (9 of 9 total)
12-19 13:49:51.549: I/jPCT-AE(23790): Loading Texture...
12-19 13:49:51.549: I/jPCT-AE(23790): Texture loaded...262144 bytes/256*256 pixels!
12-19 13:49:51.589: I/jPCT-AE(23790): Subobject of object 537/object539 compiled to indexed fixed point data using 6/4 vertices in 0ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Object 537/object539 compiled to 1 subobjects in 1ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Subobject of object 535/object537 compiled to indexed fixed point data using 6/4 vertices in 1ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Object 535/object537 compiled to 1 subobjects in 1ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Subobject of object 533/object535 compiled to indexed fixed point data using 6/4 vertices in 0ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Object 533/object535 compiled to 1 subobjects in 1ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Subobject of object 531/object533 compiled to indexed fixed point data using 6/4 vertices in 0ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Object 531/object533 compiled to 1 subobjects in 0ms!
12-19 13:49:51.599: I/jPCT-AE(23790): Normal vectors calculated in 0ms!
12-19 13:49:51.599: D/Awila Renderer(23790): Added OSM Maps-55-8093-5392-14 1 of 1
12-19 13:49:51.659: I/jPCT-AE(23790): Subobject of object 539/object541 compiled to indexed fixed point data using 6/4 vertices in 1ms!
12-19 13:49:51.659: I/jPCT-AE(23790): Object 539/object541 compiled to 1 subobjects in 1ms!


The end result;



Originally I did think it was texture loading, but the objects all have obj.setAdditionalColor(128,128,128) applied, and as you can see, nothing is grey!

Mike

19
Support / Re: multi-thread unsafe operations
« on: December 19, 2013, 12:22:24 pm »
In terms of the original question, is object creation and texture loading thread-safe?

I am creating objects and loading textures in a separate thread and then passing the objects to a Handler in the renderer which adds them to the world from a Stack in onDrawFrame(). Randomly these objects are not being displayed (incidentally all the objects are map tiles - 2 triangles with one texture).

Logcat reports that 9 textures are loaded, 9 objects are added to the world/ compiled, but potentially only 4 will actually be displayed.

Should texture's be loaded and/ or objects created in the render thread as well as adding?



20
Support / Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: December 18, 2013, 02:15:13 pm »
Wasn't aware OpenCV had an Android implementation.. Have to look that up when I have the change.

Can't help with the canvas much, but with Vuforia you could always nobble the part that actually checks for Trackable's and just utilise the camera preview segments, although possibly a bit heavy handed.

Code: [Select]
JNIEXPORT void JNICALL
Java_com_augtech_awilaSDK_graphics_JpctRenderer_renderFrame(JNIEnv* env, jobject obj) {

   jclass activityClass = env->GetObjectClass(obj); //We get the class of our graphics engine

    // Clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Get the state from QCAR and mark the beginning of a rendering section
    QCAR::State state = QCAR::Renderer::getInstance().begin();

    // Explicitly render the Video Background
    QCAR::Renderer::getInstance().drawVideoBackground();

21
Support / Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: December 18, 2013, 01:40:50 pm »
The QCAR/ Vuforia is not OpenSource, but it is free to use in private and commercial apps; https://developer.vuforia.com/legal/license/2-8

Which bit can't you use (commercial reasons or technical?)

Code: [Select]

frameBuffer.clear(background);

/* Call our native QCAR function to render the video
 * background and scan images for recognition */
renderFrame();

// Render the AR data to the jPCT scene
theWorld.renderScene(frameBuffer);
theWorld.draw(frameBuffer);

// Display our content...
frameBuffer.display();

22
Support / Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: December 18, 2013, 01:21:08 pm »
You can do this using the Vuforia SDK - That provides the image recognition and camera rendering via one 'renderFrame()' call which goes in the onDrawFrame method along with Jpct.
There's a pretty good article on the Wiki which I followed (mostly) to do just that.

23
Support / Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: December 17, 2013, 05:36:09 pm »
Unfortunately I can't answer your question directly (as to why), but I struggled for sometime getting a stable implementation whereby the AR data was always on top of the camera, especially whilst toggling the camera preview on and off.
I always implemented this in code, not using a layout as follows;

In the main activity onCreate method, in this order;

Create the CameraPreview.
Create the SurfaceView (with renderer)

In the CameraPreview constructor;
Code: [Select]
    RelativeLayout tmpLayout = new RelativeLayout( appContext );
    tmpLayout.addView(this, 0,
    new LayoutParams(
    LayoutParams.FILL_PARENT,
    LayoutParams.FILL_PARENT)
    );
    activity.setContentView(tmpLayout);

In the SurfaceView constructor;
Code: [Select]
        setEGLContextClientVersion(2);

setEGLConfigChooser(new AAConfigChooser(this, true));

getHolder().setFormat(PixelFormat.TRANSLUCENT);

// Setup the renderer
mRenderer = new JpctRenderer( mainARView.orientationListener.tabletMode );
Activity activity = (Activity)mainARView.appContext;

// Add this view to the main activity
        setZOrderMediaOverlay(true);
    activity.addContentView(this, new LayoutParams(
    LayoutParams.FILL_PARENT,
    LayoutParams.FILL_PARENT));

If you want a UI on-top of both, do this in the main activity after creating the SurfaceView;
Code: [Select]
uiScreen = new UserInterfaceView(this);
addContentView(uiScreen, fillLayout);

In onResume;
Code: [Select]
camScreen.start();
augScreen.setVisibility(View.VISIBLE);
augScreen.onResume();

In onPause;
Code: [Select]
augScreen.setVisibility(View.INVISIBLE);
augScreen.onPause();
camScreen.stop();

Hope this helps.

M

24
Support / Re: NullPointer in queue
« on: September 05, 2013, 07:53:30 pm »
That got it, thank you. Now all removals and additions are done via messages and Stack's

25
Support / Re: NullPointer in queue
« on: September 03, 2013, 09:51:59 am »
Okay. So when you say render thread, should this be the onDrawFrame method; i.e. it reads from a synchronized list that has been populated by a Message() to completely detach from the rest of the app? (Object creation in another thread)

Cheers.

26
Support / NullPointer in queue
« on: September 02, 2013, 08:53:58 pm »
Hi.
I'm getting a reasonably regular, but quite random crash as below. It appears to happen after deleting objects from the world;

Code: [Select]
09-02 19:13:22.063: I/jPCT-AE(13962): [ 1378145602065 ] - ERROR: Null object in queue...?
09-02 19:13:22.103: W/dalvikvm(13962): threadid=11: thread exiting with uncaught exception (group=0x41050450)
09-02 19:13:22.103: E/AndroidRuntime(13962): FATAL EXCEPTION: GLThread 551
09-02 19:13:22.103: E/AndroidRuntime(13962): java.lang.RuntimeException: [ 1378145602065 ] - ERROR: Null object in queue...?
09-02 19:13:22.103: E/AndroidRuntime(13962): at com.threed.jpct.Logger.log(Logger.java:193)
09-02 19:13:22.103: E/AndroidRuntime(13962): at com.threed.jpct.World.renderScene(World.java:1029)
09-02 19:13:22.103: E/AndroidRuntime(13962): at com.augtech.awilaSDK.graphics.JpctRenderer.onDrawFrame(JpctRenderer.java:162)
09-02 19:13:22.103: E/AndroidRuntime(13962): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
09-02 19:13:22.103: E/AndroidRuntime(13962): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

Any pointers on what I should be looking for/ changing to stop this happening?
Many thanks in advance.

27
Support / Re: Augmented reality using JPCT-AE with OpenCV
« on: May 03, 2013, 12:04:00 pm »
You could always use the Android camera parameters to get FOV values and then apply these to the WorldCamera...

In your camera class
Code: [Select]
        Camera.Parameters cameraParams = mCamera.getParameters();
        float hva = cameraParams.getHorizontalViewAngle();
        float vva = cameraParams.getVerticalViewAngle();

and then in the render class
Code: [Select]
Camera worldCamera = theWorld.getCamera();
float wid = worldCamera.convertDEGAngleIntoFOV( hvAngle );
float hig = worldCamera.convertDEGAngleIntoFOV( vvAngle );
worldCamera.setFOV( wid );
worldCamera.setYFOV( hig );

I use this method and it works fine except when rotating the device to portrait - The values should really be re-calculate when the camera activity is rotated (like in Wikitude), but I haven't implemented that as yet  :)

To answer one of your questions, the axis description is at http://www.jpct.net/wiki/index.php/Coordinate_system

28
Support / Re: Ground clamping through calcMinDistance with .obj's help
« on: February 09, 2013, 07:15:33 pm »
I'll certainly check that out stray vertices...

Quote
No, why should it?
I wasn't suggesting it should  ;) just wanted to check why I can't get my child item to follow the parent, whilst remaining clamped to the ground. I'm setting the child on the ground, but when the parent is moved the child gets translated off in another direction.

29
Support / Re: Ground clamping through calcMinDistance with .obj's help
« on: February 09, 2013, 04:50:07 pm »
Code: [Select]
interDist = plane.calcMinDistance( obj.getTransformedCenter(), upAxis );

if (interDist==Object3D.COLLISION_NONE) {
// translate -20 and re-test
}

if(!obj.isPlane) {
bbox = getWorldSpaceBounds(obj);
objHeight = bbox[3]-bbox[2];
}
// Do the clamping...
if (interDist!=Object3D.COLLISION_NONE) {
if(!obj.isPlane) {
Log.i(LOG_TAG, "Obj: "+obj.getParentFeatureID()+" Dist: "+interDist+" Height: "+objHeight/2);
}
trans.set( upAxis );
trans.scalarMul( interDist-obj.heightOffset-(objHeight/2) );
obj.translate( trans );
}

appears to sort all the models except one; this one reports an incorrect bounding box (a height of 16.8m instead of 10m), therefore the adjustment back to ground level is out.

30
Support / Re: Ground clamping through calcMinDistance with .obj's help
« on: February 09, 2013, 04:14:15 pm »
I mean, if a child has been translated by 20m on Y, then the parent get translated by 10 on X, does the child forget the previous 20m on Y?

Pages: 1 [2] 3 4 5