Log in or register to post comments

Augmented reality for beginners

November 23, 2010 - 3:48am #1

Hi,this is kesava, i had a question that by using qualcomm we can develop any type of application like image recognization and gps based?

Re: Augmented reality for beginners

February 27, 2011 - 5:52am #115

The origin of the coordinate system is in the center of the target. Positive X is to the right, positive Y is towards the top, and positive Z comes up out of the target (perpendicular to it). You can see a diagram in the Developer Guide: https://ar.qualcomm.com/qdevnet/developer_guide

Click on the Trackables section, and scroll down to the Coordinate Systems section.

- Kim

Re: Augmented reality for beginners

February 26, 2011 - 9:22am #114

Hi siva, at which point virtual object is appearing, bcoz so many markings are there in the image target, can i know where the exact information is available in this site.

Re: Augmented reality for beginners

February 24, 2011 - 12:34pm #113

Have you tried a variety of scales? It's tough to help without more info, can you see the object at all? You can set that number as high as you'd like, it's just a multiplier on the existing scale of the object (not a percentage). Try 200, or 500, etc.

- Kim

Re: Augmented reality for beginners

February 24, 2011 - 1:56am #112

Thank u siva, hi siva, my image target is very very small and the virtual object appearing is also small , i want to increase my size of the virtual object and i changed the kobject scale to 100 but it was not appearing big. thank u

Re: Augmented reality for beginners

February 22, 2011 - 7:02am #111

140 MB? How many triangles are in your model? Make sure that the models you use are relatively low poly, you can't just grab any model from the net and hope it works on mobile devices. I would use 20K triangles as a good starting point for an upper bound, you can probably go higher but the performance will decline as you add more.

Are you sure that you've triangulated the model as robertross suggested? You can also get holes by trying to render a model with quads (rectangular primitives) in OpenGL, which only supports triangles.

Finally, you can send the models to

if you're really stuck, and I'll take a look. Send the original model, not the header file.

- Kim

Re: Augmented reality for beginners

February 22, 2011 - 2:01am #110

siva, its not working any suggestion?
siva, i had generated one apk, so that its size is 13mb. any limitation is there for the apk?
header file size is 140mb.

Re: Augmented reality for beginners

February 21, 2011 - 10:13am #109

Sure, try it with the triangle strips, and also try it with just triangles.

- Kim

Re: Augmented reality for beginners

February 21, 2011 - 10:05am #108

the header file contains these arrays

glVertexPointer(3, GL_FLOAT, 0, OBJVerts );
glNormalPointer(GL_FLOAT, 0, OBJNormals);
glTexCoordPointer(2, GL_FLOAT, 0, OBJTexCoords);

glDrawArrays(GL_TRIANGLES, 0, OBJNumVerts);

so that i had modified in the cpp file based on the above generated arrays and some of the textures are missing.

I can go with glDrawArrays(GL_TRIANGLE_STRIP, 0, OBJNumVerts) ?

Re: Augmented reality for beginners

February 21, 2011 - 6:51am #107

The source of the model should tell you how it's been exported, there's no real way of knowing by just looking at the file (although you could guess by looking at the arrays and following the pattern of vertices). You could try drawing it with strips instead of triangles to see if it looks any better. You could also open the model in a 3D program such as Blender and then reexport it yourself, so you can carefully control all the settings and know what it is you're importing.

- Kim

Re: Augmented reality for beginners

February 19, 2011 - 10:32am #106

i had taken 3d models from net so that how can i determine 3d models contain triangle strips and correspoding methods in opengl to render object correctly.

Re: Augmented reality for beginners

February 19, 2011 - 9:38am #105

thanks siva, after converting 3d model to header file i am getting some values to the below attributes
vertices
faces
normals
texture coordinates
but some of the models are rendering correctly, while some 3d models are not rendering .

Re: Augmented reality for beginners

February 18, 2011 - 6:19am #104

http://www.khronos.org/opengles/sdk/2.0/docs/man/
http://www.khronos.org/opengles/sdk/1.1/docs/man/

You are going to need a basic understanding of OpenGL to get started here. Having a model that looks correct in a modeling program isn't enough, there are many ways to export a model and only some of them will work with OpenGL. I'm sorry we can't help more, but this isn't really an AR problem, this is something you have to learn to do any 3D rendering on these devices.

