隐形SurfaceView相机preVIEW [英] Invisible SurfaceView for Camera Preview

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

问题描述

我只需要拿到相机preVIEW数据,但不可见preVIEW。 因为我做的这一切都在一个服务,我不得不创建一个虚拟SurfaceView,这工作得很好。

I need to get camera preview data only, but not visible preview. Since I'm doing all this in a service, I had to create a dummy SurfaceView, which works very well.

我用这个答案code: <一href="http://stackoverflow.com/a/10268650/1395697">http://stackoverflow.com/a/10268650/1395697

I've used the code from this answer: http://stackoverflow.com/a/10268650/1395697

然而,随着TYPE_SYSTEM_OVERLAY没有奏效。它是无形的,但没有收到preVIEW数据(在previewFrame())。当我这个参数更改为0,我得到preVIEW数据,但SurfaceView是可见的。

However, with TYPE_SYSTEM_OVERLAY it didn't work. It was invisible but no preview data was received (in onPreviewFrame()). When I change this argument to 0, I get preview data, but the SurfaceView is visible.

你知不知道任何其他方式做到这一点?

Do you know any other way to do this?

我所做的现在只是做一个明显的SurfaceView一个宽度为1和高度,然后创建一个ImageView的覆盖与特定的颜色,这样你就不会看到SurfaceView的颜色变化。但是,这是不是整齐的一切,我真的很想做一个好一点......

What I did now is just make a visible SurfaceView with width and height of 1 and then I create an ImageView overlay with a specific color so that you don't see the change of color of the SurfaceView. But this isn't neat at all and I'd really like to do it a bit better...

推荐答案

我也用同样的计算器的答案,并获得相同的problem.so:

i also used the same stackOverflow answer, and get the same problem.so:

我添加了这code

this.setZOrderOnTop(true);
SurfaceHolder h = this.getHolder();
h.setFormat(PixelFormat.TRANSPARENT);

我surfaceChanged的方法,而不是活动(或在我的情况下,服务),并把它trasparent,但日志上抱怨被遗弃的框架:(

to my surfaceChanged method, instead of the activity (or a service at my case), and got it trasparent, but the Log complains on abandoned frames :(

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

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