Topic locked

Camera Vertically Flipped - Archos 97 Titanium HD

August 5, 2013 - 6:29am #1

Hi,

 

We have encountered a problem with this specific device. When the camera is turned on to scan the AR target, the camera is vertically flipped. 

We have tried several other devices and none of them show this symptom (camera is not vertically flipped). 

 

What we tried so far:

In an empty scene we drew the device camera to a GUI Texture and the camera was showing properly, afterwards we opened a clean project with just the sample vuforia scene... the camera on the Archos device was inverted again.

We have tried Portrait, Landscape Left, Landscape Right, and automatic, all of them show the same result (inverted camera on the Archos). 

 

The camera is not inverted in the Unity Editor, iOS devices, and our other Android devices.

This might not be limit to only this device but from the devices that we own this was the one that decided to be stubborn.

 

Any help to get the camera working properly on this device is appreciated.

 

Device and Version info:

Archos 97 Titanium HD

Android 4.1.1

Unity version: 4.1.5

Vuforia: 2.6

Camera Vertically Flipped - Archos 97 Titanium HD

May 4, 2015 - 11:55am #29

@johnnyGor: This thread is over a year old and the post AlessandroB provided was from almost 2 years ago and for an older version of Vuforia where StateManagerImpl.cs was available within Unity.

Sept. 2013 (obsolete): https://developer.vuforia.com/forum/device-support/camera-vertically-flipped-archos-97-titanium-hd#comment-2032263

Could you create a new thread for the issue with the Prestigio Multipad 4 Pro Quad device and include a screenshot of the ImageTargets 4.0.105 sample app running on the device so that we can see the effect?

Additional details to include:

https://developer.vuforia.com/forum/device-support/how-report-device-issue

 

Camera Vertically Flipped - Archos 97 Titanium HD

May 3, 2015 - 5:40am #28

Hello

 

Is there any fix for this issue ? I'm trying to fix it on Prestigio Multipad 4 Pro Quad but withou t any succes. I have been trying to use AlessandroB example with QuaternionFromMatrix replacement but I cant find StateManagerImpl class. I'm using Vuforia 4.0

 

Please help.

 

Regards

Jan

 

 

Camera Vertically Flipped - Archos 97 Titanium HD

March 10, 2014 - 3:10am #27

Thanks for the response.

I am using vuforia 2.6.7, and the samples currently available are of latest version, so i tried importing just the prefab of BackgroundCamera Object to my project. But it just shows black screen on device rather than rendering the texture.

Is there any way to get the samples for vuforia 2.6.7?

Camera Vertically Flipped - Archos 97 Titanium HD

March 7, 2014 - 9:59pm #26

Try rotating the plane rendering Camera video over it in background texture access example that worked for me.

Camera Vertically Flipped - Archos 97 Titanium HD

March 6, 2014 - 4:31am #25

I guess you will need older version of vuforia for that.

can you please tell me how you rotated the device camera's video using the backgroundTextureAccess sample?

I have been stuck on this for many days. I can't seem to find the Script where device camera's video is handled?

Camera Vertically Flipped - Archos 97 Titanium HD

March 5, 2014 - 10:11pm #24

I cant do changes provided by alexander cause in new version of vuforia StateManagerImpl.cs is inside an internal dll file, please help how can i make changes into it.

Camera Vertically Flipped - Archos 97 Titanium HD

March 5, 2014 - 6:00am #23

I have tried putting that code outside if condition too, it does not affect camera feed, one thing that i have done differently from littlechicken is that i have not used VideoTextureBehaviour . I am afraid i am doing it in wrong file. Any idea what could be wrong here?

Camera Vertically Flipped - Archos 97 Titanium HD

March 5, 2014 - 5:28am #22

Clarifiation: swapping x and y will make a rotation of 90 degrees; if insetad you want to flip, then the code posted by littlechiken should be the correct one

 

Camera Vertically Flipped - Archos 97 Titanium HD

