Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0e8fafe
PythonK4A: Adding initial directory structure, k4atypes.py which defi…
JonathanESantos Dec 9, 2020
b77771a
PythonK4A: Updating __init__.py to point to the "api" directory (rena…
JonathanESantos Dec 9, 2020
f1e90ba
Python K4A: Rearranging directory tree so that it matches the expecta…
JonathanESantos Dec 9, 2020
b2443dd
Python k4a api: Put ctypes structs inside k4atypes.py.
JonathanESantos Dec 10, 2020
1e8677c
Python k4a api: Adding to setup.py so that "pip install -e .[test]" w…
JonathanESantos Dec 10, 2020
071ab03
Python k4a api: An enum name with AUTO was mistakenly replaced with _…
JonathanESantos Dec 10, 2020
de120dd
Python k4a api: Adding __repr__() functions to structs in order to pr…
JonathanESantos Dec 10, 2020
ad64501
Python k4a api: Adding a check that the required dlls are in the _lib…
JonathanESantos Dec 10, 2020
8e5e3a1
Python k4a api: Adding the rest of the bindings for the functions tha…
JonathanESantos Dec 10, 2020
5d9db7b
Python k4a: Adding tests to call the functions in the dll.
JonathanESantos Dec 11, 2020
744ccb9
Python k4a: Adding missing enum in color resolution, and adding tests…
JonathanESantos Dec 12, 2020
f85d8d2
Python k4a: Changing @unittest.skip to @unittest.expectedfail for tho…
JonathanESantos Dec 12, 2020
c1a85d9
Python k4a: Updating docs. Removing platform tag in building the k4a …
JonathanESantos Dec 12, 2020
3c25d68
Python API: Renaming enums and structs to Python naming convention.
JonathanESantos Dec 16, 2020
88be9e5
Python API: Moving all internal files and symbols into the _bindings/…
JonathanESantos Dec 16, 2020
da31b2a
Python API: Moving handle structs from _k4a.py back to _k4atypes.py s…
JonathanESantos Dec 16, 2020
a080d08
Renaming modules inside _bindings subpackage to not include underscor…
JonathanESantos Dec 16, 2020
ee41c9a
Python api: Adding Device class which corresponds to a device with a …
JonathanESantos Dec 17, 2020
fddad4e
Python API: Adding capture and image classes to encapsulate capture a…
JonathanESantos Dec 22, 2020
c44293c
Python API: Bug in Image class was missing a height_pixels in one lin…
JonathanESantos Dec 22, 2020
76b3e83
Python API: Adding Calibration and Transformation wrapper classes.
JonathanESantos Dec 23, 2020
cd14e98
Python API: Renaming a test file.
JonathanESantos Dec 23, 2020
d023902
Python API: Adding more tests to test the Device, Capture, Image, and…
JonathanESantos Dec 24, 2020
359525d
Python API: Fixing transformation functions and their tests.
JonathanESantos Dec 28, 2020
ef8887b
Python API: Adding example code that makes use of the Python API.
JonathanESantos Dec 29, 2020
456c0b6
Python API: Adding docstrings *.py files and a Doxygen settings file …
JonathanESantos Dec 31, 2020
cd9a0da
Python API: Adding a main page to the documentation, and fixing a bug…
JonathanESantos Dec 31, 2020
f48bf0c
Python API: Adding lines in build_wheel.ps1 to generate the documenta…
JonathanESantos Dec 31, 2020
6bf9c0c
Making minor changes to get this k4a package to work in both Windows …
JonathanESantos Jan 8, 2021
0e53962
Forgot to commit the minor changes to get this k4a package to work in…
JonathanESantos Jan 8, 2021
1b6b6aa
Python API: Specifying specific library names that the python code wi…
JonathanESantos Jan 8, 2021
49a52fd
Python API: Modifying the build_wheel.csh script to look for libdepth…
JonathanESantos Jan 8, 2021
d560c73
Python API: Updating building.md for clarity.
JonathanESantos Jan 15, 2021
c567635
Python API: Fixing bug in tests that causes failure in some of the te…
JonathanESantos Jan 22, 2021
038b9f6
Removing forced-loading of depthengine library. Just load k4a.dll and…
JonathanESantos Mar 23, 2021
ccbc0bf
In the wheel build scripts, adding test to check if doxygen is instal…
JonathanESantos Mar 23, 2021
f1902be
Fixing markdown documents.
JonathanESantos Mar 23, 2021
7b69e00
Adding blurb about installing pip in Linux.
JonathanESantos Mar 23, 2021
55d6ba7
Changing ctypes.c_ulonglong to ctypes.c_size_t where it matches the f…
JonathanESantos Mar 23, 2021
a742479
Changing c_ulonglong to c_size_t in the tests to match the change in …
JonathanESantos Mar 23, 2021
bd1cad9
Fixing build script in Linux to look for depthengine.so* inside a sub…
JonathanESantos Mar 23, 2021
d65d0b7
Fixing documents that say the Linux depthengine.so.2.0 must be in a s…
JonathanESantos Mar 24, 2021
57802b3
The build script for Linux needs to check for depthengine.so* in the …
JonathanESantos Mar 24, 2021
f71cbea
Making slight changes to the building.md documentation for more clarity.
JonathanESantos Mar 24, 2021
cf713d6
Fixing a minor typo in the comments of image_transformations.py, and …
JonathanESantos Mar 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removing forced-loading of depthengine library. Just load k4a.dll and…
… let it load the depth engine.

Fixing markdown formatting.
  • Loading branch information
JonathanESantos committed Mar 23, 2021
commit 038b9f6e19da856f213b210b0293cc2d88f5ccf5
8 changes: 4 additions & 4 deletions src/python/k4a/build_wheel.csh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
# to manually copy them into the _libs/ folder.
if [ ! -f "$DIR/src/k4a/_libs/libk4a.so" ] && [ ! -h "$DIR/src/k4a/_libs/libk4a.so" ]; then
echo "File not found: $DIR/src/k4a/_libs/libk4a.so"
echo "Please manually copy the library into that folder."
echo "Please manually copy the k4a library into that folder."
return 1
fi

if [ ! -f "$DIR/src/k4a/_libs/libdepthengine.so" ] && [ ! -h "$DIR/src/k4a/_libs/libdepthengine.so" ]; then
echo "File not found: $DIR/src/k4a/_libs/libdepthengine.so"
echo "Please manually copy the library into that folder."
if [ ! -f "$DIR/src/k4a/_libs/libdepthengine*" ] && [ ! -h "$DIR/src/k4a/_libs/libdepthengine*" ]; then
echo "File not found: $DIR/src/k4a/_libs/libdepthengine*"
echo "Please manually copy the depth engine library into that folder."
return 1
fi

Expand Down
8 changes: 4 additions & 4 deletions src/python/k4a/build_wheel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# to manually copy them into the _libs/ folder.
If (-not (Test-Path -Path "$PSScriptRoot\src\k4a\_libs\k4a.dll")) {
Write-Host "File not found: $PSScriptRoot\src\k4a\_libs\k4a.dll"
Write-Host "Please manually copy the dll into that folder."
Write-Host "Please manually copy the k4a library into that folder."
exit 1
}

If (-not(Test-Path -Path "$PSScriptRoot\src\k4a\_libs\depthengine.dll")) {
Write-Host "File not found: $PSScriptRoot\src\k4a\_libs\depthengine.dll"
Write-Host "Please manually copy the dll into that folder."
If (-not(Test-Path -Path "$PSScriptRoot\src\k4a\_libs\depthengine*.dll")) {
Write-Host "File not found: $PSScriptRoot\src\k4a\_libs\depthengine*.dll"
Write-Host "Please manually copy the depth engine library into that folder."
exit 1
}

Expand Down
57 changes: 22 additions & 35 deletions src/python/k4a/docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following dependencies are for both Windows and Linux:

* [k4a library](../../../../docs/building.md)
The k4a library can be built from the repository or the SDK can be downloaded
for the binary. The Windows library is k4a.dll, and the Linux library is k4a.so.
for the binary. The Windows library is k4a.dll, and the Linux library is libk4a.so.
The k4a binary needs to be copied to the host system and added
to the path src/python/k4a/src/k4a/_libs in this repository before building.

Expand All @@ -47,62 +47,49 @@ The following tools are optional:

### Building using a powershell script (Windows)

1. Copy the k4a and DE binaries into the folder src/python/k4a/src/k4a/_libs.
The file names MUST be k4a.dll and depthengine.dll.
1. Copy the k4a and DE binaries into the folder src/python/k4a/src/k4a/_libs.
The file name for the k4a library MUST be k4a.dll.

Note: To create a cross-platform wheel, the .dll for Windows and the .so for Linux need to
copied into the folder.
Note: If the dlls have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlink as well as run build_wheel.ps1.
Note: If the .so have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlink as well as run build_wheel.csh.
>**Note:** To create a cross-platform wheel, the .dll for Windows and the .so for Linux need to
>copied into the folder. Python will look for "k4a.dll" in Windows and "libk4a.so" in Linux.

2. In a powershell terminal, run the script src/python/k4a/build_wheel.ps1.
This will create the .whl file in a build/ folder.

### Building using a bash script (Linux)

1. Copy the k4a and DE binaries into the folder src/python/k4a/src/k4a/_libs.
The file names MUST be libk4a.so and libdepthengine.so.
The file name for the k4a library MUST be libk4a.so.

Note: To create a cross-platform wheel, the .dll for Windows and the .so for Linux need to
copied into the folder.
Note: If the dlls have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlink as well as run build_wheel.ps1.
Note: If the .so have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlink as well as run build_wheel.csh.
>**Note:** To create a cross-platform wheel, the .dll for Windows and the .so for Linux need to
>copied into the folder. Python will look for "k4a.dll" in Windows and "libk4a.so" in Linux.

2. In a terminal, source the script src/python/k4a/build_wheel.csh.
This will create the .whl file in a build/ folder.

cd <repo_root>/src/python/k4a
source build_wheel.csh
`cd <repo_root>/src/python/k4a`
`source build_wheel.csh`

### Building using a command line terminal (cross platform)

1. Copy the k4a and DE binaries into the folder src/python/k4a/src/k4a/_libs.
The file names MUST be k4a.dll and depthengine.dll in Windows, and
the file names MUST be libk4a.so and libdepthengine.so in Linux.
The file names for the k4a library MUST be k4a.dll (for Windows) and libk4a.so (for Linux).

Note: To create a cross-platform wheel, the .dll for Windows and the .so for Linux need to
copied into the folder.
Note: If the dlls have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlink as well as run build_wheel.ps1.
Note: If the .so have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlink as well as run build_wheel.csh.
>**Note:** To create a cross-platform wheel, the .dll for Windows and the .so for Linux need to
>copied into the folder. Python will look for "k4a.dll" in Windows and "libk4a.so" in Linux.

2. In a command line terminal, create a Python virtual environment and activate it (do not include brackets):
cd <repo_root>/src/python/k4a
python -m venv <env_name>
./<env_name>/Scripts/activate
`cd <repo_root>/src/python/k4a`
`python -m venv <env_name>`
`./<env_name>/Scripts/activate`

3. Build the .whl file and place it in a build/ folder.
pip install wheel
pip wheel . -w build
`pip install wheel`
`pip wheel . -w build`

4. Deactivate the virtual environment and delete it.
./<env_name>/Scripts/deactivate.bat
Delete the directory <env_name>
4. Deactivate the virtual environment and delete it.
`./<env_name>/Scripts/deactivate.bat`
Delete the directory `<env_name>`.

### Building the HTML Documentation

Expand All @@ -118,6 +105,6 @@ The wheel file can be distributed and installed as follows.

1. In a command line terminal, install the k4a python library via pip.
Replace <k4a*.whl> with the name of the wheel file.
pip install <k4a*.whl>
`pip install <k4a*.whl>`

Once installed, the user can "import k4a" in their python code.
16 changes: 10 additions & 6 deletions src/python/k4a/docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ A simple program to showcase the basic functions in the Azure Kinect API.

Additional Prerequisites: None

To run, open a command terminal and type: python the_basics.py
To run, open a command terminal and type:
`python the_basics.py`

The expected output is a print out on the terminal of the device, capture, and image properties.

### image_transformations.py

A simple program to showcase the image transformation functions in the Azure Kinect API.

Additional Prerequisites:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline using \
currently all on one line

Matplotlib installed via pip: pip install matplotlib
Numpy installed via pip: pip install numpy==1.18.5
- Matplotlib installed via pip: pip install matplotlib
- Numpy installed via pip: pip install numpy==1.18.5

Note that numpy version 1.19.5 currently has a bug for Windows, so do not use it as of 2020/12/28.

To run, open a command terminal and type: python image_transformations.py
To run, open a command terminal and type:
`python image_transformations.py`

The program transforms a color image into the depth camera space and displays the images in a figure.
Close the figure to proceed.
Expand All @@ -57,9 +60,10 @@ Close the figure to proceed and the program exits.
A simple program to continuously capture images from an Azure Kinect device and display the images.

Additional Prerequisites:
Matplotlib installed via pip: pip install matplotlib
- Matplotlib installed via pip: pip install matplotlib

To run, open a command terminal and type: python simple_viewer.py
To run, open a command terminal and type:
`python simple_viewer.py`

The program creates a figure and continuously displays the captured images on the figure.
Close the figure to end the program.
42 changes: 17 additions & 25 deletions src/python/k4a/docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,33 @@ The following are required in order to run the Python K4A tests.
### Setting up the test environment

1. Copy the k4a and DE dynamic libraries (.dll or .so) into the folder src/python/k4a/src/k4a/_libs.
The file names MUST be k4a.dll and depthengine.dll in Windows, and
the file names MUST be libk4a.so and libdepthengine.so in Linux.

Note: If the libraries have different names, create a symlink with relative redirection. This may
require elevated permissions to create the symlinks.
The file names for the k4a library MUST be k4a.dll (for Windows) and libk4a.so (for Linux).

2. In a command line terminal, create a Python virtual environment and activate it (do not include brackets):
cd <repo_root>/src/python/k4a
python -m venv <env_name>
`cd <repo_root>/src/python/k4a`
`python -m venv <env_name>`

Windows:
.\<env_name>\Scripts\activate
Windows:
`.\<env_name>\Scripts\activate`

Ubuntu:
source ./<env_name>/bin/activate
Ubuntu:
`source ./<env_name>/bin/activate`

3. Install the k4a package in development mode. This is required in order to
automatically install required Python packages for running the tests, as
well as to install the code with the k4a package as the root of the
subpackages and modules. In the command below, make sure to include
".[test]" with dot and square brackets.
pip install -e .[test]
".[test]" with dot and square brackets.
`pip install -e .[test]`

### Running unit tests on the command line

Unit tests execute small pieces of code that run very fast (less than a second).
These tests do not require any hardware to be attached.
These tests should be run on every pull request.

To run the unit tests:

python -m pytest tests -k unit
To run the unit tests:
`python -m pytest tests -k _unit_`

To capture the results, use an additional --junit-xml=./test_results.xml option.

Expand All @@ -64,13 +59,11 @@ There are 2 types of functional tests:
1. functional_fast - fast functional tests that should be run on every pull request.
2. functional - more comprehensive functional tests but these may take a long time.

To run the functional_fast tests:

python -m pytest tests -k functional_fast
To run the functional_fast tests:
`python -m pytest tests -k functional_fast`

To run all functional tests:

python -m pytest tests -k functional
To run all functional tests:
`python -m pytest tests -k functional`

To capture the results, use an additional --junit-xml=./test_results.xml option.

Expand All @@ -80,9 +73,8 @@ Performance tests attempt to verify the performance of the device under stress,
such as maintaining frame rates, etc. These tests require an attached device.
These tests should be run on every pull request.

To run the performance tests:

python -m pytest tests -k perf
To run the performance tests:
`python -m pytest tests -k perf`

To capture the results, use an additional --junit-xml=./test_results.xml option.

Expand Down
2 changes: 0 additions & 2 deletions src/python/k4a/src/k4a/_bindings/k4a.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
_lib_dir = _os_path.join(_os_path.dirname(_os_path.dirname(__file__)), '_libs')

if _IS_WINDOWS:
_depthengine_lib = _ctypes.CDLL(_os_path.join(_lib_dir, 'depthengine.dll'))
_k4a_lib = _ctypes.CDLL(_os_path.join(_lib_dir, 'k4a.dll'))
else:
_depthengine_lib = _ctypes.CDLL(_os_path.join(_lib_dir, 'libdepthengine.so'))
_k4a_lib = _ctypes.CDLL(_os_path.join(_lib_dir, 'libk4a.so'))

except Exception as ee:
Expand Down
14 changes: 8 additions & 6 deletions src/python/k4a/src/k4a/_libs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Required libraries should be placed here before building wheel package.
## Required libraries should be placed here before building wheel package.

# k4a
# DepthEngine
- k4a
- DepthEngine

# The actual names may differ depending on version and platform.
# On Windows, the libraries should be named k4a.dll and depthengine.dll.
# On Linux, the libraries should be named libk4a.so and libdepthengine.so.
The actual names may differ depending on version and platform.

> On Windows, the libraries should be named k4a.dll and depthengine*.dll.

> On Linux, the libraries should be named libk4a.so and libdepthengine.*