ARToolkit,UIImagePickerController& cameraOverlayView:如何拍照?

时间:2011-06-17 12:00:01

标签: iphone uiimagepickercontroller augmented-reality

我正在使用ARToolkit为iPhone开发增强现实版应用程序。现在我想将其功能包含在主应用程序中,并带有一个按钮,该按钮会抛出“AR视图”,以便能够在其上拍摄3D模型。

我正在使用 UIImagePickerController cameraOverlayView 将ARViewController视图添加到相机视图中,作为叠加层,但它不会显示它。这是代码:

-(IBAction)Switch2AR:(id)sender{

ARController = [[ARViewController alloc] init];
[ARController loadView];

UIImagePickerController *picker  = [[UIImagePickerController alloc]init];
    picker.delegate = self;


if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
picker.showsCameraControls = YES;

picker.cameraOverlayView = ARController.view;


//[ARController.view addSubview: picker.view];
//[picker.view addSubview: ARController.view];

//[picker viewWillAppear:YES];
//[picker viewDidAppear:YES];
//[ARController viewWillAppear:YES];
//[ARController viewDidAppear:YES];


[self presentModalViewController:picker animated:YES];

[ARController release];

}

我还尝试将 UIImagePickerController 视图添加为 ARViewController视图的子视图,但由于相机模态视图隐藏了' AR视图。 ARViewController视图也是 UIImagePickerController 子视图。

问题是我无法以任何方式覆盖我的ARView和相机视图

提前致谢

1 个答案:

答案 0 :(得分:0)

只需更改

picker.showsCameraControls = YES;

picker.showsCameraControls = NO;

它应该有用。