Tensorflow android demo出错了。无法连接到相机服务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tensorflow android demo出错了。无法连接到相机服务相关的知识,希望对你有一定的参考价值。

我试图运行Tensorflow demo for android。 (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android)我的手机是22级API。我按照说明运行演示。我无法连接到相机服务错误。我是android的新手。如何解决这个问题呢?给我任何线索来解决它。

我得到这个错误

12 - 20 16: 29: 20.150 7901 - 7901 / org.tensorflow.demo E / AndroidRuntime: FATAL EXCEPTION: main
Process: org.tensorflow.demo, PID: 7901
java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera. < init > (Camera.java: 497)
at android.hardware.Camera.open(Camera.java: 342)
at org.tensorflow.demo.LegacyCameraConnectionFragment$1.onSurfaceTextureAvailable(LegacyCameraConnectionFragment.java: 80)
at android.view.TextureView.getHardwareLayer(TextureView.java: 370)
at android.view.View.updateDisplayListIfDirty(View.java: 14144)
at android.view.View.getDisplayList(View.java: 14189)
at android.view.View.draw(View.java: 14959)
at android.view.ViewGroup.drawChild(ViewGroup.java: 3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 3198)
at android.view.View.updateDisplayListIfDirty(View.java: 14162)
at android.view.View.getDisplayList(View.java: 14189)
at android.view.View.draw(View.java: 14959)
at android.view.ViewGroup.drawChild(ViewGroup.java: 3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 3198)
at android.view.View.draw(View.java: 15234)
at android.widget.FrameLayout.draw(FrameLayout.java: 598)
at android.view.View.updateDisplayListIfDirty(View.java: 14167)
at android.view.View.getDisplayList(View.java: 14189)
at android.view.View.draw(View.java: 14959)
at android.view.ViewGroup.drawChild(ViewGroup.java: 3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 3198)
at android.view.View.updateDisplayListIfDirty(View.java: 14162)
at android.view.View.getDisplayList(View.java: 14189)
at android.view.View.draw(View.java: 14959)
at android.view.ViewGroup.drawChild(ViewGroup.java: 3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 3198)
at android.view.View.updateDisplayListIfDirty(View.java: 14162)
at android.view.View.getDisplayList(View.java: 14189)
at android.view.View.draw(View.java: 14959)
at android.view.ViewGroup.drawChild(ViewGroup.java: 3405)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 3198)
at android.view.View.draw(View.java: 15234)
at android.widget.FrameLayout.draw(FrameLayout.java: 598)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java: 2650)
at android.view.View.updateDisplayListIfDirty(View.java: 14167)
at android.view.View.getDisplayList(View.java: 14189)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java: 273)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java: 279)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java: 318)
at android.view.ViewRootImpl.draw(ViewRootImpl.java: 2530)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java: 2352)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java: 1982)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java: 1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java: 5885)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java: 767)
at android.view.Choreographer.doCallbacks(Choreographer.java: 580)
at android.view.Choreographer.doFrame(Choreographer.java: 550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java: 753)
at android.os.Handler.handleCallback(Handler.java: 739)
at android.os.Handler.dispatchMessage(Handler.java: 95)
at android.os.Looper.loop(Looper.java: 135)
at android.app.ActivityThread.main(ActivityThread.java: 5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java: 372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 698)
答案

您可能需要在运行时请求权限。有关此主题的更多信息,请参阅docs。在定位Android 6.0或更高版本时,需要请求运行时权限。

以上是关于Tensorflow android demo出错了。无法连接到相机服务的主要内容,如果未能解决你的问题,请参考以下文章

尝试在 android 中实现 SQlcipher 时出错

第一个 Kivy/Buildozer android 项目出错

导入 keras ModuleNotFoundError 时出错:没有名为“tensorflow.examples”的模块; 'tensorflow' 不是一个包

tensorflow c++ demo

记一次安装CPU版本的TensorFlow(numpy出错,ddl出错)解决

导入 tensorflow 模块时出错