Skip to content

Commit 6d1355a

Browse files
lpasselinshagren
andauthored
Version 1.0.1 (#74)
* Run test with different python versions (#65) * Add matrix to workflow * Change python versions list * Change python versions list * Add k4a versions to matrix * Typofix * Drop k4a from matrix * Add dataclasses requirement for python <3.7 * Fix python 3.6 test behavior * Fix python 3.6 test behavior * Restore fail-fast option * fix conversion seconds to ns * fix conversion seconds to ns * fix timestamp ns to us Co-authored-by: Louis-Philippe Asselin <[email protected]> * fix install using pip --editable --user (#67) * Codecov support (#64) * Codecov support * Add badge * Order badges * fix capture.transformed_depth_point_cloud (#73) * version 1.0.1 Co-authored-by: Ilya Gruzinov <[email protected]>
1 parent f3d1814 commit 6d1355a

File tree

9 files changed

+46
-20
lines changed

9 files changed

+46
-20
lines changed

.github/workflows/ci.yml

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: CI
22

3+
34
on:
45
pull_request:
56
push:
@@ -22,10 +23,10 @@ jobs:
2223
- name: Cache PyPI
2324
uses: actions/cache@v2
2425
with:
25-
key: pip-cache-${{ hashFiles('requirements-dev.txt') }}
26+
key: pip-cache-lint-${{ hashFiles('requirements-dev.txt') }}
2627
path: ~/.cache/pip
2728
restore-keys: |
28-
pip-cache-
29+
pip-cache-lint
2930
- name: Install dependencies
3031
uses: py-actions/py-dependency-install@v2
3132
with:
@@ -34,6 +35,10 @@ jobs:
3435
run: |
3536
make lint
3637
test:
38+
strategy:
39+
matrix:
40+
python-version: ['3.6', '3.7', '3.8']
41+
fail-fast: true
3742
name: Test
3843
runs-on: ubuntu-18.04
3944
steps:
@@ -45,17 +50,17 @@ jobs:
4550
env DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y sudo -E apt install -q -y libk4a1.4-dev
4651
- name: Checkout
4752
uses: actions/checkout@v2
48-
- name: Setup Python 3.7
53+
- name: Setup Python ${{ matrix.python-version }}
4954
uses: actions/setup-python@v2
5055
with:
51-
python-version: 3.7
56+
python-version: ${{ matrix.python-version }}
5257
- name: Cache PyPI
5358
uses: actions/cache@v2
5459
with:
55-
key: pip-cache-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('setup.py') }}
60+
key: pip-cache-test-${{ matrix.python-version }}-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('setup.py') }}
5661
path: ~/.cache/pip
5762
restore-keys: |
58-
pip-cache-
63+
pip-cache-test-${{ matrix.python-version }}
5964
- name: Install dependencies
6065
uses: py-actions/py-dependency-install@v2
6166
with:
@@ -66,3 +71,7 @@ jobs:
6671
- name: Run tests
6772
run: |
6873
make test-no-hardware
74+
- name: Coverage
75+
uses: codecov/codecov-action@v1
76+
with:
77+
file: ./coverage.xml # optional

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ lint:
3030
mypy $(SOURCES)
3131

3232
test:
33-
pytest --cov=pyk4a --verbose $(TESTS)
33+
pytest $(TESTS)
3434

3535
test-hardware:
36-
pytest --cov=pyk4a -m "device" --verbose $(TESTS)
36+
pytest -m "device" $(TESTS)
3737