- Kim

Re: Augmented reality for beginners

February 17, 2011 - 11:49pm #103

I have done this but it is not working . with the help of opengl how can i create a semi circle shape(chain) plz provide any code regarding thatin opengl, it will help me

Re: Augmented reality for beginners

February 17, 2011 - 8:22am #102

Before exporting did you click triangulate in the exporting options? (if using Blender)
This converts your polygons to triangles which can then be rendered properly by openGL ES.

Re: Augmented reality for beginners

February 17, 2011 - 3:17am #101

i mean to say that virtual object (eg car) as all having holes on the body of the car, but the virtual object appearing in the modeling software was very good. can u help me out. Thanku very much

Re: Augmented reality for beginners

February 17, 2011 - 2:12am #100

Thanks siva, its working but the virtual object having small-small gaps in whole object( for all virtual objects it was appearing like that only). can u help me

Re: Augmented reality for beginners

February 16, 2011 - 11:20am #99

One way is to apply a texture, that will usually give you the nicest looking results.

If you are using OpenGL ES 1.1 you can set a color using glColor4f. The sample applications default to OpenGL ES 2.0, however. In GLES 2.0, you can either write a shader that applies a particular color, or you can bind an array of color values, one for each vertex.

You might find it easiest to modify the fragment shader in CubeShaders.h. Simply replace this line:

gl_FragColor = texture2D(texSampler2D, texCoord);

with something like this:

gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

Where the values are red, green, blue, alpha.

Be sure to rebuild the native library using ndk-build after making changes to the shaders.

- Kim

Re: Augmented reality for beginners

February 15, 2011 - 11:23pm #98

Thanks siva for u response, here watever the virtual objects are adding are appearing black in color, so i want to change the object color,can u help me

Re: Augmented reality for beginners

February 15, 2011 - 10:16am #97

Faces sounds like it might be the same thing as indices, but only if it contains an index that can be used for all three other arrays (vertices, normals, texcoords) and not one index per array. For OpenGL, you want the vertex, normal, and texcoord arrays to all be the same length. Then either you traverse these arrays, using every three elements to define a triangle, or you have an index array that points into them, with every three elements of the index array making a triangle. If you are using triangle strips the offsets change a little bit, but that's the basic idea.

Where did you get the model from, and how did you get it into the header format? It's important to understand how your model was exported to know how to use it with OpenGL.

Finally, if your model has indices you use glDrawElements, and if it doesn't you use glDrawArrays.

- Kim

Re: Augmented reality for beginners

February 15, 2011 - 8:48am #96

Thanks siva, i want to use framemarkers to put my virtual object such as goldchain, but in framemarkers example it contains indices as well as numindices attributes and gldrawelements

but in my 3dmodel i dont have these attributes
my headerfile contains faces,normals,vertices,texturecoords
and gldrawarrays

can u help me.

Re: Augmented reality for beginners

February 14, 2011 - 9:39am #95

You'll need to play around with that translatePoseMatrix method call. It translates along X, Y, and Z, from the center of the target. X is to the right, Y is towards the top of the target, and Z is coming up out of the target (perpendicular to it).

Try setting X, Y, and Z all to 0 first, then see which axis you need to adjust.

SampleUtils::translatePoseMatrix(0.0f, 0.0f, 0.0f,
                                 &modelViewMatrix.data[0]);

- Kim

Re: Augmented reality for beginners

February 14, 2011 - 9:32am #94

Thanks siva, previously u told that rotation of the axis

i changed like this,

SampleUtils::rotatePoseMatrix(90.0f, 0.1f, 0.0f, 0.0f,
&modelViewMatrix.data[0]);

but the object is appearing so much above to the target, how can i get close towards the target.please help me

Re: Augmented reality for beginners

February 14, 2011 - 6:09am #93

Are you trying to apply multiple textures to a single model? You'll want to bind a texture, and then render only the geometry that belongs to that texture.

A common problem is flipped texture coordinates, you may need to flip your image vertically to get it to look right.

- Kim

Re: Augmented reality for beginners

February 14, 2011 - 1:28am #92

Thanks siva, while i am seeing the virtual object some of the textures are missing or not filling.can u help me out

Re: Augmented reality for beginners

February 13, 2011 - 1:59pm #91

Look at the SampleUtils rotatePoseMatrix method. Add a rotation around the correct axis, for example, the following code rotates 90 degrees around the X axis:

SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                 &modelViewMatrix.data[0]);
SampleUtils::rotatePoseMatrix(90.0f, 1.0f, 0.0f, 0.0f,
                              &modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                             &modelViewMatrix.data[0]);
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                            &modelViewMatrix.data[0],
                            &modelViewProjection.data[0]);

- Kim

Re: Augmented reality for beginners

February 13, 2011 - 4:50am #90

Thanks siva its working, but the virtual object is appearing vertically, i want to change to appear as horizontally, can u help me.

Re: Augmented reality for beginners

February 10, 2011 - 8:56am #89

Yep, give that a try. You'll probably have to play around with the value until the scale looks right.

- Kim

Re: Augmented reality for beginners

February 10, 2011 - 8:52am #88

kObjectScale=3.f in the samples project, so i need to change to 100.f is it?
Thanks siva

Re: Augmented reality for beginners

February 10, 2011 - 5:00am #87

In the samples, you can change the value of the kObjectScale variable (in ImageTargets.cpp for instance) to adjust the scale of the object. Try a larger value, something like 100 perhaps.

- Kim

Re: Augmented reality for beginners

February 9, 2011 - 11:16pm #86

I included the object (Eg: car),which is appearing very very small like a ant in the phone.I got this from net, the header file size is 5.5mb how to increase the size of the object (car). can u help me please. asap.

Re: Augmented reality for beginners

February 9, 2011 - 11:11pm #85

Thanks siva,

Re: Augmented reality for beginners

February 9, 2011 - 7:41am #84

You can't use hyphens (-) in you variable names. If you've named your model "L200-OBJ", then the perl script is probably creating arrays with hypens in the name. Try using an underscore instead, like "L200_OBJ".

- Kim

Re: Augmented reality for beginners

February 9, 2011 - 4:03am #83

when i am building my ndk-build, i am getting error like this

compile ++arm : ImageTargets In file Included from /cygdrive/c/Development/Android/qcar-sdk/......./ImageTargets.cpp:38:
/cygdrive/c/Development/Android/qcar-sdk/......./jni/L200-OBJ.h:23:error:expected initalizer before '-' token

L200-OBJ is my 3d object

/cygdrive/c/Development/Android/qcar-sdk/......./ImageTargets.cpp: error:
L200 was not declared in scope
OBJVerts was not declared in scope

Re: Augmented reality for beginners

February 8, 2011 - 6:04am #82

If you are using a frame marker, then the only thing you need to do is place the id of the frame marker in the config.xml file (located in the assets folder). See the FrameMarker sample, it can track four frame markers, ids 0-3. You can place any image you want inside the frame marker, but it is not used for tracking.

- Kim

Re: Augmented reality for beginners

February 7, 2011 - 10:02pm #81

i had created own marker for my goldchain, i want to include my own marker what further modifications is to be done in the markerpart thing, can u help me.

Re: Augmented reality for beginners

February 7, 2011 - 6:52am #80

Just use the FrameMarkers sample as a starting point. Rendering 3D content isn't any different for frame markers than it is for image targets. You just need to use the correct model data according to which marker is visible. Look at the FrameMarkers.cpp file, at the renderFrame method. Currently the sample switches between the Q, C, A, and R letter models, depending on which marker ids are visible.

- Kim

Re: Augmented reality for beginners

February 7, 2011 - 4:37am #79

Thanks siva, for the gold chain i want to use frame-markers as a target, so that want what changes i need to do? can u help me

Re: Augmented reality for beginners

February 4, 2011 - 7:12am #78

I'd start with modeling software like "Blender".
Search google for some tutorials.
Then file > export > Wavefront (.obj) and at the menu select Triangulate, UV's, Normals and objects then hit export.

You can then use this program here: http://heikobehrens.net/2009/08/27/obj2opengl/
To translate the obj to something that can be read by the sample programs.
A quick tweak here and there and you're good to go.

Rob.

Re: Augmented reality for beginners

February 4, 2011 - 5:52am #77

