Log in or register to post comments

Rotated camera

December 15, 2014 - 10:37pm #1

I duplicated one of my existing textures for the purpose of using it as the rendertarget for Vuforia. I made it the rendertarget and all was well except the image showed up upside down. I simply rotated the image 180 degress on the x-axis and it showed perfectly. Not flipped or anything. Perfectly. 

Then I built the project for iOS and now suddenly the video on spans around 90% of the width of the image and only 90% of the height of the image AND it is rotated 90 degrees. I thought perhaps that UIDeviceOrientation setting I had to set in Xcode to make the project build was the roblem but setting that to any value makes no difference. It  is still rotated 90 degrees ccw and taking up only a percentage of the image... Why?

Maybe the fact that my device is locked to landscape but I am running an app in portrait only mode? Nope, unlocked it and it still does exactly the same. So I ask again, why? :(


I noticed the following in my Xcode logs. Perhaps this might prove insightful....

Can't add component because class 'PremiumObjectFactoryStarterBehaviour' doesn't exist!


Setting Unity version 4.6.0


2014-12-16 08:21:46.560 ProductName[359:69225] *** -[AVCaptureVideoDataOutput setVideoSettings:] - videoSettings dictionary contains one or more unsupported (ignored) keys: (





2014-12-16 08:21:46.568 ProductName[359:69225] DEBUG/AR(359) UIView has CAEAGLLayer class

2014-12-16 08:21:46.569 ProductName[359:69225] DEBUG/AR(359) UIView does not respond to selector renderFrameQCAR

2014-12-16 08:21:46.570 ProductName[359:69225] DEBUG/AR(359) UIView has CAEAGLLayer class

2014-12-16 08:21:46.570 ProductName[359:69225] DEBUG/AR(359) UIView does not respond to selector renderFrameQCAR

2014-12-16 08:21:46.571 ProductName[359:69225] DEBUG/AR(359) Could not find a UIView with CAEAGLLayer layer class that responds to selector renderFrameQCAR

(Repeated 3 times)
Thanks for any assistance


Rotated camera

December 26, 2014 - 1:17am #6

Ok, I think I understand better your issue;

in fact, there is no public API in the Vuforoia Unity Extension corresponding to the native QCAR::setRotation(QCAR::ROTATE_IOS_90);

In Unity you need to handle the "scaling" and the "rotation" aspects of the Camera in a different way;

the VideoTextureBehaviour.cs script included in the Bckground Texture Access sample is what you need to look at, as it contains both the "scaling" logic and the "rotation" logic that ensure a proper video texture maping in all orientations (including the Portrait case).

In particular, you'll want to have a look at:

  1. the method called "CreateVideoMesh", where you can find the "scaling" logic that relies on a comparison between the background "imageSize" and the background "textureSize" (see variables "scaleFactorX" and "scaleFactorY") and
  2. the metod called "PositionVideoMesh" which contains the "rotation" logic to handle different orientations

As you'll be able to see, this sample allows rendering the video backgroundtexture correctly on a textured plane in all orientations by using the code above (note: by default the sample starts is Portrait mode). You should be able to re-use the same code with minor adapatations for you GUI texture too.



Rotated camera

December 24, 2014 - 7:08am #5


How do I call this in Unity? I don't seem to have access to QCAR, only QCARUnity, QCARRuntimeUtilities, QCARManager etc etc etc...

Knowing that will most likely solve issue 1. Then it's just the issue of the clipped, non scaled image not filling the texture it is rendering to to be solved...

Halfway there already :P :D lol

Rotated camera

December 24, 2014 - 6:58am #4

Just to clarify this once more...

I have a texture in my project... I set that texture as the render target using:

QCARRRenderer.Instance.SetVideoBackgroundTexture( VideoFeedTexture );

QCARRenderer.Instance.DrawVideoBackground = false;

I then use that Texture2D as the source image for a RawTexture component in UGUI, Unity's new GUI system. As such, irrespective of the device's orientation, the video is still drawn to the same texture and the texture is displayed on screen in a region of the screen, not full screen. As such, the orientation of the device shouldn't make any difference, should it?

Rotated camera

December 24, 2014 - 6:47am #3

Hi again

Thanks for getting back to me on this. It's really been giving me gray hair so far... :(

I am currently on Unity 4.6.1 and using UGUI for my display. As explained in that link you posted, Unity 4.6 does not compile for iOS unless I make that change to the info.plist. I made this change and voila, the project builds just fine... except it doesn't run fine at all...

The image is rotated 90 degrees as explained before. I am including a screenshot to show the other problem. In the Unity Editor I can see the image is placed on the texture and it fills the texture 100% as one would expect it to do.... but when I run it on my iPhone, my iPad mini or my mate's iPad Air... the video takes up only a portion of the texture but also, instead of the entire video being scaled to fit the texture, n the iPhone about 90% of the video is clipped and the remaining small region of video is displayed on the texture but NOT stretched out to cover the entire texture... 

I am now wondering if Maybe our versions of Xcode might have any impact on things cause he and I have different results on the device. This screen shot is from his iPad Air and shows the image NOT rotated but with about 90% of the feed clipped. On my end the video is not clipped but I cannot get it to rotate at all. 

As per the instructions in that link you posted, he sets his rotation to landscape left and then the video displays correctly in portrat mode. Me, I can set that orientation to anything I want and it still shows up rotated 90 degrees CCW...

In any event, the video is rotated. Also, just for the sake of perfect clarity here, when I render to the texture, the video feed is already rotated 180 degrees so in Unity I rotate the texture by 180 degrees so it shows up correct in the editor. In iOS it is then rotated by 90 from that so eitherthe rotation is off by 90 degrees or 270...

I noticed in this very forum that in QCAR there is an initialisation flag that we can set. I think it's IOS_ROTATE_90. the fact that you HAVE such a flag says to me that this is a known issue you guys are aware of and do already handle... The question now is, why is that setting not available in the Unity pluginand how do I tackle that?

I can always have a look at the book sample you mention but the thing is, I don't care about supporting all orientations, just the one... just portrait. Not even portrait upside down, just portrait. Just that single orientation. I even lock the app to that orientation in Unity and verify it in Xcode before I build as I only need that one, is all... I need to use your kit to recognise text, nothing more. I don't do augmentation or anything else fancy like that... I just want it to recognise the text in front of the camera and then save the current frame as an image when I click on a button... really siple stuff I would have thought... Using your Text Recognition demo I was able to get the entire thing working as expected and all was well with the world... till I built it for iOS and found the rotated image not filling up the texture... :(

Image icon photo.jpg54.15 KB

Rotated camera

December 24, 2014 - 5:42am #2

Is your device running on iOS 8 ?  If so, I would suggest updating your Unity version to the latest Unity 4.5.5 patch p5 (if you are using Unity 4.5.x), which you can find here:


That contains a number of fixes and improvements specifically for Xcode 6 and iOS 8 support (note: in iOS8 they did change the handling of the screen width and height to be orientation dependent, so you need to use an updated Unity version to correctly handle that).


Alternatively, you could even upgrade to Unity 4.6.

See also:


As a second tip, you may want to try out the Books sample app, which has autorotation enabled and supports all orientations.


Log in or register to post comments