gphoto2驱动可以进行自动拍照,有一个命令行可以控制时间和次数。嗯,现在我们用python来编程控制,是不是更强大?
gphoto2 1.3.3
Python interface to libgphoto2
python-gphoto2 is a comprehensive Python interface (or binding) to libgphoto2. It is built using SWIG to automatically generate the interface code. This gives direct access to nearly all the libgphoto2 functions, but sometimes in a rather un-Pythonic manner.
Other Python bindings to libgphoto2 are available:piggyphoto uses ctypes (included in standard Python installations) to interface to the library. The gphoto2 source tree includes some Python bindings which also use ctypes.gphoto2-cffi uses cffi.
Contents
Python: http://python.org/ version 2.6 or greater (including Python 3)
SWIG: http://swig.org/ (optional since python-gphoto2 v0.11)
Note that you need the “development headers” versions of libgphoto2 and Python. Most Linux distributions’ package managers have these, but the names vary. Look for libgphoto2-2-dev or libgphoto2-devel or something similar.
There are several ways to install python-gphoto2, with varying levels of control over the installation process.
The commands below will install python-gphoto2 for your default Python version. To install for both Python 2 and Python 3, run the installation process twice with specific commands, i.e. pip2 and pip3 or python2 and python3.
Install with pip
The easiest installation method is to use the pip command:
sudo pip install -v gphoto2
Note that this may take longer than you expect as the SWIG generated files are compiled during installation. The -v option increases pip’s verbosity so you can see that it’s doing something.
Visit PyPI and download one of the zip or tar.gz files, then extract it and change to the new directory. For example:
tar xzf gphoto2-0.11.0.tar.gz
cd gphoto2-0.11.0
Python’s distutils are used to build and install python-gphoto2:
python setup.py build
sudo python setup.py install
Install from GitHub (SWIG required)
To install the very latest version, use git to “clone” the GitHub repository, then change to the new directory:
git clone https://github.com/jim-easterbrook/python-gphoto2.git
cd python-gphoto2
As before, Python’s distutils are used to build and install python-gphoto2, but now you have to run SWIG first to generate the files to be compiled:
python setup.py build_swig
python setup.py build
sudo python setup.py install
See “running SWIG” below for more detail.
Note
If you installed with pip the example files should be in /usr/share/python-gphoto2/examples or /usr/local/share/python-gphoto2/examples or somewhere similar. Otherwise they are in the examples sub-directory of your working directory.
Connect a digital camera to your computer, switch it on, and try one of the example programs:
python examples/camera-s