Skip to content

Commit

Permalink
Merge branch 'release/2019.0910'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Sep 10, 2019
2 parents 74fcaeb + bf26bb2 commit e9faf24
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 153 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ venv/
.buildozer/
.pytest_cache/
.tox/
opencv-*
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ venv/
.tox/
.buildozer/
bin/
opencv-*
build/
dist/
*.egg-info/
23 changes: 14 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [2019.0910]

- Use new `xcamera` from PyPI
- Use `opencv-python` from PyPI, refs #23

## [2019.0909]

- Fix camera events not binded
Expand All @@ -22,7 +27,7 @@
- Publish documentation to readthedocs, refs #18
- Publish to PyPI, refs #19

## [20190303]
## [2019.0303]

- Add Python3.6 support, refs #5
- Fully migrated Android from PIL to Pillow, refs #13
Expand All @@ -31,12 +36,12 @@
- Migrate from zbarlight to pyzbar, refs #32
- Migrate to Python3.6 and opencv 4, refs #33

## [20190223]
## [2019.0223]

- Fix zbarlight dependency in setup.py, refs #28
- Migrate to zbarlight 2.1, refs #18

## [20190222]
## [2019.0222]

- Provide Makefile, refs #15
- Setup continuous integration testing, refs #6, #14
Expand All @@ -46,31 +51,31 @@
- Using non-root Docker container, refs #27
- Run UI tests from Travis, refs #26

## [20171220]
## [2017.1220]

- Full screen camera
- Kvlang refactoring
- File tree refactoring

## [20171117]
## [2017.1117]

- Integrated to kivy-garden

## [20171102]
## [2017.1102]

- Add camera start/stop

## [20171020]
## [2017.1020]

- Add Android autofocus, refs #2
- Fix Android rotation, refs #3
- Add animated demo gif

## [20171019]
## [2017.1019]

- Add ZBar Android support, refs #1
- Add PIL/Pillow Android workaround

## [20171016]
## [2017.1016]

- Initial release
98 changes: 13 additions & 85 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,106 +11,35 @@ SOURCES=src/ tests/ setup.py setup_meta.py
SPHINXBUILD=$(shell realpath venv/bin/sphinx-build)
DOCS_DIR=doc
SYSTEM_DEPENDENCIES= \
build-essential \
cmake \
curl \
libpython$(PYTHON_VERSION)-dev \
libsdl2-dev \
libzbar-dev \
tox \
virtualenv \
wget
virtualenv
OS=$(shell lsb_release -si)
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=6
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION)
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
# python3 has a "m" suffix for both include path and library
PYTHON_M=$(PYTHON_WITH_VERSION)
SITE_PACKAGES_DIR=$(VENV_NAME)/lib/$(PYTHON_WITH_VERSION)/site-packages
TMPDIR ?= /tmp
DOWNLOAD_DIR = $(TMPDIR)/downloads
OPENCV_VERSION=4.0.1
OPENCV_BASENAME=opencv-$(OPENCV_VERSION)
OPENCV_ARCHIVE=$(OPENCV_BASENAME).tar.gz
OPENCV_ARCHIVE_PATH=$(DOWNLOAD_DIR)/$(OPENCV_ARCHIVE)
OPENCV_EXTRACT_PATH=$(DOWNLOAD_DIR)/$(OPENCV_BASENAME)
OPENCV_BUILD_LIB_DIR=$(OPENCV_EXTRACT_PATH)/build/lib
OPENCV_BUILD=$(OPENCV_BUILD_LIB_DIR)/python$(PYTHON_MAJOR_VERSION)/cv2*.so
OPENCV_DEPLOY=$(SITE_PACKAGES_DIR)/cv2*.so
NPROC=`grep -c '^processor' /proc/cpuinfo`


ifeq ($(PYTHON_MAJOR_VERSION), 3)
PYTHON_M := $(PYTHON_M)m
endif


all: system_dependencies virtualenv opencv
all: system_dependencies virtualenv

venv:
test -d venv || virtualenv -p python$(PYTHON_MAJOR_VERSION) venv
test -d venv || virtualenv -p $(PYTHON_WITH_VERSION) venv

virtualenv: venv
$(PIP) install Cython==0.28.6
$(PIP) install -r requirements/requirements.txt
$(GARDEN) install xcamera

