Log in or register to post comments

Render only scene content, not camera feed

January 9, 2013 - 2:29pm #1

Hey there,

Really enjoying working with Vuforia so far. I haven't been able to find an answer or solution to one thing:

How can I not render the video feed from the camera in my scene? For app-specific reasons, I'd like to acquire and track targets as usual, but to *only* render the 3D content in my scene, on a black background — in other words, hiding (or not drawing / rendering) the video image from the camera being used for tracking.

This seems like a simple thing but I can't work out how to do it. I could draw a large black plane in my Unity scene to obscure it, but I'd rather not draw it in the first place, to save the processor cycles. I'd really appreciate any assistance you can offer.

I'm using Unity 4, but it would be useful to know this info for native apps as well.

Thanks very much!

Render only scene content, not camera feed

June 25, 2014 - 1:39am #12

For new visitors, please, refer to this thread, which describes a much simpler way to achieve this.

Aernarion.

Render only scene content, not camera feed

June 26, 2013 - 10:22pm #11

Nice.

Render only scene content, not camera feed

June 26, 2013 - 7:52pm #10

Update

In case anyone wants to do something similar I solved it by making a transparent background and setting an image for the container ViewController.

To make the transparent background y just used:

    glClear(GL_COLOR_BUFFER_BIT);

    glClearColor(0, 0, 0, 0);

Thanks AlessandroB for your help and insights,

:)

----------------------------------------

AlessandroB wrote:

Yes, that's possible. The best way would be to create an OpenGL texture for the background image (the code to do that can be derived from the code used to create the teapot textures in the ImageTargets sample, for instance...)

Then you could render the texture on a screen aligned quad; this should occur right after the call to glClear() which I was mentioning before.

Hi AlessandroB,

I think something like the code I copied from te frameMarker example could work, but unfortunately I'm not familiar with openGL and I don't know how to populate the following variables: numVerts, verts, normals, textCoords and anotherMatrix in order to create a plane that I can apply the texture to. 

glClear(GL_COLOR_BUFFER_BIT);

[self add3DObjectWith:numVerts ofVertices:verts normals:normals texcoords:textCoords with:0 ofIndices:0 usingTextureIndex:0];

Object3D *obj3D = [objects3D objectAtIndex:0];

// Render with OpenGL 2
QCAR::Matrix44F modelViewProjection;
ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0], &anotherMatrix.data[0], &modelViewProjection.data[0]);    

glUseProgram(shaderProgramID);    

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, obj3D.vertices);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, obj3D.normals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, obj3D.texCoords);    

glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);    

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, [obj3D.texture textureID]);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0]);
glUniform1i(texSampler2DHandle, 0);
glDrawArrays(GL_TRIANGLES, 0, obj3D.numVertices);

It would be really helpful if you can provide me with some hints or examples about how can I initialize those variables.

As always, thank you for your time,

 

Render only scene content, not camera feed

June 24, 2013 - 8:22am #9

Makes a lot of sense, I'll try that later and let you know how it was,

Thanks!

Render only scene content, not camera feed

June 24, 2013 - 8:20am #8

Yes, that's possible. The best way would be to create an OpenGL texture for the background image (the code to do that can be derived from the code used to create the teapot textures in the ImageTargets sample, for instance...)

Then you could render the texture on a screen aligned quad; this should occur right after the call to glClear() which I was mentioning before.

 

Render only scene content, not camera feed

June 24, 2013 - 8:11am #7

Hey AlessandroB,

Thanks again, actually I'm willing to display an image instead of the black background, is that possible?

Render only scene content, not camera feed

June 24, 2013 - 8:04am #6

You're welcome. 

BT: I forgot to mention; in the code you should be able to find some code like:

glClearColor (0, 0, 0, 0); (or similar...)

in case you want to change the background color (currently rendering Black) with another color (e.g. red, blue...), you just need to change the R,G,B values in glClearColor()

.

 

Render only scene content, not camera feed

June 24, 2013 - 7:55am #5

Thanks for your quick answer AlessandroB,

It is working like a charm :D

Thanks a lot!

Render only scene content, not camera feed

June 24, 2013 - 7:46am #4

Can you try this simple thing, i.e. adding glClear ( GL_COLOR_BUFFER_BIT  ) after the call to drawVideoBackground() ?

your code in practice should simply become:

...

QCAR::Renderer::getInstance().drawVideoBackground();

glClear (GL_COLOR_BUFFER_BIT);

...

Let me know if that does the trick (it should).

 

 

Render only scene content, not camera feed

June 24, 2013 - 7:36am #3

AlessandroB wrote:

Hi, I think you psted the same question here:

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/avoid-drawing-or-rendering-video-feed-camera

(please avoid double posting in the future, thanks.)

 

Hi AlessandroB,

Thanks for the insight. I looked for that in iOS but I only have a call to:

QCAR::Renderer::getInstance().drawVideoBackground();

I tryed commenting that line out, but it simply wont render the 3D model when I do that. I would like to know how can I deal with that call to be able to display the 3D model but without displaying the camera feed.

Thanks!

Hi, I think you psted the

January 9, 2013 - 10:54pm #2

Hi, I think you psted the same question here:

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/avoid-drawing-or-rendering-video-feed-camera

(please avoid double posting in the future, thanks.)

 

Log in or register to post comments