March 5, 2014 - 4:58am #21

Thank you for your response. 

as littlechicken mentioned i did the following inside CreateVideoMesh:


if (mFlipHorizontally)
                {
                    /*uvs[p0Index].x = 1 - uvs[p0Index].x;
                    uvs[p1Index].x = 1 - uvs[p1Index].x;
                    uvs[p2Index].x = 1 - uvs[p2Index].x;
                    uvs[p3Index].x = 1 - uvs[p3Index].x;*/
		
		   uvs[p0Index] = new Vector2(scaleFactorX - uvs[p0Index].x, scaleFactorY - uvs[p0Index].y);
		   uvs[p1Index] = new Vector2(scaleFactorX - uvs[p1Index].x, scaleFactorY - uvs[p1Index].y);
		   uvs[p2Index] = new Vector2(scaleFactorX - uvs[p2Index].x, scaleFactorY - uvs[p2Index].y);
		   uvs[p3Index] = new Vector2(scaleFactorX - uvs[p3Index].x, scaleFactorY - uvs[p3Index].y);

                }

Above change did not change anything, infact tracking stopped.

By swapping do you mean to swap their x and y variables?

Camera Vertically Flipped - Archos 97 Titanium HD

March 5, 2014 - 4:11am #20

In CreateVideoMesh, you can achieve a rotation of the video texture by acting on the U, V texture coordinates (e.g. swapping U with V)

 

 

Camera Vertically Flipped - Archos 97 Titanium HD

March 5, 2014 - 3:08am #19

Hi,

By using the workaround suggested by AlessandroB in StateManagerImpl's PositionCamera function, i am able to correct the rotation of my overlay and its movement but i am unable to find the solution to rotate the camera feed . Anyone who could tell me how i can change the camera's rotation? 

I have tried changing the function CreateVideoMesh() inside BGRenderingBehaviour, but it did not have any effect on camera feed.

i am using  vuforia 2.6.7 and Unity 4.3.

regards, 

Camera Vertically Flipped - Archos 97 Titanium HD

March 3, 2014 - 2:16pm #18

i want to know that what part to use from that sample?  so far i have tried copying the "BackgroundCamera" Object to my scene, as it uses the script "VideoTextureBehavior", in which littlechiken suggested a code change to rotate the video. But the app crashes right away. I am new to vuforia so i don't understand the sample that well.

Camera Vertically Flipped - Archos 97 Titanium HD

March 3, 2014 - 10:32am #17

This is the sample that he's referring to - https://developer.vuforia.com/resources/sample-apps/background-texture-access-sample-app

What part do you need explained?

Camera Vertically Flipped - Archos 97 Titanium HD

March 3, 2014 - 9:12am #16

Hi,

could anyone please explain the first part of workaround provided by AlexanderB, that involves BackgroundTextureAccess sample from vuforia. Thanks.

Camera Vertically Flipped - Archos 97 Titanium HD

February 3, 2014 - 10:50pm #15

Ok i self did half part of it by using background texture access example and applying solution given by little chicken however now i ended up 3d model moving in opposite direction but i cant do changes provided by alexander cause in new version of vuforia StateManagerImpl.cs is inside an internal dll file, please help how can i make changes into it.

Camera Vertically Flipped - Archos 97 Titanium HD

February 3, 2014 - 4:22am #14

Can you post which version of vuforia you tested it with also i tried this solution but it seems like there is no instance of BakgroundCamera prefab is being created in final build for android like it does in webcam testing, so current solution doesnt works for me.

I am using vuforia version 2.6.7 with unity 4.2

 

Also i tried it on one of the chinese tablets on those it is showing only blank screen but tracking is working fine i.e. on pointing to marker it displays 3d content over it but it doesnt show camera at all. This problem is occuring from vuforia version 2.6 onwards.

 

Camera Vertically Flipped - Archos 97 Titanium HD