3838
test-no-hardware:
39-
pytest --cov=pyk4a -m "not device" --verbose $(TESTS)
39+
pytest -m "not device" $(TESTS)

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# pyk4a
2+
23
![CI](https://github.com/etiennedub/pyk4a/workflows/CI/badge.svg)
4+
[![codecov](https://codecov.io/gh/etiennedub/pyk4a/branch/master/graph/badge.svg)](https://codecov.io/gh/etiennedub/pyk4a)
5+
6+
![pyk4a](https://github.com/etiennedub/pyk4a/raw/master/figs/pyk4a_logo.png)
37

4-
![pyk4a](https://github.com/etiennedub/pyk4a/raw/master/figs/pyk4a_logo.png)
58

69
This library is a simple and pythonic wrapper in Python 3 for the Azure-Kinect-Sensor-SDK.
710

pyk4a/capture.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ def transformed_depth(self) -> Optional[np.ndarray]:
5353
@property
5454
def depth_point_cloud(self) -> Optional[np.ndarray]:
5555
if self._depth_point_cloud is None and self.depth is not None:
56-
self._depth_point_cloud = depth_image_to_point_cloud(self._depth, self._calibration, self.thread_safe)
56+
self._depth_point_cloud = depth_image_to_point_cloud(
57+
self._depth, self._calibration, self.thread_safe, calibration_type_depth=True,
58+
)
5759
return self._depth_point_cloud
5860

5961
@property
6062
def transformed_depth_point_cloud(self) -> Optional[np.ndarray]:
6163
if self._transformed_depth_point_cloud is None and self.transformed_depth is not None:
62-
self._depth_point_cloud = depth_image_to_point_cloud(
63-
self.transformed_depth, self._calibration, self.thread_safe
64+
self._transformed_depth_point_cloud = depth_image_to_point_cloud(
65+
self.transformed_depth, self._calibration, self.thread_safe, calibration_type_depth=False,
6466
)
6567
return self._transformed_depth_point_cloud
6668

pyk4a/transformation.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ def depth_image_to_color_camera(depth: np.ndarray, calibration: Calibration, thr
1717
)
1818

1919

20-
def depth_image_to_point_cloud(depth: np.ndarray, calibration: Calibration, thread_safe: bool) -> Optional[np.ndarray]:
20+
def depth_image_to_point_cloud(
21+
depth: np.ndarray, calibration: Calibration, thread_safe: bool, calibration_type_depth=True
22+
) -> Optional[np.ndarray]:
2123
"""
2224
Transform depth color_image to point cloud
2325
Return empty result if transformation failed
2426
"""
2527
return k4a_module.transformation_depth_image_to_point_cloud(
26-
calibration.transformation_handle, thread_safe, depth, True
28+
calibration.transformation_handle, thread_safe, depth, calibration_type_depth,
2729
)
2830

2931

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ line-length = 120
77
[tool.pytest.ini_options]
88
markers = [
99
"device: Tests require connected real device"
10-
]
10+
]
11+
addopts = "--cov=pyk4a --cov-report=xml --verbose"

requirements-dev.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ flake8-isort==4.0.0
55
mypy==0.782
66
mypy-extensions==0.4.3
77
pytest==6.0.1
8-
pytest-cov==2.10.1
8+
pytest-cov==2.10.1
9+
dataclasses==0.6; python_version<"3.7"

setup.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
if sys.version_info[0] == 2:
55
sys.exit("Python 2 is not supported.")
66

7+
# Enables --editable install with --user
8+
# https://github.com/pypa/pip/issues/7953
9+
import site
10+
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
11+
712
# Bypass import numpy before running install_requires
813
# https://stackoverflow.com/questions/54117786/add-numpy-get-include-argument-to-setuptools-without-preinstalled-numpy
914
class get_numpy_include:
@@ -18,15 +23,15 @@ def __str__(self):
1823
libraries=['k4a', 'k4arecord'])
1924

2025
setup(name='pyk4a',
21-
version='1.0',
26+
version='1.0.1',
2227
description='Python wrapper over Azure Kinect SDK',
2328
license='GPL-3.0',
2429
author='Etienne Dubeau',
2530
install_requires=['numpy'],
2631
python_requires='>=3.4',
2732
author_email='[email protected]',
2833
url='https://github.com/etiennedub/pyk4a/',
29-
download_url='https://github.com/etiennedub/pyk4a/archive/0.2.tar.gz',
34+
download_url='https://github.com/etiennedub/pyk4a/archive/1.0.1.tar.gz',
3035
packages=['pyk4a'],
3136
package_data={'pyk4a': ["py.typed"]},
3237
ext_modules=[module],

tests/plugins/device.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ def device_get_imu_sample(
232232
assert self._opened is True
233233
if not self._cameras_started:
234234
return Result.Failed.value, None
235-
return Result.Success.value, (36.6, (0.1, 9.8, 0.005), time.time_ns(), (0.1, 0.2, 0.3), time.time_ns())
235+
return (
236+
Result.Success.value,
237+
(36.6, (0.1, 9.8, 0.005), int(time.time() * 1e6), (0.1, 0.2, 0.3), int(time.time() * 1e6)),
238+
)
236239

237240
def device_get_calibration(self, depth_mode: int, color_resolution: int) -> Tuple[int, Optional[object]]:
238241
assert self._opened is True

0 commit comments

Comments
 (0)