我只需要拿到相机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: 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 :(