In vuforia sample i have customized for my own purpose. The camera is working in portrait and landscape it showing black screen on top of the live video stream. I have chanegd the code in SampleAppSession.mm & ImageTargetsViewController.mm file. Check the attached image.
ImageTargetsViewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Support all orientations
return YES;
}
// Not using iOS6 specific enums in order to compile on iOS5 and lower versions
-(NSUInteger)supportedInterfaceOrientations
{
return ((1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown));
}
// This is called on iOS 4 devices (when built with SDK 5.1 or 6.0) and iOS 6
// devices (when built with SDK 5.1)
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
[self handleRotation:interfaceOrientation];
}
- (void) handleRotation:(UIInterfaceOrientation)interfaceOrientation {
// ensure overlay size and AR orientation is correct for screen orientation
[self handleARViewRotation:self.interfaceOrientation];
// [bookOverlayController handleViewRotation:self.interfaceOrientation];
[vapp changeOrientation:self.interfaceOrientation];
/*
// adjust the size according to the rotation
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGRect overlayRect = screenRect;
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
overlayRect.size.width = screenRect.size.height;
overlayRect.size.height = screenRect.size.width;
}
*/
}
- (void) handleARViewRotation:(UIInterfaceOrientation)interfaceOrientation
{
CGPoint centre, pos;
NSInteger rot;
// Set the EAGLView's position (its centre) to be the centre of the window, based on orientation
centre.x = arViewRect.size.width / 2;
centre.y = arViewRect.size.height / 2;
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
NSLog(@"ARVC: Rotating to Portrait");
pos = centre;
rot = 90;
CGRect viewBounds;
viewBounds.origin.x = 0;
viewBounds.origin.y = 0;
viewBounds.size.width = arViewRect.size.width;
viewBounds.size.height = arViewRect.size.height;
[eaglView setFrame:viewBounds];
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
NSLog(@"ARVC: Rotating to Upside Down");
pos = centre;
rot = 270;
CGRect viewBounds;
viewBounds.origin.x = 0;
viewBounds.origin.y = 0;
viewBounds.size.width = arViewRect.size.width;
viewBounds.size.height = arViewRect.size.height;
[eaglView setFrame:viewBounds];
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
NSLog(@"ARVC: Rotating to Landscape Left");
pos.x = centre.y;
pos.y = centre.x;
rot = 180;
CGRect viewBounds;
viewBounds.origin.x = 0;
viewBounds.origin.y = 0;
viewBounds.size.width = arViewRect.size.height;
viewBounds.size.height = arViewRect.size.width;
[eaglView setFrame:viewBounds];
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
NSLog(@"ARVC: Rotating to Landscape Right");
pos.x = centre.y;
pos.y = centre.x;
rot = 0;
CGRect viewBounds;
viewBounds.origin.x = 0;
viewBounds.origin.y = 0;
viewBounds.size.width = arViewRect.size.height;
viewBounds.size.height = arViewRect.size.width;
[eaglView setFrame:viewBounds];
}
}