简体   繁体   English

无需预览即可访问Android相机框架

[英]Access Android Camera Frames with no Preview

I want to do image processing on frames from Android Camera in real time with OpenCv, but all the OpenCv Android examples provide a preview of the image being captured. 我想使用OpenCv对Android Camera中的帧进行实时图像处理,但是所有的OpenCv Android示例都提供了所捕获图像的预览。 I really don't need previews of the frames , is there any way to get the frames without actually showing the preview ? 我真的不需要框架的预览,有没有办法在不实际显示预览的情况下获得框架?

一种快速/幼稚的方法是使onCameraFrame方法返回null并将您的CameraBridgeViewBase可见性设置为SurfaceView.INVISIBLESurfaceView.GONE

I still would like to know if it worked for you, but meanwhile I found the solution that worked for me. 我仍然想知道它是否对您有用,但是与此同时,我找到了对我有用的解决方案。 As I feel grateful for the guy who wrote it, I'm sharing this (scroll down to answers section) with anyone who will have same problem in future. 我为编写此书的人感到感激,因此我将与以后遇到相同问题的任何人分享此内容 (向下滚动至“答案”部分)。

In case the link vanished, here's his/her pro-tip: 万一链接消失,这是他/她的专业建议:

You can set your preview (in this case a CameraBridgeViewBase ) transparent by setting the alpha value of the view, with 0 being completely invisible. 您可以通过设置视图的Alpha值将预览(在本例中为CameraBridgeViewBase )设置为透明,而0则完全不可见。

mOpenCvCameraView.setAlpha(0);

This should make your preview "disappear". 这将使您的预览“消失”。


I wonder how your solution works, because as you can read in the docs : 我想知道您的解决方案如何工作,因为您可以在docs中阅读:

This method is invoked when delivery of the frame needs to be done. 需要完成帧的传递时调用此方法。 The returned values - is a modified frame which needs to be displayed on the screen. 返回的值-是修改后的框架,需要在屏幕上显示。

Indeed, in my case it doesn't work but I desperately need such a functionality. 确实,就我而言,它不起作用,但是我非常需要这样的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM