Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texture of image is black when attaching to target image and i have not used firebase and rubberstamp #1

Open
Anushree278 opened this issue Jun 11, 2019 · 1 comment

Comments

@Anushree278
Copy link

public void render() {
GLES20.glClearColor(1.f, 1.f, 1.f, 1.f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    if (videobgRenderer != null) {
        Vec4I default_viewport = new Vec4I(0, 0, viewSize.data[0], viewSize.data[1]);
        GLES20.glViewport(default_viewport.data[0], default_viewport.data[1], default_viewport.data[2], default_viewport.data[3]);
        if (videobgRenderer.renderErrorMessage(default_viewport)) {
            return;
        }
    }

    if (streamer == null) {
        return;
    }
    Frame frame = streamer.peek();
    try {
        updateViewport();
        GLES20.glViewport(viewport.data[0], viewport.data[1], viewport.data[2], viewport.data[3]);

        if (videobgRenderer != null) {
            videobgRenderer.render(frame, viewport);
        }

        TargetContainer targetContainer = new TargetContainer(frame.targetInstances());
        Iterator targetIterator = targetContainer.getIterator();

        while (targetIterator.hasNext()) {
            TargetInstance targetInstance = (TargetInstance) targetIterator.next();
            int status = targetInstance.status();
            if (status == TargetStatus.Tracked) {
                Target target = targetInstance.target();
                ImageTarget imagetarget = target instanceof ImageTarget ? (ImageTarget) (target) : null;
                if (imagetarget == null) {
                    continue;
                }
                if (imageRenderer != null) {
                    currentTarget = imagetarget.name();
                    if (!currentTarget.equals(previusTarget)) {
                        Log.i(TAG, String.format("current: %s, prev: %s", currentTarget, previusTarget));
                        System.out.println("targetname"+target.name()+"or"+currentTarget);
                        Lesson existingLesson = pairObjectPool.findExistingLesson(currentTarget);
                        if (existingLesson == null) {

                            File file = new File("/data/data/com.example.augmentedrealityapp"+"/",objectdata);

                            Bitmap b = BitmapFactory.decodeStream(new FileInputStream(file));

// bitmap = pairObjectPool.checkOut(curLesson).getBitmap();
bitmap = imageProcessing.generateBitmap();
TextureHelper.loadTexture(mainActivity.getApplicationContext(),"/data/data/com.example.augmentedrealityapp"+"/"+objectdata);
TextureHelper.updateBitmap(bitmap);
}
else {
// });
bitmap = existingLesson.getBitmap();
TextureHelper.updateBitmap(bitmap);
}
}
}
imageRenderer.render(camera.projectionGL(0.2f, 500.f), targetInstance.poseGL(), imagetarget.size());
}
}
previusTarget = currentTarget;

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } finally {
        frame.dispose();
    }
}
@Anushree278 Anushree278 changed the title Object image is black when attaching to target image and i have not used firebase and rubberstamp texture of image is black when attaching to target image and i have not used firebase and rubberstamp Jun 11, 2019
@khoben
Copy link
Owner

khoben commented Aug 16, 2019

@Anushree278 Sorry for the late reply, here is question about how to load texture properly. If correctly-loaded Bitmap object pass into TextureHelper.updateBitmap then texture will update. Also check OpenGL samples with texture processing, maybe your OpenGL build and target device gives inappropriate results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants