本文介绍了在服务/后台进程摄像机架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关科学测量,我想从一个服务访问摄像头帧。这样做是为了分析在某些条件下进行实时来自摄像机的图像。由于电话可能重新启动或简单地锁定,则应该可以从服务开始的过程。

For scientific measurements, I would like to access the camera frames from a service. The idea is to analyze the images coming from the camera in real-time under some conditions. Since the phone might be restarted or simply locked, it should be possible to start the process from a service.

现在,我通过使用满足了 Camera.Callback 在previewFrame 回调,但现在看来,它只是如果我的应用程序在前台运行工作。更多precisely,相机需要一个有效的 SurfaceView ,以便调用在previewFrame 功能。和 SurfaceView 在创建活动时,活动被减到最少被销毁/成品。

For now, I was satisfied by using a Camera.Callback and the onPreviewFrame callback, but it appears that it only works if my application is running in foreground. More precisely, the camera requires a valid SurfaceView in order to call the onPreviewFrame function. And a SurfaceView created in an Activity is destroyed when the activity is minimized / finished.

我无法找到一种方式来获得从后台进程的框架。其实,它的工作原理上的 Galaxy Note的10.1 ,而银河S4 需要一个有效的SurfaceView。

I just cannot find a way to get the frames from a background process. Actually, it works on a Galaxy Note 10.1, but the Galaxy S4 requires a valid SurfaceView.

有没有办法来实现这一目标?

Is there a way to achieve this?

有关于这个话题很多的StackOverflow,但没有为我工作。

There are many topics about this on StackOverflow, but none worked for me.

推荐答案

您可以发送preVIEW到的表面纹理代替(设置previewTexture())。当应用程序被暂停这不会消失。需要API 11 +。

You can send the preview to a SurfaceTexture instead (setPreviewTexture()). This won't disappear when the app is paused. Requires API 11+.

您可以看到这种技术在 Grafika ,这一般是在做视频或GLES操作,而各种应用比剧照,但这个想法是相似的。

You can see various applications of this technique in Grafika, which is generally doing video or GLES manipulation rather than stills, but the idea is similar.

这篇关于在服务/后台进程摄像机架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 06:13