简体   繁体   English

基于陀螺仪的相机覆盖图像位置变化

[英]Camera overlay image position change based on gyro

I would like to create a mock AR (Aug Reality) demo using the camera whereby you can move the camera around and see information about the world around you. 我想使用相机创建一个模拟的AR(八月现实)演示,以便您可以移动相机并查看有关您周围世界的信息。 In the first instance as this would just be an initial demo I thought a sensible approach may be to use a large transparent image and based on the angle of the device a different portion of the image would be shown, so as you would tilt it up the image would move down and a different portion of the image would be shown, and as you would pan left and right the corresponding part of that image would show, appearing like there's an overlay over specific parts of the scene (from the camera). 首先,因为这只是一个初始演示,所以我认为明智的方法可能是使用较大的透明图像,并根据设备的角度显示图像的不同部分,以便将其向上倾斜图像将向下移动,并显示图像的不同部分,并且当您左右左右移动时,将显示该图像的相应部分,看起来就像场景的特定部分(来自相机)覆盖了一样。

My initial investigation leads me to believe the CMMotionManager class is probably the best to use to handle the device angle position and after which the centre of the image overlay would be altered accordingly. 我的初步调查使我相信CMMotionManager类可能是处理设备角度位置的最佳方法,此后,图像叠加层的中心将相应地更改。

My question is 2 fold: 我的问题是2折:

  • Is this a sensible approach for this, or should I look to go with another approach like splitting down to smaller images and "popping" up based on the device position? 这是一种明智的方法吗?还是我应该考虑采用另一种方法,例如分解为较小的图像并根据设备位置“弹出”?
  • Is there any example of approaches / code like this that have already been done? 有没有这样的方法/代码示例? Including some of the maths that may be involved. 包括一些可能涉及的数学。

Thanks, 谢谢,

To answer the first part of your question: 要回答问题的第一部分:

I think you're on the right track by using CMMotionManager since it provides stable estimates (by combing gyroscope, accelerometer, and magnetometer signals) of the devices roll, pitch, and yaw. 我认为使用CMMotionManager可以使您走上正确的道路,因为它可以(通过组合陀螺仪,加速计和磁力计信号)对设备的滚动,俯仰和偏航提供稳定的估计。 It's much more stable than using the gyro or accelerometer by themselves. 这比单独使用陀螺仪或加速度计要稳定得多。

Second part of your question: 问题的第二部分:

There is a good tutorial on augmented reality on the iphone on Ray Wenderlich's website . Ray Wenderlich网站上的iphone上有一个很好的增强现实教程。

Good luck. 祝好运。

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

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