virtualenv/test: virtualenv
$(PIP) install -r requirements/requirements-test.txt

system_dependencies:
ifeq ($(OS), Ubuntu)
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
endif

$(OPENCV_ARCHIVE_PATH):
mkdir -p $(DOWNLOAD_DIR)
curl --location https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz \
--progress-bar --output $(OPENCV_ARCHIVE_PATH)

# The build also relies on virtualenv, because we make references to it.
# Plus numpy is required to build OpenCV Python module.
$(OPENCV_BUILD): $(OPENCV_ARCHIVE_PATH) virtualenv
tar -xf $(OPENCV_ARCHIVE_PATH) --directory $(DOWNLOAD_DIR)
cmake \
-D CMAKE_SHARED_LINKER_FLAGS=-l$(PYTHON_M) \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_STATIC_LIBS=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_OPENCV_APPS=OFF \
-D BUILD_OPENCV_JAVA=OFF \
-D BUILD_OPENCV_JAVA_BINDINGS_GENERATOR=OFF \
-D BUILD_OPENCV_NONFREE=OFF \
-D BUILD_OPENCV_PYTHON2=OFF \
-D BUILD_OPENCV_PYTHON3=ON \
-D BUILD_OPENCV_STITCHING=OFF \
-D BUILD_OPENCV_SUPERRES=OFF \
-D BUILD_OPENCV_TS=OFF \
-D BUILD_PACKAGE=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_WITH_DEBUG_INFO=OFF \
-D OPENCV_SKIP_PYTHON_LOADER=ON \
-D OPENCV_PYTHON$(PYTHON_MAJOR_VERSION)_INSTALL_PATH=$(SITE_PACKAGES_DIR) \
-D PYTHON$(PYTHON_MAJOR_VERSION)_PACKAGES_PATH=$(SITE_PACKAGES_DIR) \
-D PYTHON$(PYTHON_MAJOR_VERSION)_EXECUTABLE=$(PYTHON) \
-D PYTHON$(PYTHON_MAJOR_VERSION)_INCLUDE_PATH=/usr/include/$(PYTHON_M)/ \
-D PYTHON$(PYTHON_MAJOR_VERSION)_LIBRARIES=/usr/lib/x86_64-linux-gnu/lib$(PYTHON_M).so \
-D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python$(PYTHON_MAJOR_VERSION) \
-D WITH_1394=OFF \
-D WITH_CUDA=OFF \
-D WITH_CUFFT=OFF \
-D WITH_GIGEAPI=OFF \
-D WITH_GTK=OFF \
-D WITH_JASPER=OFF \
-D WITH_OPENEXR=OFF \
-D WITH_PVAPI=OFF \
-B$(OPENCV_EXTRACT_PATH)/build -H$(OPENCV_EXTRACT_PATH)
cmake --build $(OPENCV_EXTRACT_PATH)/build -- -j$(NPROC)

$(OPENCV_DEPLOY): $(OPENCV_BUILD) virtualenv
cp $(OPENCV_BUILD) $(SITE_PACKAGES_DIR)

opencv: $(OPENCV_DEPLOY)

run/linux: virtualenv
$(PYTHON) src/main.py

Expand All @@ -119,20 +48,19 @@ run: run/linux
test:
$(TOX)

uitest: virtualenv
$(PIP) install -r requirements/test_requirements.txt
uitest: virtualenv/test
PYTHONPATH=src $(PYTHON) -m unittest discover --top-level-directory=. --start-directory=tests/ui/

isort-check: virtualenv
lint/isort-check: virtualenv/test
$(ISORT) --check-only --recursive --diff $(SOURCES)

isort-fix: virtualenv
lint/isort-fix: virtualenv/test
$(ISORT) --recursive $(SOURCES)

flake8: virtualenv
lint/flake8: virtualenv/test
$(FLAKE8) $(SOURCES)

lint: isort-check flake8
lint: lint/isort-check lint/flake8

docs/clean:
rm -rf $(DOCS_DIR)/build/
Expand All @@ -156,5 +84,5 @@ clean: release/clean docs/clean
find src/ -type d -name "__pycache__" -exec rm -r {} +
find src/ -type d -name "*.egg-info" -exec rm -r {} +

