相机作为背景视图?
我想用增强现实进行一些测试。我的第一个问题是如何获取来自相机的图片作为我的视图背景?对于我想做的事情,我不需要访问图片,我只需要它作为背景。我找到了一些如何使用相机拍照的解决方案,但没有任何解决方案可以为我提供来自相机的照片。
谢谢,。
I would like to test around a bit with augmented reality. My first problem is how to get the picture that comes from the camera as background for my view? For what i want to do, i dont need to access the picture, i just need it as background. I found a few solutions how to take a picture with the camera, but nothing that gives me a picture that comes from the camera.
thanks,.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会使用 AVFoundation 来实现这一点。
您需要使用 AVCaptureDevice 和 AVCaptureDeviceInput 设置 AVCaptureSession。最后 - 这就是您感兴趣的 - 设置 AVCaptureVideoPreviewLayer。
将 startRunning: 消息发送到您的 AVCaptureSession 对象,然后您就可以开始了。
此处的文档:
I would use AVFoundation for that.
You need to set up an AVCaptureSession with an AVCaptureDevice and an AVCaptureDeviceInput. Finally - and this is what you're interested in - set up an AVCaptureVideoPreviewLayer.
Send the startRunning: message to your AVCaptureSession object, and you should be good to go.
Docs here: http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/03_MediaCapture.html#//apple_ref/doc/uid/TP40010188-CH5-SW14
另一种方法是使用 UIImagePickerController 。
创建一个实例,例如 picker 并设置:
picker.showsCameraControls = NO
。最后使用叠加层设置
cameraOverlayView
:picker.cameraOverlayView = someViewController.view
。希望这有帮助。
another way would be using
UIImagePickerController
.Create an instance, say picker and set:
picker.showsCameraControls = NO
.And finally set
cameraOverlayView
with your overlay:picker.cameraOverlayView = someViewController.view
.Hope this helps.