简体   繁体   English

在iPad2上更改设备方向时如何旋转视频源(在带有Qualcomm QCAR扩展的Unity中)

[英]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. 我已经为iPad2开发了一个AR应用程序,当检测到标记时,该应用程序使用ImageMarker在相机源的前面在屏幕上显示3D对象。 My app needs to run in landscape mode to handle display of the 3D model well (aspect ratio of the 3D model object). 我的应用程序需要以横向模式运行才能很好地处理3D模型的显示(3D模型对象的纵横比)。

The app has GUI elements (buttons and labels), and these are also displayed in front of the video feed. 该应用程序具有GUI元素(按钮和标签),这些元素也显示在视频源的前面。

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). 我已将应用程序提交到应用程序商店,但是由于该应用程序目前仅支持设备方向LandscapeLeft,并且苹果要求它至少支持两个设备方向(LandscapeLeft和LandscapeRight才足够),因此被拒绝。

I have managed to rotate the GUI elements from LandscapeLeft to LandscapeRight when the iPad is rotated. 旋转iPad时,我设法将GUI元素从LandscapeLeft旋转到LandscapeRight。 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. 我通过查找Input.deviceOrientation值的更改来完成此操作,并在更改时将iPhoneSettings.screenOrientation设置为iPhoneScreenOrientation.LandscapeLeft或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). 这样的效果是,当我将设备从左横向旋转到右横向旋转时,GUI元素正确旋转,但视频提要却上下颠倒显示(未旋转)。

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. 我正在运行Qualcomm QCAR Unity 1.0 iOS扩展和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. 使用QCAR 1.5您可以以纹理的形式访问视频源,因此现在您可以将此纹理映射到所有对象后面的平面(例如,在较远的剪切距离附近),并根据需要将该平面旋转180度。

Or you could leave the plane as is, and rotate the UV-coordinates . 或者,您可以按原样离开飞机,然后旋转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. 我不确定最简单的方法是什么,因为我还没有亲自访问过视频供稿,但是如果您查看QCAR SDK提供的示例,则可能会很明显。 The name of the (Android version of the) sample is qcar-unity-videobackgroundaccess-android-1-5-4-beta1.unitypackage. (Android版本的)示例的名称为qcar-unity-videobackgroundaccess-android-1-5-4-beta1.unitypackage.

Hope this helps (..someone, since the question is a bit old), 希望这会有所帮助(..某人,因为这个问题有点老了),

Lex 莱克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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