October 15, 2013 - 3:01am #13

Great!

You're welcome.

Camera Vertically Flipped - Archos 97 Titanium HD

October 15, 2013 - 1:32am #12

Sorry for the late reply, but we have tested it and it works nice. 
Thanks for the support!

 

Camera Vertically Flipped - Archos 97 Titanium HD

September 4, 2013 - 5:23am #11

Ok, so, this means that Vuforia is still "correctly" tracking based on the original camera image (which is rotated 180), while you are now correcting the video background rendering via UV map.

So, in order to "complete" the workaround, and make the 3D augmentation consistent with the image that you have rotated "ad hoc,

you also need to modify the code that handles the camera-to-target pose, which can be found in the PositionCamera() method in the StateManagerImpl.cs script;

this script is located under Assets/Qualcomm Augmentedf Reality/Scripts/Internal

The relevant code change which should make it happen is the following (see "Workaround code start" and "Workaround code end", the rest of the code is the one that you find in the original script):

// Utility function to get a quaternion out of a matrix in Unity
	private static Quaternion QuaternionFromMatrix(Matrix4x4 m) {
		Quaternion q = new Quaternion();
		q.w = Mathf.Sqrt( Mathf.Max( 0, 1 + m[0,0] + m[1,1] + m[2,2] ) ) / 2; 
		q.x = Mathf.Sqrt( Mathf.Max( 0, 1 + m[0,0] - m[1,1] - m[2,2] ) ) / 2; 
		q.y = Mathf.Sqrt( Mathf.Max( 0, 1 - m[0,0] + m[1,1] - m[2,2] ) ) / 2; 
		q.z = Mathf.Sqrt( Mathf.Max( 0, 1 - m[0,0] - m[1,1] + m[2,2] ) ) / 2; 
		q.x *= Mathf.Sign( q.x * ( m[2,1] - m[1,2] ) );
		q.y *= Mathf.Sign( q.y * ( m[0,2] - m[2,0] ) );
		q.z *= Mathf.Sign( q.z * ( m[1,0] - m[0,1] ) );
		return q;
	}
	
    // Position the camera relative to a Trackable.
    private void PositionCamera(TrackableBehaviour trackableBehaviour,
                                  Camera arCamera,
                                  QCARManagerImpl.PoseData camToTargetPose)
    {
		// ----------- Workaround code start -----------//
		Matrix4x4 camToTargetMat = new Matrix4x4();
		camToTargetMat.SetTRS(camToTargetPose.position, camToTargetPose.orientation, Vector3.one);
		
		// Apply 180 degrees pre-rotation
		Matrix4x4 rotMat = new Matrix4x4();
		rotMat.SetTRS(Vector3.zero, Quaternion.AngleAxis(180.0f, Vector3.forward), Vector3.one);
		camToTargetMat = rotMat * camToTargetMat;
		
		// get back the position and orientation
		camToTargetPose.position = camToTargetMat.MultiplyPoint(Vector3.zero);
		camToTargetPose.orientation = QuaternionFromMatrix(camToTargetMat);
		
		//-----------Workaround code end ------------------//
		
		
		
		arCamera.transform.localPosition =
                trackableBehaviour.transform.rotation *
                Quaternion.AngleAxis(90, Vector3.left) *
                Quaternion.Inverse(camToTargetPose.orientation) *
                (-camToTargetPose.position) +
                trackableBehaviour.transform.position;

        arCamera.transform.rotation =
                trackableBehaviour.transform.rotation *
                Quaternion.AngleAxis(90, Vector3.left) *
                Quaternion.Inverse(camToTargetPose.orientation);
    }

 

Note: I tested it, and it seems to work as expected.

Camera Vertically Flipped - Archos 97 Titanium HD

September 4, 2013 - 12:38am #10

Hey again,

Yesterday we've already tried playing with the VideoTextureBehaviour.cs but we were not able to get the result we hoped on. 

