简体   繁体   English

Buildroot上的Python picamera?

[英]Python picamera on Buildroot?

from picamera import PiCamera gives the following errors in python3.7 on buildroot-generated linux image. from picamera import PiCamera在buildroot生成的linux映像上的from picamera import PiCamera给出以下错误。 Appreciate advice on how to fix. 赞赏有关如何修复的建议。 Thanks! 谢谢!

/usr/bin/python3.7: symbol 'mmal_port_pool_create': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_list_push_front': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_list_destroy': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_rational_to_fixed_16_16': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_status_to_string': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_list_push_back': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_list_create': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_list_insert': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_rational_equal': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_list_pop_front': can't resolve symbol
/usr/bin/python3.7: symbol 'mmal_port_type_to_string': can't resolve symbol
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/picamera/__init__.py", line 72, in <module>
    from picamera.exc import (
  File "/usr/lib/python3.7/site-packages/picamera/exc.py", line 41, in <module>
    import picamera.mmal as mmal
  File "/usr/lib/python3.7/site-packages/picamera/mmal.py", line 49, in <module>
    _lib = ct.CDLL('libmmal.so')
  File "/usr/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen() error

You need to select the rpi-userland package. 您需要选择rpi-userland软件包。

I'm assuming you work on a Raspberry Pi, otherwise picamera is not for you to begin with. 我假设您在Raspberry Pi上工作,否则picamera不适合您开始。

picamera tries to open the libmmal.so shared library. picamera尝试打开libmmal.so共享库。 The rpi-userland Buildroot package will download, build and install this library. rpi-userland Buildroot软件包将下载,构建和安装该库。

If you made a Buildroot package for python-picamera , you should add select BR2_PACKAGE_RPI_USERLAND to its Config.in file, and also copy the dependencies of the rpi-userland package. 如果为python-picamera软件包,则应将select BR2_PACKAGE_RPI_USERLAND添加到其Config.in文件中,并复制rpi-userland软件包的依赖项。 In the python-picamera.mk file, you should add PYTHON_PICAMERA_DEPENDENCIES += rpi-userland . python-picamera.mk文件中,您应该添加PYTHON_PICAMERA_DEPENDENCIES += rpi-userland This will make sure that the package is always selected and built when you enable picamera. 这样可以确保在启用picamera时始终选择并构建该程序包。

Also, if you have a working python-picamera package, please consider sending it upstream following the contribution guidelines . 另外,如果您有可用的python-picamera软件包,请考虑按照贡献准则将其发送到上游。

If you did not make a Buildroot package for python-picamera , that might be the source of the problem. 如果您没有为python-picamera软件包,则可能是问题的根源。 The picamera package from PyPI is linked with a specific version of libmmal, which may be a different version than the one in Buildroot. PyPI的picamera软件包与libmmal的特定版本链接,该版本可能与Buildroot中的版本不同。 This might lead to the errors you see when importing the module. 这可能会导致导入模块时看到的错误。

FWIW I ended up just using raspistill... FWIW我最终只是使用raspistill ...

  raspistill_params = (' -n'
  + ' -ISO ' + str(iso)
  + ' -ss ' + str(shutter_speed)
  + ' -mm ' + meter_mode
  + ' -ex ' + exposure_mode
  + ' --ev ' + str(exposure_compensation)
  + ' -awb ' + awb_mode
  + ' -br ' + str(brightness)
  + ' -co ' + str(contrast)
  + ' -sa ' + str(saturation)
  + ' -sh ' + str(sharpness)
  + ' -drc ' + drc_strength
  + ' -rot ' + str(rotation) 
  + ' -q ' + str(quality) 
  + ' -w ' + str(width) 
  + ' -h ' + str(height) 
  + ' -ae ' + str(annotate_text_size) + ',0xff,0x808000 '
  + ' -a "' + annotate_text + '"'
  + ' -x GPS.GPSLatitudeRef=' + exif_lat_ref(latitude)  
  + ' -x GPS.GPSLatitude=' + exif_latlong(latitude)  
  + ' -x GPS.GPSLongitudeRef=' + exif_long_ref(longitude)  
  + ' -x GPS.GPSLongitude=' + exif_latlong(longitude) 
  + ' -o ' + filename
  )

  proc = subprocess.Popen("raspistill " + raspistill_params, shell=True, stdout=subprocess.PIPE)
  ret_val = proc.communicate() 
sudo apt-get update
sudo apt-get upgrade

sudo raspi-config

Enable camera and reboot 启用相机并重启

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

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