简体   繁体   中英

Python picamera on Buildroot?

from picamera import PiCamera gives the following errors in python3.7 on buildroot-generated linux image. 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.

I'm assuming you work on a Raspberry Pi, otherwise picamera is not for you to begin with.

picamera tries to open the libmmal.so shared library. The rpi-userland Buildroot package will download, build and install this library.

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. In the python-picamera.mk file, you should add PYTHON_PICAMERA_DEPENDENCIES += rpi-userland . This will make sure that the package is always selected and built when you enable picamera.

Also, if you have a working python-picamera package, please consider sending it upstream following the contribution guidelines .

If you did not make a Buildroot package for python-picamera , that might be the source of the problem. The picamera package from PyPI is linked with a specific version of libmmal, which may be a different version than the one in Buildroot. This might lead to the errors you see when importing the module.

FWIW I ended up just using 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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