We have used the mirror example to also mirror the y-axis instead of just the x-axis.

So in VideoTextureBehaviour we have changed the if (qcarBehaviour.VideoBackGroundMirrored) code block to the following;

// mirror UV coordinates if necessary
if (qcarBehaviour.VideoBackGroundMirrored)
{
	uvs[p0Index] = new Vector2(scaleFactorX - uvs[p0Index].x, scaleFactorY - uvs[p0Index].y);
	uvs[p1Index] = new Vector2(scaleFactorX - uvs[p1Index].x, scaleFactorY - uvs[p1Index].y);
	uvs[p2Index] = new Vector2(scaleFactorX - uvs[p2Index].x, scaleFactorY - uvs[p2Index].y);
	uvs[p3Index] = new Vector2(scaleFactorX - uvs[p3Index].x, scaleFactorY - uvs[p3Index].y);
}

 

EDIT: forgot to explain what went wrong here.

This piece of code resulted in a correct rotation of the background texture. However, the translation of the AR object is now inverted, when you move towards the  center of the marker, the AR object now moves from the camera instead of to the camera. 

Camera Vertically Flipped - Archos 97 Titanium HD

September 3, 2013 - 8:48am #9

I got them, thanks.

So, if the issue is just a rotation of the background image, you could use the technique Background Texture Access sample;

in the sample you can find an object called BackgroundCamera, on which the video background is rendered as a texture;

if you look at the children of the BackgroundCamera, you will see an object called NegativeGrayScaleVideo, which has a couple of scripts attached:

  • VideoTextureBehaviour
  • NegativeGrayscaleEffect

On possibility would be to adjust the texture coordinates (UV map coordinates) on the mesh which is created in the CreateAndSetVideoTexture method inside the VideoTextureBehavious.cs script.

 

Camera Vertically Flipped - Archos 97 Titanium HD

September 3, 2013 - 7:56am #8

Hi,

I have sent you a private message containing a link to the screenshot.

To the others on the forum, basicly the camera image was flipped on both the X and Y axis.

 

Camera Vertically Flipped - Archos 97 Titanium HD

September 2, 2013 - 9:04am #7

Ok, thanks for the clarifications.

Could you attach a picture showing what you see on screen (including the augmentation 3D objects) ?

I just would like to be sure I have the exact understanding, before outlining the possible solution.

 

Camera Vertically Flipped - Archos 97 Titanium HD

September 2, 2013 - 8:27am #6

AlessandroB wrote:

If I understand correctly, the video is vertically flipped, but target detection and tracking works; is that correct ?

if that's the case, one workaround would be to manually flip the background image by looking at the Background Texture Access example...

 

I must appolgize for my first post, it is incorrect. The camera image is not vertically flipped but it's rotated 180 degrees to the right.

One other thing which might be worth mentioning is that we have forced the screenlayout to "landscape left" in Unity or android:screenOrientation="landscape" in the AndroidManifest.

But you're right, the detection and tracking works fine. 

Regarding manually flipping the background texture, what do you suggest which hardware specifications we check on?

 

Thanks in advance.

 

Camera Vertically Flipped - Archos 97 Titanium HD

September 2, 2013 - 7:52am #5

If I understand correctly, the video is vertically flipped, but target detection and tracking works; is that correct ?

if that's the case, one workaround would be to manually flip the background image by looking at the Background Texture Access example...

 

Camera Vertically Flipped - Archos 97 Titanium HD

September 2, 2013 - 2:58am #4

Is there any news regarding this issue? 

Camera Vertically Flipped - Archos 97 Titanium HD

August 12, 2013 - 1:54am #3

We are experiancing the same problem with this device. We are not using Unity, just Android SDK.

Is there any workaround possible?

Camera Vertically Flipped - Archos 97 Titanium HD

August 5, 2013 - 11:10am #2

Thanks for the report. Let me pass along this information to our engineering team to see what they have to say.

Topic locked