Log in or register to post comments

Placing objects relative to camera results in offset when device is calibrated

June 25, 2015 - 11:57am #1

I'm trying to place objects (UI in world space in this case) relative to the camera, and am experiencing some pretty nasty offsets when the device (ODG R6) is running calibrated.

An element several units away from the center of the ARCamera is showing up centered in Play mode, and centered on the device when running uncalibrated, but is translated several units up from the camera when the device is calibrated.

I tried placing it relative to Camera.Main, the ARCamera object in the scene, and the ARCameras PrimaryCamera and SecondaryCamera but nothing seems to be working.

Placing objects relative to camera results in offset when device

October 28, 2015 - 3:14pm #12

There are no news about this yet, no solution is provided yet we will let you know when there is some solution available.

Placing objects relative to camera results in offset when device

October 5, 2015 - 4:35am #11

Hi - was a a resolution for this issue ever provided? We are experiencing the same problem with offsetting.

Placing objects relative to camera results in offset when device

July 31, 2015 - 2:54pm #10

We took a look into this, more work on our side has to be done in the future to provide some straight forward way to do this.

Some investigation could be done for the projection matrices for the cameras. We will post a response later when we have some time for investigation on this one since it will require some work.

Placing objects relative to camera results in offset when device

July 20, 2015 - 11:14am #9

Hi. We are looking into this one.

Placing objects relative to camera results in offset when device

July 14, 2015 - 8:39am #8

Exactly same issue as csrussell and no solution work for me yet.

Placing objects relative to camera results in offset when device

July 13, 2015 - 12:02pm #7

Thanks moisestafolla.

I tried what you suggested with a few modifications but still seem to be having problems:

		Camera mCamera = this.transform.parent.GetComponent<Camera>();
		
		Plane depthPlane = new Plane(mCamera.transform.forward, mCamera.transform.position + mCamera.transform.forward * distance);
		
		Ray principalPointRay = mCamera.ScreenPointToRay(new Vector3(mCamera.pixelRect.xMin + ((mCamera.pixelRect.xMax - mCamera.pixelRect.xMin) / 2f),
		                                                             mCamera.pixelRect.yMin + ((mCamera.pixelRect.yMax - mCamera.pixelRect.yMin) / 2f), 0));
		float rayDist = 0.0f;
		depthPlane.Raycast(principalPointRay, out rayDist);
	Vector3 pointOnPlane = mCamera.transform.InverseTransformPoint(principalPointRay.GetPoint(rayDist));
		this.transform.localPosition  = pointOnPlane;

		if(Input.GetKey(KeyCode.UpArrow))
		   distance *= 1.1f;
		if(Input.GetKey(KeyCode.DownArrow))
			distance /= 1.1f;

I swapped the x and y values for principalPointRay, and I added the ability to change the distance in game.

In the Unity player, everything is fine and works as expected. Pressing up and down moves the the object away from its parent camera.  I have it attached to a left eye cube, and a right eye cube, children of the left camera and right camera respectively.  

On the calibrated device, pressing up and down moves the left eye cube left, and the right eye cube right!  I can't figure out what's going on here.  Uncalibrated (using the default profile) the cube seem to move toward the bottom left and right corners respectively. I find this to be rather frustrating to diagnose what's going on.

Placing objects relative to camera results in offset when device

July 9, 2015 - 5:17pm #6

Try adding the object as child of the left camera.

  • Define a plane at the desired distance
  • Raycast from the center of the camera to the plane
  • Get the intersection point
  • Apply to the object local position
        Camera mCamera = this.transform.parent.GetComponent<Camera>();

        Plane depthPlane = new Plane(mCamera.transform.forward, mCamera.transform.position + mCamera.transform.forward * zDistance);

        Ray principalPointRay = mCamera.ScreenPointToRay(new Vector3(mCamera.pixelRect.yMin + ((mCamera.pixelRect.yMax - mCamera.pixelRect.yMin) / 2f),
                                                                     mCamera.pixelRect.xMin + ((mCamera.pixelRect.xMax - mCamera.pixelRect.xMin) / 2f), 0));

        float rayDist = 0.0f;
        depthPlane.Raycast(principalPointRay, out rayDist);
        Vector3 pointOnPlane = mCamera.transform.InverseTransformPoint(principalPointRay.GetPoint(rayDist));

 

Placing objects relative to camera results in offset when device

July 9, 2015 - 10:56am #5

Hi,

We are looking into this. Basically what you are experiencing is the result of the projection matrix which is modified for the calibration. For R6 it means it is shifted a bit down.

Placing objects relative to camera results in offset when device

July 2, 2015 - 11:17am #4

What Luke is experiencing is a different issue than mine.  Objects that are placed relative to the target appear on the correct location and are the correct scale when the device is calibrated.  When an object is placed relative to the camera however, the position is wrong.

Here's a more formal statement of the problem and how to reproduce it:

Hardware:

ODG R6

 

Software Version:

Vuforia for Eyewear 4.2.3

Unity 5.0.2f1, 5.1.1f1

 

Bug:  objects placed relative to the camera are offset incorrectly on a device that has a stereo calibration profile loaded.

 

Reproduction Steps:

1.       Get Camera position

2.       Set UI’s position to camera position + camera.position.forward*distance

3.       Set UI’s rotation to camera rotation

 

Expected Behavior:

UI placed several units in front of camera with center of of UI canvas at the center of the user’s FOV, facing user.

 

Actual Behavior:

UI is placed several units in front of camera but also translated up several units.

 

Notes:

For the Camera position, I tried Camera.main, the ARCamera object position, and the average of the left camera + right camera position.  Behavior was the same.  

Placing objects relative to camera results in offset when device

July 1, 2015 - 10:49am #3
Are you experiencing the same alignment issues using the Vuforia for Digital Eyewear image target sample application when you view the teapot on a stones target?  Also, does the augmentation on the user calibration confirmation screen appear properly aligned?
 
Target size and real-world relative scale impact alignment.  You can check the following. 
 
The target size should be specified in millimeter.  You can update the target size in the XML file or via the TMS.
 
The target size should be specified in real-world scale.  In other words, an image target with a physical width of 100mm should be specified as a 100mm wide target.   User calibration captures real world to camera display coordinates, which needs to be kept consistent with the size of objects being augmented.

Placing objects relative to camera results in offset when device

June 30, 2015 - 1:50am #2

csrussell wrote:

I'm trying to place objects (UI in world space in this case) relative to the camera, and am experiencing some pretty nasty offsets when the device (ODG R6) is running calibrated.

An element several units away from the center of the ARCamera is showing up centered in Play mode, and centered on the device when running uncalibrated, but is translated several units up from the camera when the device is calibrated.

I tried placing it relative to Camera.Main, the ARCamera object in the scene, and the ARCameras PrimaryCamera and SecondaryCamera but nothing seems to be working.

 

Interesting. I think we might have the same issue.

My experiments thus far have been particularly unrewarding when it comes to the positioning of models.

I have an stereo AR camera setup looking at an image target with a basic model of a horse in the center. When I enter play mode I expect the model to be in the center of the target.

 - Uncalibrated the model appears in the top left of the target image and just out of bounds of the viewport. 

 - Calibrated, it position closer to the middle but is still not centered.

 - If I position the image relative to the camera and not my eyes it does center (as expected).

Perhaps somebody can explain what we're doing wrong?

 

Log in or register to post comments