0

I'm trying to write an augment reality app for iOS tablet. For this I use AVFoundation classes to translate video from camera to screen. The augment objects are simple UILabels "flying in the air". It must look like the labels are in front of you and save the position even if you rotate the tablet. As usual i'm using CMMotionManager to capture device gyroscope data. My problem is - I can't correctly apply device rotation quaternion to the flying UILabels. The labels are rotating around they own axes, but they must rotate "around the tablet axes". How to describe this mathematically? For now i only have an idea of a imaginary sphere that is around the tablet, the labels are positioned on this sphere and when you rotate the tablet than this imaginary sphere is rotating with labels in opposite direction around the same axis. I don't wanna use any 3rd party libs.

Rajesh
  • 10,318
  • 16
  • 44
  • 64

2 Answers2

0

I have worked on a similar app. But in my case the scenario was a little different. I was using UIImageView instead of UILabel. What I did was I made another UIView and made its background to default/transparent. And on that view I placed my UIImageView which rotates when UIView rotates but the CameraView UIView was creating problems with rotating. Luckily as per my requirements I have to force the device orientation to stay in landscape mode. For which I used:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeRight;
}

and

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

So add a transparent UIView. Then check if the problem still remains define your UIInterfaceOrientationMask in all the four possible orientations and see if it works or not.

0

At the end i decided to use this library: https://github.com/antonholmquist/rend-ios. Its not that easy to make this task on pure UIKit.