简体   繁体   中英

How to rotate video feed when changing device orientation on iPad2 (in Unity with Qualcomm QCAR extension)

I have developed an AR application for iPad2 that uses an ImageMarker to display a 3D object on screen, in front of the camera feed, when the marker is detected. My app needs to run in landscape mode to handle display of the 3D model well (aspect ratio of the 3D model object).

The app has GUI elements (buttons and labels), and these are also displayed in front of the video feed.

I have submitted the app to the app store, but it was rejected because the app only supports device orientation LandscapeLeft at the moment, and apple requires it to support at least two device orientations (LandscapeLeft & LandscapeRight is sufficient).

I have managed to rotate the GUI elements from LandscapeLeft to LandscapeRight when the iPad is rotated. I do this by looking for changes to the Input.deviceOrientation value, and when it changes, I set the iPhoneSettings.screenOrientation to either iPhoneScreenOrientation.LandscapeLeft or iPhoneScreenOrientation.LandscapeRight.

However, when I do this, the video feed is not also rotated. This has the effect that when I rotate the device from landscape left to landscape right, the GUI elements are rotated correctly, but the video feed is displayed upside down (it is not rotated).

Does anyone know if I can rotate the video feed to solve my problem? I am running the Qualcomm QCAR Unity 1.0 iOS extension and Unity 3.4.2.

With QCAR 1.5 you get access to the videofeed as a texture, so now you can map this texture to a plane that is behind all objects (eg near the far clipping distance) and rotate this plane by 180 degrees as needed.

Or you could leave the plane as is, and rotate the UV-coordinates . Or you could write a shader to sample the texture in a rotated way..

I'm not sure what will be the easiest way, because I haven't done accessed the videofeed myself yet, but if you look at the provided sample in the QCAR SDK it'll probably be obvious. The name of the (Android version of the) sample is qcar-unity-videobackgroundaccess-android-1-5-4-beta1.unitypackage.

Hope this helps (..someone, since the question is a bit old),

Lex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM