没有相机应用拍照 [英] Take photo without camera application

查看:249
本文介绍了没有相机应用拍照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求在没有用户实际看到照片的情况下从相机拍摄照片。

I have a requirement whereby a photo needs to be taken from the camera without the user actually seeing it being taken.

iOS应用程序是否可以拍摄没有实际打开照片应用程序的照片?

Is it possible for an iOS application to take a photo without actually opening the photo app?

推荐答案

从你的简短描述和限制中,当然有可能。

From your brief description and constraints, of course it's possible.

我的假设是:


  • 您想从自己的应用程序执行此操作,而不是以某种方式启动Camera.app或Photos.app 。

  • 该应用程序正在运行(我没有在后台尝试过这个)。

只需拥有您的AVCaptureDevice requestAccessForMediaType: AVMediaTypeAudio (必填)和 AVMediaTypeVideo (某些地区需要)。然后,您可以使用它拍摄视频录制照片(如果您正在进行A / V录制,则只需要录制音频)。如果要将捕获内容保存到Photos.app相册,则用户也必须允许这样做。在所有情况下,将向用户显示允许应用访问相机(+麦克风)硬件或相册的选项 - 如果有任何被拒绝,该应用将无法捕获录制内容,也无法保存到照片分别是'专辑'。

Simply have your AVCaptureDevice requestAccessForMediaType: for AVMediaTypeAudio (required) and AVMediaTypeVideo (required in some regions). You can then use that to take video recordings and photos (you only need the audio if you're doing A/V recordings). If you want to save the captures to Photos.app albums, the user will have to allow that as well. In all cases, the user will be presented with the choice to allow the app access to the camera (+mic) hardware or the photos album -- if any are denied, the app will not be able to capture recordings, nor save to Photos' albums, respectively.

您将(显然)失去让用户触摸屏幕以关注兴趣点或其他功能的能力需要一个用户界面。

You're going to (obviously) lose the ability to have the user touch the screen to focus on a point of interest, or other features that demand a user interface.

如果您只想拍摄静态照片,请在 AVCaptureStillImageOutput 处开始阅读文档,特别是 captureStillImageAsynchronouslyFromConnection:completionHandler:

If you are just interested in capturing still photos, start your documentation reading at AVCaptureStillImageOutput, specifically captureStillImageAsynchronouslyFromConnection:completionHandler:.

忽略上述评论中的恐惧症 - 你会拥有无论如何要求用户获得许可,无法以100%隐藏的方式执行此操作。

Ignore the fear mongering in the comments above -- you will have to ask the user for permission regardless, there is no way to do this in a 100% hidden fashion.

话虽如此,您还必须遵守 App Store评论指南,我特别猜测隐私媒体内容法律要求

Having said that, you also must comply with the App Store Review Guidelines, and I'm guessing specifically the sections on privacy, media content, and legal requirements.

而且,最重要的是:


我们将拒绝Apps对于我们认为存在的任何内容或行为。你问什么线?好吧,正如最高法院法官曾经说过的那样,当我看到它时,我会知道它。我们认为你跨过它时也会知道它。

We will reject Apps for any content or behavior that we believe is over the line. What line, you ask? Well, as a Supreme Court Justice once said, "I'll know it when I see it". And we think that you will also know it when you cross it.

在这种情况下,我认为这意味着: don不是一个混蛋

In this case, I think that means: don't be a jerk.

这篇关于没有相机应用拍照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