Attachment | Size |
---|---|
![]() | 1.2 MB |
Attachment | Size |
---|---|
![]() | 1.2 MB |
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); } }
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.
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
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.
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.
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"?
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
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").
Attachment | Size |
---|---|
![]() | 722.26 KB |
![]() | 418.4 KB |
![]() | 839.59 KB |
![]() | 1.74 MB |
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.
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.
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°.
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
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"
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
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
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.
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.
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.
Attachment | Size |
---|---|
![]() | 860.95 KB |
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)
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
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) ?
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?
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.
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.
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/
I just updated to Unity 2017.3 with Vuforia 7 and it works like charm in my Nexus 5x