Skip to content

Commit 19d80c0

Browse files
committed
Initial commit
0 parents  commit 19d80c0

9 files changed

+3795
-0
lines changed

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*.py[cdo]
2+
*.vim
3+
*.swp
4+
tags
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
eggs
12+
parts
13+
bin
14+
var
15+
sdist
16+
develop-eggs
17+
.installed.cfg
18+
19+
# Installer logs
20+
pip-log.txt
21+
22+
# Unit test / coverage reports
23+
coverage
24+
.coverage
25+
.tox
26+
27+
#Translations
28+
*.mo
29+
30+
#Mr Developer
31+
.mr.developer.cfg
32+
33+
#License files (generated by Makefile)
34+
LICENSE.rtf
35+

LICENSE.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2013 Dave Hughes <[email protected]>
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of the copyright holder nor the
12+
names of its contributors may be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
POSSIBILITY OF SUCH DAMAGE.
26+

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
prune debian
2+
prune docs
3+
include README.rst
4+
include LICENSE.txt

Makefile

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# vim: set noet sw=4 ts=4 fileencoding=utf-8:
2+
3+
# External utilities
4+
PYTHON=python3
5+
PYFLAGS=
6+
DEST_DIR=/
7+
8+
# Horrid hack to ensure setuptools is installed in our python environment. This
9+
# is necessary with Python 3.3's venvs which don't install it by default.
10+
ifeq ($(shell python -c "import setuptools" 2>&1),)
11+
SETUPTOOLS:=
12+
else
13+
SETUPTOOLS:=$(shell wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $(PYTHON))
14+
endif
15+
16+
# Calculate the base names of the distribution, the location of all source,
17+
# documentation, packaging, icon, and executable script files
18+
NAME:=$(shell $(PYTHON) $(PYFLAGS) setup.py --name)
19+
VER:=$(shell $(PYTHON) $(PYFLAGS) setup.py --version)
20+
PYVER:=$(shell $(PYTHON) $(PYFLAGS) -c "import sys; print('py%d.%d' % sys.version_info[:2])")
21+
PY_SOURCES:=$(shell \
22+
$(PYTHON) $(PYFLAGS) setup.py egg_info >/dev/null 2>&1 && \
23+
cat $(NAME).egg-info/SOURCES.txt)
24+
DOC_SOURCES:=$(wildcard docs/*.rst)
25+
26+
# Calculate the name of all outputs
27+
DIST_EGG=dist/$(NAME)-$(VER)-$(PYVER).egg
28+
DIST_TAR=dist/$(NAME)-$(VER).tar.gz
29+
DIST_ZIP=dist/$(NAME)-$(VER).zip
30+
31+
32+
# Default target
33+
all:
34+
@echo "make install - Install on local system"
35+
@echo "make develop - Install symlinks for development"
36+
@echo "make test - Run tests"
37+
@echo "make doc - Generate HTML and PDF documentation"
38+
@echo "make source - Create source package"
39+
@echo "make egg - Generate a PyPI egg package"
40+
@echo "make zip - Generate a source zip package"
41+
@echo "make tar - Generate a source tar package"
42+
@echo "make dist - Generate all packages"
43+
@echo "make clean - Get rid of all generated files"
44+
@echo "make release - Create and tag a new release"
45+
@echo "make upload - Upload the new release to repositories"
46+
47+
install:
48+
$(PYTHON) $(PYFLAGS) setup.py install --root $(DEST_DIR)
49+
50+
doc: $(DOC_SOURCES)
51+
$(PYTHON) $(PYFLAGS) setup.py build_sphinx -b html
52+
53+
source: $(DIST_TAR) $(DIST_ZIP)
54+
55+
egg: $(DIST_EGG)
56+
57+
zip: $(DIST_ZIP)
58+
59+
tar: $(DIST_TAR)
60+
61+
dist: $(DIST_EGG) $(DIST_RPM) $(DIST_DEB) $(DIST_TAR) $(DIST_ZIP)
62+
63+
develop: tags
64+
$(PYTHON) $(PYFLAGS) setup.py develop
65+
66+
test:
67+
$(PYTHON) $(PYFLAGS) setup.py test
68+
69+
clean:
70+
$(PYTHON) $(PYFLAGS) setup.py clean
71+
$(MAKE) -f $(CURDIR)/debian/rules clean
72+
rm -fr build/ dist/ $(NAME).egg-info/ tags
73+
find $(CURDIR) -name "*.pyc" -delete
74+
75+
tags: $(PY_SOURCES)
76+
ctags -R --exclude="build/*" --exclude="debian/*" --exclude="docs/*" --languages="Python"
77+
78+
$(DIST_TAR): $(PY_SOURCES)
79+
$(PYTHON) $(PYFLAGS) setup.py sdist --formats gztar
80+
81+
$(DIST_ZIP): $(PY_SOURCES)
82+
$(PYTHON) $(PYFLAGS) setup.py sdist --formats zip
83+
84+
$(DIST_EGG): $(PY_SOURCES)
85+
$(PYTHON) $(PYFLAGS) setup.py bdist_egg
86+
87+
release: $(PY_SOURCES) $(DOC_SOURCES)
88+
$(MAKE) clean
89+
# ensure there are no current uncommitted changes
90+
test -z "$(shell git status --porcelain)"
91+
# commit the changes and add a new tag
92+
git commit debian/changelog -m "Updated changelog for release $(VER)"
93+
git tag -s release-$(VER) -m "Release $(VER)"
94+
95+
upload: $(PY_SOURCES) $(DOC_SOURCES)
96+
# build a source archive and upload to PyPI
97+
$(PYTHON) $(PYFLAGS) setup.py sdist upload
98+
99+
.PHONY: all install develop test doc source egg zip tar dist clean tags release upload
100+

README.rst

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
.. -*- rst -*-
2+
3+
========
4+
picamera
5+
========
6+
7+
This package provides a pure Python interface to the `Raspberry Pi`_ `camera`_
8+
module.
9+
10+
.. warning::
11+
This package is still in heavy development and many things do not yet work.
12+
`Pull requests`_ gratefully received!
13+
14+
The project is written to be compatible with `Python`_ 2.7 from the 2.x series
15+
(it will not work with 2.6 or below), and Python 3.2 or above from the 3.x
16+
series. The same codebase supports both Python 2 and 3 with no conversions
17+
(e.g. ``2to3``) required.
18+
19+
The code is licensed under the `BSD license`_ as much of the code is a
20+
translation of the libmmal headers which Broadcom have licensed under this same
21+
license. I'm unsure of the legal obligations surrounding such header
22+
conversions so for the sake of simplicity I've kept the license the same.
23+
24+
Packages can be downloaded from the project `homepage`_. The `source code`_
25+
can be obtained from GitHub. The `documentation`_ can be read on ReadTheDocs.
26+
27+
Quick start
28+
===========
29+
30+
Start a preview for 10 seconds with the default settings::
31+
32+
import time
33+
import picamera
34+
35+
camera = picamera.PiCamera()
36+
try:
37+
camera.start_preview()
38+
time.sleep(10)
39+
camera.stop_preview()
40+
finally:
41+
camera.close()
42+
43+
Note that you should always ensure you call ``close()`` on the PiCamera object
44+
to clean up resources. The following example demonstrates that the context
45+
manager protocol can be used to achieve this::
46+
47+
import time
48+
import picamera
49+
50+
with picamera.PiCamera() as camera:
51+
camera.start_preview()
52+
for i in range(100):
53+
camera.brightness = i
54+
time.sleep(0.2)
55+
camera.stop_preview()
56+
57+
Development
58+
===========
59+
60+
For anybody wishing to hack on the project please understand that although it
61+
is technically written in pure Python, heavy use of ``ctypes`` is involved so
62+
the code really doesn't look much like Python - more a sort of horrid mish-mash
63+
of C and Python. The project currently consists of a class (PiCamera) which is
64+
a crude re-implementation of useful bits of the ``raspistill`` and ``raspivid``
65+
commands using the ``ctypes`` based ``libmmal`` header conversion.
66+
67+
Even if you don't feel up to hacking on the code, I'd love to hear suggestions
68+
from people of what you'd like the API to look like (even if the code itself
69+
isn't particularly pythonic, the interface should be)!
70+
71+
To do
72+
=====
73+
74+
Major things that still need work:
75+
76+
* Video recording
77+
78+
* Image encoding selection (PNG, BMP, GIF, etc.)
79+
80+
* Image thumbnail settings
81+
82+
* JPEG quality configuration
83+
84+
* EXIF tags
85+
86+
* Preview alpha configuration
87+
88+
* Preview display-rect configuration
89+
90+
* Documentation, examples, tests, etc. etc.
91+
92+
.. _Raspberry Pi: http://www.raspberrypi.org/
93+
.. _camera: http://www.raspberrypi.org/camera
94+
.. _homepage: https://pypi.python.org/pypi/picamera/
95+
.. _documentation: http://picamera.readthedocs.org/
96+
.. _source code: https://github.com/waveform80/picamera.git
97+
.. _Python: http://python.org/
98+
.. _BSD license: http://opensource.org/licenses/BSD-3-Clause
99+
.. _Pull requests: https://github.com/waveform80/picamera.git

0 commit comments

Comments
 (0)