Log in or register to post comments

Camera image has been rotated 180 degrees on Nexus 5X

November 4, 2015 - 9:41pm #1
Hello.
 
I have a issue.
 
The camera image has been rotated 180 degrees on Nexus 5X (2015 model)
See attached file.
 
This issue seems to be in NEXUS5X only.
Same apk works fine on other devices.
 
Is it special problem of this device?
 
 
My current versions are:
Unity: 5.2
Project: Vuforia Sample Video playback (vuforia 5)
Nexus5 (Android 6)
Best Regards.

 

AttachmentSize
Image icon IMG_5783.JPG1.2 MB

Camera image has been rotated 180 degrees on Nexus 5X

December 21, 2017 - 2:57am #40

I just updated to Unity 2017.3 with Vuforia 7 and it works like charm in my Nexus 5x

Camera image has been rotated 180 degrees on Nexus 5X

December 6, 2017 - 3:38am #39

You can add the following ARManager to your scene, assuming your ARCamera is tagged with the tag MainCamera. Please customize it depending on your needs.

Do not expect a fix from Vuforia anytime soon, nor even an answer here. They are like the most expensive AR platform, but, you know, priorities I guess...

 

using UnityEngine;

using System.Collections;
using System.Collections.Generic;

using Vuforia;

public class ARManager : MonoBehaviour
{
    IEnumerator Start ()
{
        while(!VuforiaRuntime.Instance.HasInitialized)
        {
            yield return null;
        }

        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
        VuforiaARController.Instance.RegisterOnPauseCallback(OnPaused);

        #if UNITY_ANDROID
        yield return StartCoroutine(AndroidFixes());
        #endif
}

    #if UNITY_ANDROID
    // 1. Restart VuforiaBehaviour to avoid camera lags on some Android devices
    // 2. Add CameraFlip on Nexus 5X to avoid flipped camera
    IEnumerator AndroidFixes()
    {
        yield return null;

        VuforiaBehaviour.Instance.enabled = false;

        yield return null;

        if(SystemInfo.deviceModel == "LGE Nexus 5X")
        {
            Camera.main.gameObject.AddComponent<CameraFlip>();
        }

        yield return null;

        VuforiaBehaviour.Instance.enabled = true;
    }
    #endif