clean/full: clean
rm -rf $(VENV_NAME) .tox/ $(DOWNLOAD_DIR)
clean/all: clean
rm -rf $(VENV_NAME) .tox/
26 changes: 0 additions & 26 deletions OpenCV.md

This file was deleted.

19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ Install system requirements (Ubuntu 18.04):
make system_dependencies
```

Install garden requirements:
```sh
garden install --upgrade xcamera
```

Install zbarcam:
```sh
pip install --upgrade zbarcam
Expand All @@ -49,11 +44,6 @@ Then import it in your Python code via:
from kivy_garden.zbarcam import ZBarCam
```

[OpenCV](OpenCV.md):
```sh
make opencv
```

### Android
Build for Android via buildozer, see [buildozer.spec](buildozer.spec).

Expand All @@ -70,16 +60,7 @@ make uitest

## Troubleshooting

### Install `Unable to import package 'kivy.garden.xcamera.XCamera'`
You're missing the `xcamera` dependency. Install it as described in the install instructions.

### Android `ValueError: Empty module name`
More likely an import issue in your `.kv` file.
Try to `from zbarcam import ZBarCam` in your `main.py` to see the exact error.
It's common to forget `Pillow` in `buildozer.spec` `requirements` section.

### OpenCV related
See [OpenCV.md](OpenCV.md).

## Credits
I borrowed a lot of code from [tito/android-zbar-qrcode](https://github.com/tito/android-zbar-qrcode).
4 changes: 2 additions & 2 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ requirements =
libzbar,
Pillow==5.2.0,
python3,
pyzbar==0.1.8
pyzbar==0.1.8,
xcamera
# (str) Custom source folders for requirements
Expand All @@ -52,7 +53,6 @@ requirements =
# (list) Garden requirements
#garden_requirements =
garden_requirements = xcamera
# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Kivy==1.11.1
Kivy-Garden==0.1.4
numpy==1.16.1
opencv-python==4.1.1.26
Pillow==5.2.0
pyzbar==0.1.8
xcamera
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def read(fname):
'install_requires': [
'kivy',
'numpy',
'opencv-python>=4',
'pillow',
'pyzbar',
'xcamera',
],
}

Expand Down
2 changes: 1 addition & 1 deletion setup_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Creates a distribution alias that just installs pyetheroll.
Creates a distribution alias that just installs kivy_garden.zbarcam.
"""
from setuptools import setup

Expand Down
4 changes: 2 additions & 2 deletions src/kivy_garden/zbarcam/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__version__ = '2019.0909'
__version__ = '2019.0910'
# The `__version_code__` is used for the F-Droid auto update and should match
# the `versionCode` from the `build.gradle` file located in:
# `.buildozer/android/platform/build/dists/zbarcamdemo/`
# The auto update method used is the `HTTP`, see:
# https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
__version_code__ = 721202809
__version_code__ = 721202810
4 changes: 2 additions & 2 deletions src/kivy_garden/zbarcam/zbarcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import PIL
from kivy.clock import Clock, mainthread
from kivy.garden.xcamera import XCamera
from kivy.lang import Builder
from kivy.properties import ListProperty
from kivy.uix.anchorlayout import AnchorLayout
from kivy_garden.xcamera import XCamera
from pyzbar import pyzbar

from .utils import check_request_camera_permission, fix_android_image
Expand All @@ -16,7 +16,7 @@

class CustomXCamera(XCamera):
"""
Inherits from `kivy.garden.xcamera.XCamera`.
Inherits from `kivy_garden.xcamera.XCamera`.
Overrides `_on_index()` to make sure the `kivy.core.camera.Camera` object
is only created if permission are granted on Android.
On other system, it's a noop calling the parent `_on_index()`.
Expand Down
1 change: 0 additions & 1 deletion tests/test_zbarcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import mock
from kivy.base import EventLoop
from kivy.core.image import Image

from kivy_garden.zbarcam import ZBarCam

FIXTURE_DIR = os.path.join(
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/test_zbarcam_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import mock
from kivy.clock import Clock

from kivy_garden.zbarcam.zbarcam import ZBarCam

from main import DemoApp


Expand Down
Loading

0 comments on commit e9faf24

Please sign in to comment.