在UIView中嵌入实时相机视图 [英] embed live camera view inside a UIView
问题描述
我一直在想办法在iPhone的 UIView
里面嵌入一个小的(ish)实时相机视图。
我甚至没有能够在网上找到任何样品。我知道它是可行的,但我甚至不知道从哪里开始。似乎有很多例子,其他人已添加视图到相机的完整的屏幕视图,而不是其他方式...
I've been trying to figure out how to embed a small(ish) live camera view inside of an iPhone's UIView
to no avail.
I have not even been able to find any samples of that on the net either. I know that it's do-able, but I don't even know where to start. There seem to be a lot of examples where others have added views TO the full-blown screen view of the camera, but not the other way around...
似乎 UIImagePickerControllerSourceTypeCamera
只是显示大模态摄像机
查看器,图片接收器,因此它不适合我的目的
It seems that UIImagePickerControllerSourceTypeCamera
just displays the BIG modal camera
viewer, picture taker, so it is unsuitable (I think) for my purposes.
我想有一个小的活的相机视图,在 UIView
里面,我可以添加我自己的按钮
采取pic我可以想出这个 - 一个代表以某种形式捕获
的图像)
I want to have a small live camera view, inside a UIView
, and I can add my own buttons
for taking the pic (I can probably figure this out - a delegate of some sort to capture
the image)
谢谢...
推荐答案
出于您的目的,您需要使用 AVFoundation ,具体看看 AVCaptureSession
, AVCaptureDeviceInput
您可以使用它来访问摄像机,并查看 AVCaptureVideoPreviewLayer
,这将允许您将相机输入绘制到屏幕,所需的一切是在那里..
For your purpose you need to use AVFoundation, specifically look at AVCaptureSession
, AVCaptureDeviceInput
, which you can use in order to get access to the cameras and look into AVCaptureVideoPreviewLayer
which will allow you to draw the camera input to the screen, everything you need is in there..
这篇关于在UIView中嵌入实时相机视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!