    private void OnVuforiaStarted()
{
     CameraDevice.Instance.SetFocusMode(
        CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}

void OnPaused(bool paused)
{
        VuforiaBehaviour.Instance.enabled = !paused;

     if (!paused) // resumed
     {
         CameraDevice.Instance.SetFocusMode(
         CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

            #if UNITY_ANDROID
            StartCoroutine(AndroidFixes());
            #endif
     }
        else // paused
        {
            #if UNITY_ANDROID
            if(SystemInfo.deviceModel == "LGE Nexus 5X")
            {
                if(Camera.main.gameObject.GetComponent<CameraFlip>() != null)
                {
                    Destroy(Camera.main.gameObject.GetComponent<CameraFlip>());
                }
            }
            #endif
        }
}

    void Destroy()
    {
        VuforiaARController.Instance.UnregisterVuforiaStartedCallback(OnVuforiaStarted);
        VuforiaARController.Instance.UnregisterOnPauseCallback(OnPaused);
    }
}

Camera image has been rotated 180 degrees on Nexus 5X

November 28, 2017 - 5:24pm #38

I am still getting this, I would like to deploy my app.

 

How can I check if the device is a Nexus/affected by this error to selectively apply the CameraFlip script provided below?

 

 

Camera image has been rotated 180 degrees on Nexus 5X

November 7, 2017 - 2:45am #37

Exactly the same problem here. With Unity 2017.2.0p1 ( Vuforia version 6.5.22 ) running on the Nexus 5. 

Camera image has been rotated 180 degrees on Nexus 5X

October 24, 2017 - 6:55am #36

Same problem here. Since unity 2017.2 we have the flipping camera problem on Nexus 5

 

 

Camera image has been rotated 180 degrees on Nexus 5X

October 19, 2017 - 7:04am #35

Hello,

 

I reopen this thread because this problem came back since we updated Unity to 2017.2 with the native Vuforia implementation. No problem before.

The workaround supplied before (CameraFlip.cs) is working in portrait mode, however it's not working in Landscape Mode.

Is it gonna be fixed again ? Otherwise, somebody knows how to adapt the camera flip script for landscape mode ? Thank you.

Camera image has been rotated 180 degrees on Nexus 5X

March 14, 2017 - 4:52am #34

I have same problem with Image Target Recognizion no Nexus5X.

When I try to recognize image all work fine. But if I move ARCamera.transform to Vector3.zero and set rotation to Quaternion.identity (for TrackableBehaviour Status NOT_FOUND) scene has been rotated 180 degrees.



All objects in ARCamera has correct transform.up vector (0.0, 1.0, 0.0);

I use:

Unity 5.5.2f1;

Vuforia SDK v6.2.6;

Nexus5X

Android 7.1.1

 

Camera image has been rotated 180 degrees on Nexus 5X

October 13, 2016 - 3:06pm #33

5k1ttl3 wrote:

Using the TextReco sample app, when compiled and run on Nexus5x, the sheet of text needs to be rotated 180 degrees or the device will not recognize it.

This is a known issue with Unity TextReco on Nexus 5X. We have a bug open for it. TextReco on Native Android/iOS is working okay on the Nexus 5X.

Camera image has been rotated 180 degrees on Nexus 5X

October 11, 2016 - 1:34pm #32

October 2016 - I have the same issue as everyone else in this thread. Latest unity, Vuforia 6:

 

Using the TextReco sample app, when compiled and run on Nexus5x, the sheet of text needs to be rotated 180 degrees or the device will not recognize it.

 

Is this ever going to be fixed, or -if not- can I be reasonably confident that this **only** affects this device?

 

If this problem happens on even 5% of devices, then I simply cannot trust Vuforia as a platform.

Camera image has been rotated 180 degrees on Nexus 5X

August 30, 2016 - 5:56am #31

rajeesh wrote:

Hi,

I updated my unity to 5.3 and Vuforia to 5-5-9 . 

Now when I try to scan the image using Nexus 5x, it seems okay.

But I have incuded an option in my app->  when the trackerLost happens, the augmented items will be attached to the mobile screen. And it can be viewd for the user.

But currently this seems 180 degree rotated.

Same thing still happens with new vuforia 6.0 version. Using vuforia 6.0 and Unity 5.4.0f3. AR on target is good, if attached to screen it's rotated 180°. Also input, like controls to rotate the object, is inverted.

Any info on this topic? Did you implement this solution pointed out here? Is this then also the problem with the rotation when "attaching to screen"?

MADmarine wrote:

I've found this issue as well, I've read up on the problem and it seems that the Vuforia SDK might need a tweak to accomodate for rare camera hardware orientation:

http://www.xda-developers.com/why-images-in-some-camera-apps-are-upside-down-on-the-nexus-5x/

Cheers

Camera image has been rotated 180 degrees on Nexus 5X

July 7, 2016 - 5:55pm #30

Hello,

Thanks for the detailed feedback. Historically, the Nexus 5X has been a problematic device for a variety of reasons.

We'll have to look into this further.

Thanks.

Camera image has been rotated 180 degrees on Nexus 5X

July 7, 2016 - 1:23pm #29

I have confirmed using the AR/VR sample. (Nexus 5x running Android 6.0 - vuforia 5.5.9)

I added some text to the scene (world space) to test the orientation. In AR Mode the text (and when using GVRMain the rotation/direction tracking) is rotated 180 degrees.

By using the built-in Vuforia "cardboard" the text sits rotated 180 degrees in AR mode (displays correctly in VR mode).

By using the GVRMain (Cardboard/Google VR 0.8.0) - I have the same result but it tracks rotation is also opposite (text goes opposite direction you'd expect).

Edit: This also occurs if not using any stereoscopic feature (clicking "mobile").

 

AttachmentSize
Image icon AR_Mode_w_imagetarget.png722.26 KB
Image icon VR_Mode.png418.4 KB
Image icon AR_Mode.png839.59 KB
Image icon mobile_mode.png1.74 MB

Camera image has been rotated 180 degrees on Nexus 5X

July 5, 2016 - 3:49pm #28

Hello,

Can you please confirm that you are also seeing this when using our 5.5 SDK sample application?

Thanks.

Camera image has been rotated 180 degrees on Nexus 5X

July 5, 2016 - 8:14am #27

Is there any update to this - I am having this issue with the Nexus 5x. The virtual content is upside down.

Camera image has been rotated 180 degrees on Nexus 5X

April 19, 2016 - 11:31pm #26

Hi,

I updated my unity to 5.3 and Vuforia to 5-5-9 . 

Now when I try to scan the image using Nexus 5x, it seems okay.

But I have incuded an option in my app->  when the trackerLost happens, the augmented items will be attached to the mobile screen. And it can be viewd for the user.

But currently this seems 180 degree rotated.

Camera image has been rotated 180 degrees on Nexus 5X

April 19, 2016 - 11:31pm #25

Hi,

I updated my unity to 5.3 and Vuforia to 5-5-9 . 

Now when I try to scan the image using Nexus 5x, it seems okay.

But I have incuded an option in my app->  when the trackerLost happens, the augmented items will be attached to the mobile screen. And it can be viewd for the user.

But currently this seems 180 degree rotated.

Camera image has been rotated 180 degrees on Nexus 5X

April 6, 2016 - 3:01am #24

In Unity PlayMode the model orientation is correct.
On other devices, wehre the where the app worked correct with older vuforia versions, the model orientation is also correct with the new version.
On a "cheap Android tablet" and on the Nexus5X, wehre the camera was rotated in older Vuforia versions, the camera is now correct but the model orientation is rotated 180°.
 

Camera image has been rotated 180 degrees on Nexus 5X

April 4, 2016 - 12:05pm #23

Are you able to reproduce this problem in Unity PlayMode or on any other device?

Camera image has been rotated 180 degrees on Nexus 5X

April 2, 2016 - 12:01am #22

dm3d wrote:

Release Notes for Vuforia 5.5.9 which was released March 9th:

"Fixed a bug where the camera image appeared flipped on the Nexus 5X back camera and Nexus 6 front camera"

 

Hi,

thanks for the fix with Vuforia 5.5.9 Unity plugin! Now the orientation of the camera video is correct on my Nexus 5X!

But there seems to be a problem with the coordinate system. If I (dynamically) load a model into my Unity app on the Nexus 5X and there is no tracker active, the model is displayed upside down! If the model is tracked, it flips to the right position on the tracker. My app uses "Landscape left" default orientation.

Is it possible to query if the camera video is flipped by Vuforia, so that it is possible to rotate the coordinate system when not tracked?
 

thx

Camera image has been rotated 180 degrees on Nexus 5X

March 10, 2016 - 5:20pm #21

Release Notes for Vuforia 5.5.9 which was released March 9th:

"Fixed a bug where the camera image appeared flipped on the Nexus 5X back camera and Nexus 6 front camera"

Camera image has been rotated 180 degrees on Nexus 5X

February 24, 2016 - 12:51am #20

dm3d wrote:

Yes, the script flips the background video plane as part of the workaround and a result of that is the watermark appearing upside-down. The watermark is shown for a brief time (see this FAQ: https://developer.vuforia.com/library/articles/FAQ/Watermark). This script is just a temporary workaround. An official fix will be appearing in an upcoming SDK release.

 

Why isn't it mentioned in the known issues section of the Release notes?

https://developer.vuforia.com/library/articles/Release_Notes/Vuforia-SDK-Release-Notes

Camera image has been rotated 180 degrees on Nexus 5X

February 16, 2016 - 8:12pm #19

Correct. The script has no awareness of the device it's running on. You might check using Android APIs to determine device:

http://developer.android.com/reference/android/os/Build.html

 

Camera image has been rotated 180 degrees on Nexus 5X

February 16, 2016 - 8:03am #18

Hi, 

thank you for this fix. What is the best practice to flip this only for nexus 5x device. Currently this script flips it on every device. But its only wrong on nexus 5x.

Thank you

Camera image has been rotated 180 degrees on Nexus 5X

February 2, 2016 - 6:05pm #17

Hello,

 

I'm using the script posted below with the exact same versions of everything. This does flip the camera; however, it also makes any overlays that I am tracking with Vuforia move the opposite from the way they are supposed to. For example, if I move my target left, my object goes right; if I move my target up, my object goes down. All the tracking is inversed. Is there a way I can fix this?

 

Thanks for the help.

Camera image has been rotated 180 degrees on Nexus 5X

January 11, 2016 - 1:08pm #16

Yes, the script flips the background video plane as part of the workaround and a result of that is the watermark appearing upside-down. The watermark is shown for a brief time (see this FAQ: https://developer.vuforia.com/library/articles/FAQ/Watermark). This script is just a temporary workaround. An official fix will be appearing in an upcoming SDK release.

Camera image has been rotated 180 degrees on Nexus 5X

January 11, 2016 - 3:57am #15

Thanks dm3d!! The Script works fine.I had to uninstall and reinstall the apk. Now only solve the watermark, appears upside down.

 

 

Thanks for all.

AttachmentSize
Image icon Screenshot_20160111-125313.png860.95 KB

Camera image has been rotated 180 degrees on Nexus 5X

January 5, 2016 - 11:30am #14

To workaround the upside-down BACK camera for the Nexus 5X with Vuforia Unity projects, try attaching this script to the Camera object which is parented to the ARCamera:

CameraFlip.cs

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Vuforia;

[RequireComponent(typeof(Camera))]
public class CameraFlip : MonoBehaviour
{
	// Public members can be changed in the Inspector
	public bool flipFrontCamera = false;
	public bool flipBackCamera = true;
	public bool flipVertical = true;
	public bool flipHorizontal = true;

	private Transform mBackgroundPlane;
	private bool mFlipped = false;
	private bool mCameraReady = false;

	void Start()
	{
		VuforiaBehaviour.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);
		VuforiaBehaviour.Instance.RegisterOnPauseCallback(OnVuforiaPause);
	}

	void OnVuforiaStarted()
	{
		Debug.Log("Vuforia has started");
		mBackgroundPlane = transform.GetComponentInChildren<Transform>();
		mCameraReady = true;
	}

	void OnVuforiaPause(bool paused)
	{
		if (!paused) {
			mFlipped = false;
		}
	}

	void OnPreCull()
	{
		// Skip if Vuforia has not started yet
		if (!mCameraReady)
			return;

		bool isFrontCam = (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_FRONT);
		bool isBackCam = (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_BACK) ||
		                 (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_DEFAULT);

		if ((isFrontCam && flipFrontCamera) ||
		    (isBackCam && flipBackCamera)) {
			if (!mFlipped) {
				FlipCameraProjectionMatrix();
				mFlipped = true;
			}
		}
	}

	private void FlipCameraProjectionMatrix()
	{
		Camera cam = this.GetComponent<Camera>();
		Vector3 flipScale = new Vector3(flipHorizontal ? -1 : 1, flipVertical ? -1 : 1, 1);
		Matrix4x4 projMat = cam.projectionMatrix * Matrix4x4.Scale(flipScale);
		Debug.Log("Flipping camera projection matrix...");
		cam.projectionMatrix = projMat;
	}

	void LateUpdate()
	{
		// Skip if Vuforia has not started yet
		if (!mCameraReady)
			return;

		Vector3 planeScaleAbs = new Vector3(Mathf.Abs(mBackgroundPlane.localScale.x), 
			                        Mathf.Abs(mBackgroundPlane.localScale.y), 
			                        Mathf.Abs(mBackgroundPlane.localScale.z));

		bool isFrontCam = (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_FRONT);
		bool isBackCam = (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_BACK) ||
		                 (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_DEFAULT);

		if ((isFrontCam && flipFrontCamera) ||
		    (isBackCam && flipBackCamera)) {
			// flip background plane
			mBackgroundPlane.localScale = new Vector3(planeScaleAbs.x * (flipHorizontal ? -1 : 1), 
				planeScaleAbs.y * (flipVertical ? -1 : 1), 
				planeScaleAbs.z);
		} else {
			// do NOT flip background plane
			mBackgroundPlane.localScale = new Vector3(planeScaleAbs.x, planeScaleAbs.y, planeScaleAbs.z);
		}
	}

	void OnPreRender()
	{
		if (flipVertical != flipHorizontal) {
			GL.SetRevertBackfacing(true);
		}
	}

	// Set it to false again because we don't want to affect all other cameras.
	void OnPostRender()
	{
		if (flipVertical != flipHorizontal) {
			GL.SetRevertBackfacing(false);
		}
	}
}

 

Tested using Vuforia 5.0.10, Unity 5.3.0f4, Nexus 5X (6.0.1)

Camera image has been rotated 180 degrees on Nexus 5X

December 22, 2015 - 4:43pm #13

The issue will be fixed in the next release of Vuforia. In the meantime, can you try and see whether this work around resolves the issue.

https://developer.vuforia.com/forum/issues-and-bugs/front-camera-issue-mirror-image#comment-2050998

Camera image has been rotated 180 degrees on Nexus 5X

December 22, 2015 - 7:34am #12

I'm having the same problem. 

Camera image has been rotated 180 degrees on Nexus 5X

December 2, 2015 - 6:34am #11

Hi there,

I just ran into this problem too. I read the complete thread here. So the script linked below doesn't help with the Nexus 5X 180 degree rotation, right? Then we have to wait until a fix in the vuforia SDK is available?!

Any news on this?
Thanks

Camera image has been rotated 180 degrees on Nexus 5X

November 23, 2015 - 6:04pm #10

MADmarine wrote:

Is there anything else you can suggest?

I am waiting to get access to a 5X device so that I can investigate further.

 

Camera image has been rotated 180 degrees on Nexus 5X

November 17, 2015 - 10:50pm #9

Read this article: http://www.theverge.com/2015/11/9/9696774/google-nexus-5x-upside-down-camera

 

Vuforia is using the old Camera API:  http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation%28int

The Camera2 API could handle that. Qualcomm have to implement the new camera2 api to fix that.

 

Does anyone found a temporary workaround for Android (not Unity) ?

 

Camera image has been rotated 180 degrees on Nexus 5X

November 13, 2015 - 6:25am #8

Hi dm3d,

Unfortunately the script in that thread didn't work, no matter what I try the camera feed just remains upside down.

I've made sure to swap the references around for back and front cameras. Interestingly, the Nexus 5X will only ever be set to "CAMERA_DEFAULT" when GetCameraDirection is called, whether I set it in QCAR Behaviour to BACK or DEFAULT, so I've also tried replacing the CAMERA_FRONT in the original script with DEFAULT, but still no luck.

I've tried swapping the various booleans for flip vertical and horizontal as well, this has not provided any difference in result.

I've debugged the code and have made sure that all of the various points in the script are being called, it looks like this may be a different problem to the Nexus 6 camera somehow, unless I'm doing something wrong.

Is there anything else you can suggest?

Camera image has been rotated 180 degrees on Nexus 5X

November 11, 2015 - 2:36pm #7

MADmarine wrote:

I've found this issue as well, I've read up on the problem and it seems that the Vuforia SDK might need a tweak to accomodate for rare camera hardware orientation:

http://www.xda-developers.com/why-images-in-some-camera-apps-are-upside-down-on-the-nexus-5x/

That was a good explanation. Thank you for providing the link.

As mentioned in that article, the Nexus 6 Front Camera also was affected by the sensor orientation issue and here's a script to workaround that:

https://developer.vuforia.com/forum/issues-and-bugs/front-camera-issue-mirror-image#comment-2050998

Note: That script fixed the 180 degree flip on the front cam of the Nexus 6. For the Nexus 5X back cam, you'll want to swap the mentions of front/back cameras in the script.

 

Camera image has been rotated 180 degrees on Nexus 5X

November 11, 2015 - 1:38pm #6

Hello MADmarine.

> Wiz, when you say "Back camera corrected", does that mean you've found a solution?
>
Excuse me! I made a mistake.
I have edited my answer.

I have not yet found a solution.

Camera image has been rotated 180 degrees on Nexus 5X

November 11, 2015 - 1:29pm #5

Hello, dm3d.

It happened on Unity Vuforia Sample.

Back Camera corrected.
It happened on the back camera.
(I didn't try with front camera.)

Model: Nexus 5X
Android version: 6.0
Security patch level: 2015/10/1
Baseband version: M8994F-2.6.22.0.56
Kernel version: 3.10.74-gea58e70

#1 Fri Sep 25 17:52:25 UTC 2015
Build Number: MDA89E

Best regards,
Wiz.

Camera image has been rotated 180 degrees on Nexus 5X

November 11, 2015 - 3:46am #4

My Nexus 5X has the exact same details as well for reference.

Wiz, when you say "Back camera corrected", does that mean you've found a solution?

Camera image has been rotated 180 degrees on Nexus 5X

November 10, 2015 - 5:25am #3

I've found this issue as well, I've read up on the problem and it seems that the Vuforia SDK might need a tweak to accomodate for rare camera hardware orientation:

http://www.xda-developers.com/why-images-in-some-camera-apps-are-upside-down-on-the-nexus-5x/

Camera image has been rotated 180 degrees on Nexus 5X

November 6, 2015 - 3:33pm #2

  • Does this happen with the native Android VuforiaSamples app?
  • Is the front camera correct?
  • What is the exact model number of Nexus 5X device?
Log in or register to post comments