在Android的表面纹理相机preVIEW [英] Android camera preview on SurfaceTexture

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

问题描述

这是我的情况:我想,当有人在锁屏放入了不正确的密码,采取从前置摄像头的画面。基本上,我需要能够拍照出来的前凸轮没有preVIEW。

This is my scenario: I am trying to take a picture from the front camera when someone puts in the incorrect password in the lock screen. Basically, I need to be able to take a picture out of the front cam without a preview.

很多google搜索后,我想通了,做的方式是OpenGL和表面纹理。你直接在相机preVIEW到表面纹理,后来提取此纹理的图片不知何故。我发现了这一点,从以下资源:

After much googling, I figured out that the way to do it is opengl and SurfaceTexture. You direct the camera preview to a SurfaceTexture, and later extract the picture from this texture somehow. I found this out from the following resources:


  1. http://stackoverflow.com/a/10776349/902572 (建议1)

  2. http://www.freelancer.com/projects/Android-opengl/Android-OpenGL-App-Access-Raw.html,这是相同的:(1)

  3. https://groups.google.com/forum/#​​!专题/ Android的开发者/ U5RXFGpAHPE (见罗曼对11年12月22日文章)

  1. http://stackoverflow.com/a/10776349/902572 (suggestion 1)
  2. http://www.freelancer.com/projects/Android-opengl/Android-OpenGL-App-Access-Raw.html, which is the same as (1)
  3. https://groups.google.com/forum/#!topic/android-developers/U5RXFGpAHPE (See Romain's post on 12/22/11)

我明白了什么是必须要做的,但我一直无法正确地把它们放到code,因为我是新来的OpenGL。

I understand what is to be done, but i have been unable to correctly put them into code, as I am new to opengl.

推荐答案

借助 CameraToMpegTest 例子有你最需要的东西,但它远远超出了你的使用情况(它记录一系列preVIEW帧作为视频)。

The CameraToMpegTest example has most of what you need, though it goes well beyond your use case (it's recording a series of preview frames as a video).

你需要什么剩下的就是在 ExtractMpegFramesTest 。特别是,要渲染到屏幕外的pbuffer(而不是媒体codeC 连接codeR输入表面),并且可以保存pbuffer的内容使用PNG文件 saveFrame()

The rest of what you need is in ExtractMpegFramesTest. In particular, you want to render to an offscreen pbuffer (rather than a MediaCodec encoder input surface), and you can save the pbuffer contents as a PNG file using saveFrame().

以上是写成小的无头的测试用例。你可以看到类似code在一个完整的应用程序在 Grafika

The above are written as small "headless" test cases. You can see similar code in a full app in Grafika.

这篇关于在Android的表面纹理相机preVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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