自动拍照,没有用户交互 [英] Take picture automatically with no user interaction

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

问题描述

我想拍摄一张照片中,没有需要进行用户交互并显示没有用户interace元素这样的方式。换句话说,我想用一个后台进程拍照。没有声音必须(抢购的照片时,就像相机快门)进行。如果可能的话,这也将是很好,如果我可以设置相机的分辨率,而不是在拍摄之后调整图像大小。

我见过使用显示典型的相机应用,让用户手动拍照活动的所有code样品。


解决方案

我认为的相机概述以及过程pretty。你看过了吗?


  

      
  1. 从开放(INT)获得相机的一个实例。

  2.   
  3. 用getParameters()获取现有的(默认)设置。

  4.   
  5. 如果有必要,修改返回Camera.Parameters对象,然后调用setParameters(Camera.Parameters)。

  6.   
  7. 如果需要,调用setDisplayOrientation(INT)。

  8.   
  9. 重要:通过一个完全初始化SurfaceHolder设置previewDisplay(SurfaceHolder)。未经表面,相机将无法启动preVIEW。

  10.   
  11. 重要:呼叫开始preVIEW()开始更新preVIEW表面。 preVIEW必须先启动,然后才可以进行拍摄。

  12.   
  13. 当你想,叫takePicture(Camera.ShutterCallback,Camera.PictureCallback,Camera.PictureCallback,Camera.PictureCallback),以拍摄照片。等待回调提供实际的图像数据。

  14.   
  15. 拍摄照片后,preVIEW显示将停止。要拍摄更多的照片,通话开始preVIEW()再次第一。

  16.   
  17. 呼叫站preVIEW()停止更新preVIEW面。

  18.   
  19. 要点:呼叫释放()到其他应用程序发布使用相机。应用程序应该立即释放相机的onPause()(并重新打开()它onResume())。

  20.   

虽然它提到previews,你总是可以隐藏用于preVIEW表面。没有用户交互应该是必要的。

I would like to take a picture in such a way that no user interaction is required and no user interace elements are displayed. In other words, I want to take a picture using a background process. No sound must be made (like the camera shutter when snapping the photo). If possible, it would also be nice if I could set the resolution of the camera rather than resizing the image after it is taken.

All the code samples I've seen use an activity that displays the typical camera app and lets the user manually take the photo.

解决方案

I think the dev page for Camera outlines the process pretty well. Have you read it?

  1. Obtain an instance of Camera from open(int).
  2. Get existing (default) settings with getParameters().
  3. If necessary, modify the returned Camera.Parameters object and call setParameters(Camera.Parameters).
  4. If desired, call setDisplayOrientation(int).
  5. Important: Pass a fully initialized SurfaceHolder to setPreviewDisplay(SurfaceHolder). Without a surface, the camera will be unable to start the preview.
  6. Important: Call startPreview() to start updating the preview surface. Preview must be started before you can take a picture.
  7. When you want, call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback) to capture a photo. Wait for the callbacks to provide the actual image data.
  8. After taking a picture, preview display will have stopped. To take more photos, call startPreview() again first.
  9. Call stopPreview() to stop updating the preview surface.
  10. Important: Call release() to release the camera for use by other applications. Applications should release the camera immediately in onPause() (and re-open() it in onResume()).

While it does mention previews, you can always hide the surface that is used for preview. No user interaction should be necessary.

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

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