我在互联网上的一个代码中使用过,它是一个从设备(手机或笔记本电脑(的摄像头使用的kivy应用程序这是代码:
__author__ = 'bunkus'
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.clock import Clock
from kivy.graphics.texture import Texture
import cv2
from kivy.lang import Builder
class CamApp(App):
def build(self):
self.img1=Image()
layout = BoxLayout()
layout.add_widget(self.img1)
#opencv2 stuffs
self.capture = cv2.VideoCapture(0)
cv2.namedWindow("CV2 Image")
Clock.schedule_interval(self.update, 1.0/33.0)
return layout
def update(self, dt):
# display image from cam in opencv window
ret, frame = self.capture.read()
cv2.imshow("CV2 Image", frame)
# convert it to texture
buf1 = cv2.flip(frame, 0)
buf = buf1.tostring()
texture1 = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
#if working on RASPBERRY PI, use colorfmt='rgba' here instead, but stick with "bgr" in blit_buffer.
texture1.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
# display image from the texture
self.img1.texture = texture1
if __name__ == '__main__':
CamApp().run()
cv2.destroyAllWindows()
之后,我在Windows中成功地运行了这个应用程序,我决定用谷歌COALB和buildozer从这个代码中制作一个APK文件,所以我使用了colab并在那里运行了这些代码:
1:!pip安装buildozer
2:!pip安装cython
3:!sudo apt-get-install libffi dev
4:!buildozer初始化
然后我将buildozer.spec文件中的需求更改为**python、kivy、opencv**并在colab中运行以下代码:
5:!buildozer-v安卓调试
几分钟后,我得到这个错误:
Exception in thread background thread for pid 12137:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 1637, in wrap
fn(*rgs, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 2561, in background_thread
handle_exit_code(exit_code)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 2265, in fn
return self.command.handle_command_exit_code(exit_code)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 865, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_127:
RAN: /content/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh
STDOUT:
/content/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found
STDERR:
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1260, in <module>
main()
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 709, in __init__
getattr(self, command)(args)
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 216, in build_dist_from_args
args, "ignore_setup_py", False
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 577, in build_recipes
recipe.build_arch(arch)
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/recipes/libffi/__init__.py", line 40, in build_arch
shprint(sh.Command('./autogen.sh'), _env=env)
File "/content/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
for line in output:
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 911, in next
self.wait()
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 841, in wait
self.handle_command_exit_code(exit_code)
File "/usr/local/lib/python3.7/dist-packages/sh.py", line 865, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_127:
RAN: /content/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh
STDOUT:
/content/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found
STDERR:
Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=FSH --bootstrap=sdl2 --requirements=python3,kivy,opencv --arch armeabi-v7a --copy-libs --color=always --storage-dir="/content/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
ENVIRONMENT:
CUDNN_VERSION = '8.0.4.30'
PYDEVD_USE_FRAME_EVAL = 'NO'
LD_LIBRARY_PATH = '/usr/local/nvidia/lib:/usr/local/nvidia/lib64'
CLOUDSDK_PYTHON = 'python3'
LANG = 'en_US.UTF-8'
HOSTNAME = '8763b8d4778c'
OLDPWD = '/'
CLOUDSDK_CONFIG = '/content/.config'
NVIDIA_VISIBLE_DEVICES = 'all'
DATALAB_SETTINGS_OVERRIDES = '{"kernelManagerProxyPort":6000,"kernelManagerProxyHost":"172.28.0.3","jupyterArgs":["--ip=\"172.28.0.2\""],"debugAdapterMultiplexerPath":"/usr/local/bin/dap_multiplexer"}'
ENV = '/root/.bashrc'
PAGER = 'cat'
NCCL_VERSION = '2.7.8'
TF_FORCE_GPU_ALLOW_GROWTH = 'true'
JPY_PARENT_PID = '47'
NO_GCE_CHECK = 'True'
PWD = '/content'
HOME = '/root'
LAST_FORCED_REBUILD = '20210420'
CLICOLOR = '1'
DEBIAN_FRONTEND = 'noninteractive'
LIBRARY_PATH = '/usr/local/cuda/lib64/stubs'
GCE_METADATA_TIMEOUT = '0'
GLIBCPP_FORCE_NEW = '1'
TBE_CREDS_ADDR = '172.28.0.1:8008'
TERM = 'xterm-color'
SHELL = '/bin/bash'
GCS_READ_CACHE_BLOCK_SIZE_MB = '16'
PYTHONWARNINGS = 'ignore:::pip._internal.cli.base_command'
MPLBACKEND = 'module://ipykernel.pylab.backend_inline'
CUDA_VERSION = '11.0.3'
NVIDIA_DRIVER_CAPABILITIES = 'compute,utility'
SHLVL = '1'
PYTHONPATH = '/env/python'
NVIDIA_REQUIRE_CUDA = ('cuda>=11.0 brand=tesla,driver>=418,driver<419 '
'brand=tesla,driver>=440,driver<441 brand=tesla,driver>=450,driver<451')
COLAB_GPU = '0'
GLIBCXX_FORCE_NEW = '1'
PATH = '/root/.buildozer/android/platform/apache-ant-.9.4/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbn:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin:/opt/bin'
LD_PRELOAD = '/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4'
GIT_PAGER = 'cat'
_ = '/usr/local/bin/buildozer'
PACKAGES_PATH = '/root/.buildozer/android/packages'
ANDROIDSDK = '/root/.buildozer/android/platform/android-sdk'
ANDROIDNDK = '/root/.buildozer/android/platform/android-ndk-r19c'
ANDROIDAPI = '27'
ANDROIDMINAPI = '21'
Buildozer failed to execute the last command
The error might be hidden in the log above this error
Please read the full log, and search for it before
raising an issue with buildozer itself.
In case of a bug report, please add a full log with log_level = 2
/content/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found
尝试安装autoreconf。