图像可用的侦听器拾取片段的图像,并且一旦图像可用,就会连续调用onimageavailble() 。 代码实例如下:
protected void onCreate(final Bundle savedInstanceState) { super.onCreate(null); getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_camera); setFragment(); }setFragment()代码是:
protected void setFragment() { final Fragment fragment = CameraConnectionFragment.newInstance( new CameraConnectionFragment.ConnectionCallback() { @Override public void onPreviewSizeChosen(final Size size, final int rotation) { CameraActivity.this.onPreviewSizeChosen(size, rotation); } }, this, getLayoutId(), getDesiredPreviewFrameSize()); getFragmentManager() .beginTransaction() .replace(R.id.container, fragment) .commit(); }代码在Android上正确运行,因此我希望它在Android Things设备上实现,但我收到一条警告,指出' 一个TextureView或一个子类只能用于启用硬件加速 ',并且永远不会调用onimageavailble() 。 我在代码中进行了必要的更改以解决警告,但仍然没有调用onimageavailble() 。
在调试用于android事物的raspberry Pi3中的代码时,我注意到片段中没有显示相机流,因为图像侦听器无法选择一个。
请为我提供这个问题的解决方案
Image available listener picks up an image of the fragment and onimageavailble() is invoked continuously as soon as the image is available. An instance of the code is as below:
protected void onCreate(final Bundle savedInstanceState) { super.onCreate(null); getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_camera); setFragment(); }The setFragment() code is:
protected void setFragment() { final Fragment fragment = CameraConnectionFragment.newInstance( new CameraConnectionFragment.ConnectionCallback() { @Override public void onPreviewSizeChosen(final Size size, final int rotation) { CameraActivity.this.onPreviewSizeChosen(size, rotation); } }, this, getLayoutId(), getDesiredPreviewFrameSize()); getFragmentManager() .beginTransaction() .replace(R.id.container, fragment) .commit(); }The code runs correctly on Android and so I wanted it to implement on Android Things device but I was getting a warning stating 'A TextureView or a subclass can only be used with hardware acceleration enabled' and the onimageavailble() is never called. I made required changes in the code to resolve the warning but still, onimageavailble() is never called.
On debugging the code in raspberry Pi3 for android things, I noticed that camera stream is not being displayed in the fragment because of which image listener is unable to pick one.
please provide me with the solution for this problem
最满意答案
您正在使用WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED (使用AndroidThings 0.3.0 )
R Pi的硬件加速仅在AndroidThings 0.5.0引入
请参阅此处的发行说明:
https://developer.android.com/things/preview/releases.html
随着Android O的更新,现在支持OpenGL ES 2.0。 带GPU的平台(如Raspberry Pi 3)现在也支持硬件加速。
请更新您正在使用的AndroidThings版本。
You are using WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED (with AndroidThings 0.3.0)
Hardware Acceleration for the R Pi was only introduced in AndroidThings 0.5.0
See the release notes here:
https://developer.android.com/things/preview/releases.html
With the update to Android O, OpenGL ES 2.0 is now supported. Platforms with a GPU (such as Raspberry Pi 3) also now support hardware acceleration.
Please update the version of AndroidThings you are using.
更多推荐
onimageavailble,fragment,代码,code,电脑培训,计算机培训,IT培训"/> <meta name=&q
发布评论