Yeah, your best bet is to use a modeling program to create the content OpenGL will render. It is possible to render simple objects by hand in OpenGL, but you really only have lines and triangles to work with, so it's tedious (and the results aren't very pretty). This isn't the place to learn how to model though, sorry!

- Kim

Re: Augmented reality for beginners

February 4, 2011 - 1:58am #76

It's possible to make any shape instead of a teapot whether its a gold chain, a semi-circle or a Mary Poppins replica. If you can make it, you can replace it.

Re: Augmented reality for beginners

February 3, 2011 - 10:19pm #75

Hi siva, with the help of opengl is it possible to draw a semi circle shape ( as a virtual object) instead of teapot.

Re: Augmented reality for beginners

February 3, 2011 - 5:38am #74

Here's one way:

Export your model as a .obj file. Most modeling programs can do this (including Blender, which is free).

Use this perl script to convert it to a header file with arrays:
http://heikobehrens.net/2009/08/27/obj2opengl/

In ImageTargets.cpp, include your new header file. Then change the OpenGL rendering code in the renderFrame method to use your new model data, instead of the teapot data. Finally, you will need to use glDrawArrays instead of glDrawElements, as that script does not produce an indices array.

Changes to OpenGL ES 1.1 code:

        // Draw object:
        glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
        glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &goldchainTexCoords[0]);
        glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &goldchainVertices[0]);
        glNormalPointer(GL_FLOAT, 0,  (const GLvoid*) &goldchainNormals[0]);
        glDrawArrays(GL_TRIANGLES, 0, goldchainNumVerts);

Changes to OpenGL ES 2.0 code:

        glUseProgram(shaderProgramID);
        
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &goldchainVerts[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &goldchainNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                              (const GLvoid*) &goldchainTexCoords[0]);
        
        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);
        
        glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
                           (GLfloat*)&modelViewProjection.data[0] );
        glDrawArrays(GL_TRIANGLES, 0, goldchainNumVerts);

Finally, you might need to change the value of kObjectScale to scale your model up or down.

Be sure to run ndk-build again after making changes to the native code, and then clean your Eclipse project before running the application.

- Kim

Re: Augmented reality for beginners

February 2, 2011 - 11:09pm #73

Instead of Tea-pot as a virtual object, i need to place a gold chain, how it can be done

Re: Augmented reality for beginners

January 6, 2011 - 4:04am #72

It works as a black and white printout or even an on screen image.

Re: Augmented reality for beginners

January 5, 2011 - 10:41pm #71

Is i need to take color printout of the ImageTargets chips & stones to detect infront of the mobile camera view.

Re: Augmented reality for beginners

January 3, 2011 - 6:54am #70

A Clean really should have helped with this. You could also try "fixing" the project properties by right-clicking on the project in the Package Explorer and choosing Android Tools > Fix Project Properties.

Also, we highly recommend upgrading to version 0.10.0 of the QCAR SDK, available on the SDK main page: https://ar.qualcomm.com/qdevnet/sdk

Version 0.10.0 no longer has the Shared project, and building the samples is a bit simpler.

- Kim

Re: Augmented reality for beginners

January 3, 2011 - 12:40am #69

when i get shared folder in ecllipse, it was executing properly where as in the case of
importing the Imagetargets into ecllipse, i am getting 2 errors like

1)Error generating final archive : java.io.filenotfoundexception,
type : android packaging problem
Location : unknown

2) unparsed aapt error(s)!check the console for output
type : android packaging problem
Location : unknown

plz reply me

Re: Augmented reality for beginners

December 29, 2010 - 5:51pm #68

Try cleaning the project:

Project > Clean... > Clean Projects Selected Below (select your project)

It might take a couple tries to get it to build correctly.

- Kim

Re: Augmented reality for beginners

December 29, 2010 - 5:44pm #67

When i am importing the Imagetargets in the ecllipse i am getting the error

unknownerrror:java.lang.NullpointerEception --- androidpackagingproblem

plz reply me asap

Re: Augmented reality for beginners

December 29, 2010 - 6:57am #66

We recommend Eclipse for the Java code and for building/running the Android application. The native code is built from the command line using ndk-build. You can use any IDE you'd like for the native (.cpp) code. Some people use Eclipse, others use Visual Studio or Xcode. That's up to you.

- Kim

Log in or register to post comments