简体   繁体   中英

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. 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.

My question is 2 fold:

  • 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. 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 .

Good luck.

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