Log in or register to post comments

2D Image is not displaying after 2ft distance

February 6, 2013 - 12:12am #1

Hi everyone ,

I have implemented an iOS app using the Image Target Sample .  Its functionality is detect the Image ( displayed the 2d Image on the Target Image ) and display the distance from the Target Image .My problem is detection and distance are working fine upto 2 ft . But after 2 ft it is detecting the Image but not displaying the 2D Image on the Target Image .   I have used the below code . Please tell me what will be the issue ? Thanks in advance

            const QCAR::Trackable* trackable = state.getTrackable(0);
            
            QCAR::Vec2F targetSize = ((QCAR::ImageTarget *) trackable)->getSize();
            
            QCAR::Matrix44F modelViewProjection;
            
            ShaderUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                             &modelViewMatrix.data[0]);
            ShaderUtils::scalePoseMatrix(targetSize.data[0], targetSize.data[1], 1.0f,
                                         &modelViewMatrix.data[0]);
            ShaderUtils::multiplyMatrix(qUtils.projectionMatrix.data,
                                        &modelViewMatrix.data[0] ,
                                        &modelViewProjection.data[0]);
            
            glUseProgram(shaderProgramID);
            
            glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,(const GLvoid*)obj3D.vertices);
            glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,(const GLvoid*)obj3D.normals);
            glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,(const GLvoid*)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] );
            glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,(const GLvoid*)obj3D.indices);
 

2D Image is not displaying after 2ft distance

February 21, 2013 - 1:33am #12

Hi, sorry, but that code renders the texture in 3D (i.e. aligned with tthe image target), so in your camera view it will look "in perspective", thus trapezoid, unless you look at the target with the camera device aligned with the target, as I said (try to look at the target from a 45 degrees angle for instance); that's why i don't get your question...

2D Image is not displaying after 2ft distance

February 21, 2013 - 1:20am #11

Hi Thank you for your reply . The texture looks like a Rectangle . Please look at this link https://developer.vuforia.com/forum/ios/get-projected-image-size-which-drawn-targetimage-imagetargets

In that link I have pasted the code which I have used , I am getting the TargetImage size like that Can I get the drawn 2D Image ?

2D Image is not displaying after 2ft distance

February 20, 2013 - 11:37pm #10

Hi, if the image is rendered on the Image Target as a texture, it will not look rectangular, but it will appear somehow skewed (like a trapezoid), due to the position of the camera with respect to the target, and due to the persepctive projection (unless you assume that the device screen is exactly parallel to the Image Target); 

as such, you cannot compute the widtn and height of the projected image, as it is not a rectangle anymore once projected;

unless you are assuming that you will always hold your camera device extactly parallel to the Image Target; are you making such assumption?

2D Image is not displaying after 2ft distance

February 20, 2013 - 9:42pm #9

HI AlessandroB

I have a Target Image ( I have uploaded this image in the Database of Vuforia for detection ) . By using the Image Targets I am detecting this Target Image and we are drawing one 2D Image on the Target Image once it is detected . I got the Target Image size programmatically , it is fine . Now I would like to know the drawn 2D Image size ( width and height ). So please tell me how to do this . Please let me know if my question not clear . Thanks in advance .

2D Image is not displaying after 2ft distance

February 20, 2013 - 3:52am #8

Glad that the isseu was solved.

Concerning your second question: could you clarify a bit what you mean exactly by "projected size" ?

2D Image is not displaying after 2ft distance

February 19, 2013 - 10:17pm #7

Yes It have solved my issue and one more thing is Could you tell me how to get the projected 2D Imagesize (the Image which we have drawn  once the target Image is tracked )? ( width and Height ) . Please let me know if my question not clear .

2D Image is not displaying after 2ft distance

February 6, 2013 - 2:31am #6

You're welcome. Did that solve your issue ?

2D Image is not displaying after 2ft distance

February 6, 2013 - 1:56am #5

Hi AlessandroB

Thank you so much for your reply . It helped me a lot

2D Image is not displaying after 2ft distance

February 6, 2013 - 1:16am #4

Hi, if you look at the Image Targets sample (or any of the Vuforia samples) you should find the function that I mentioned (getProjectionGL) this is required in order to setup the projection matrix and render the view correctly in OpenGL;  so, you should have that function too, in your code (unless you build the projection matrix with your own code...)

 

2D Image is not displaying after 2ft distance

February 6, 2013 - 12:35am #3

Hi AlessandroB

Thanks for your reply . I didn't used any function like you mentioned . Is there any other reason for my this scenario ?

2D Image is not displaying after 2ft distance

February 6, 2013 - 12:24am #2

Hi, at a first glance it might be just a problem with your far-distance clip plane, clipping your 3D model out;

you should find some code which looks like this:

QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f, 2500.0f);

the last paremeter is the far distance (far clip plane distance); you may want to try and increase such value and see if it makes any difference.

 

Log in or register to post comments