Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7532239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:23:36+00:00 2026-05-30T05:23:36+00:00

I’m planning to build an Android App. based on Augmented Reality . I googled

  • 0

I’m planning to build an Android App. based on Augmented Reality. I googled it and also searched on SO, but have not found anything very much helpful.

What I want to do is when application is launched, it will start it’s camera and initiate the scanning of the pattern. If at any instance the pattern matches with the predefined pattern present in local database, it should perform a specific action.

I referred this tutorial
When I use the following code, these files get created on sdcard : patt.hiro , android.patt , barcode.patt.

On opening .patt file, there is a matrix consisting of values between 0-255. How can I use customized pattern through assets instead of these files?

CustomActivity.java

public class CustomActivity extends AndARActivity {

    CustomObject someObject;
    ARToolkit artoolkit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CustomRenderer renderer = new CustomRenderer();
        super.setNonARRenderer(renderer);
        try {   // register a object for each marker type
            artoolkit = super.getArtoolkit();
            someObject = new CustomObject("test", "patt.hiro", 80.0,
                    new double[] { 0, 0 });
            artoolkit.registerARObject(someObject);
            someObject = new CustomObject("test", "android.patt", 80.0,
                    new double[] { 0, 0 });
            artoolkit.registerARObject(someObject);
            someObject = new CustomObject("test", "barcode.patt", 80.0,
                    new double[] { 0, 0 });
            artoolkit.registerARObject(someObject);
        } catch (AndARException ex) {
        }
        startPreview();
    }
}

CustomObject.java

/** An example of an AR object being drawn on a marker. */
public class CustomObject extends ARObject {

    public CustomObject(String name, String patternName, double markerWidth,
            double[] markerCenter) {

        super(name, patternName, markerWidth, markerCenter);
        float mat_ambientf[] = { 0f, 1.0f, 0f, 1.0f };
        float mat_flashf[] = { 0f, 1.0f, 0f, 1.0f };
        float mat_diffusef[] = { 0f, 1.0f, 0f, 1.0f };
        float mat_flash_shinyf[] = { 50.0f };

        mat_ambient = GraphicsUtil.makeFloatBuffer(mat_ambientf);
        mat_flash = GraphicsUtil.makeFloatBuffer(mat_flashf);
        mat_flash_shiny = GraphicsUtil.makeFloatBuffer(mat_flash_shinyf);
        mat_diffuse = GraphicsUtil.makeFloatBuffer(mat_diffusef);
    }

    public CustomObject(String name, String patternName, double markerWidth,
            double[] markerCenter, float[] customColor) {
        super(name, patternName, markerWidth, markerCenter);
        float mat_flash_shinyf[] = { 50.0f };
        mat_ambient = GraphicsUtil.makeFloatBuffer(customColor);
        mat_flash = GraphicsUtil.makeFloatBuffer(customColor);
        mat_flash_shiny = GraphicsUtil.makeFloatBuffer(mat_flash_shinyf);
        mat_diffuse = GraphicsUtil.makeFloatBuffer(customColor);
    }

    /** Just a box, imported from the AndAR project. */
    private SimpleBox box = new SimpleBox();
    private FloatBuffer mat_flash;
    private FloatBuffer mat_ambient;
    private FloatBuffer mat_flash_shiny;
    private FloatBuffer mat_diffuse;

    /** Everything drawn here will be drawn directly onto the marker, as the
     corresponding translation matrix will already be applied. */
    @Override
    public final void draw(GL10 gl) {

        super.draw(gl);

        gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SPECULAR, mat_flash);
        gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_SHININESS,
                mat_flash_shiny);
        gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, mat_diffuse);
        gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, mat_ambient);

        // draw cube
        gl.glColor4f(0, 1.0f, 0, 1.0f);
        gl.glTranslatef(0.0f, 0.0f, 12.5f);

        // draw the box
        box.draw(gl);
    }
    @Override
    public void init(GL10 gl) {}
}

CustomRenderer.java

/** A custom OpenGL renderer, that gets registered to the {@link AndARRenderer}. It allows you to draw non Augmented Reality stuff, and setup the OpenGL environment.*/
public class CustomRenderer implements OpenGLRenderer {

    /** Light definitions */
    private float[] ambientlight1 = { .3f, .3f, .3f, 1f };
    private float[] diffuselight1 = { .7f, .7f, .7f, 1f };
    private float[] specularlight1 = { 0.6f, 0.6f, 0.6f, 1f };
    private float[] lightposition1 = { 20.0f, -40.0f, 100.0f, 1f };

    private FloatBuffer lightPositionBuffer1 = GraphicsUtil
            .makeFloatBuffer(lightposition1);
    private FloatBuffer specularLightBuffer1 = GraphicsUtil
            .makeFloatBuffer(specularlight1);
    private FloatBuffer diffuseLightBuffer1 = GraphicsUtil
            .makeFloatBuffer(diffuselight1);
    private FloatBuffer ambientLightBuffer1 = GraphicsUtil
            .makeFloatBuffer(ambientlight1);

    /** Do non Augmented Reality stuff here. Will be called once after all AR objects have been drawn. The transformation matrices may have to be reset.*/
    public final void draw(GL10 gl) {
    }

    /**Directly called before each object is drawn. Used to setup lighting and other OpenGL specific things.*/
    public final void setupEnv(GL10 gl) {
        gl.glEnable(GL10.GL_LIGHTING);
        gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_AMBIENT, ambientLightBuffer1);
        gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_DIFFUSE, diffuseLightBuffer1);
        gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_SPECULAR, specularLightBuffer1);
        gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_POSITION, lightPositionBuffer1);
        gl.glEnable(GL10.GL_LIGHT1);
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glDisable(GL10.GL_TEXTURE_2D);
        initGL(gl);
    }

    /** Called once when the OpenGL Surface was created. */
    public final void initGL(GL10 gl) {
        gl.glDisable(GL10.GL_COLOR_MATERIAL);
        gl.glEnable(GL10.GL_CULL_FACE);
        gl.glShadeModel(GL10.GL_SMOOTH);
        gl.glDisable(GL10.GL_COLOR_MATERIAL);
        gl.glEnable(GL10.GL_LIGHTING);
        gl.glEnable(GL10.GL_CULL_FACE);
        gl.glEnable(GL10.GL_DEPTH_TEST);
        gl.glEnable(GL10.GL_NORMALIZE);
    }
}

How do I capture the pattern from camera’s focused area and how do I match it with another pattern?

I know I’m bit unclear in this question but as I’m new to android development, any suggestion would be of great help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:23:38+00:00Added an answer on May 30, 2026 at 5:23 am

    you must have to see the CustomObject.java where the actual green cube is creating by using opengl… for creating that 3d objects you must have to know the opengl… Even i m trying to create some other objects by using the same code.. it is bit difficult and we must have to spend some time to learn that…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.