python控制相机自动拍照_python控制gphoto2自动拍照

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值