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
Python k4a api: Put ctypes structs inside k4atypes.py.
Arrange import methods so that:
1. "import k4a" will expose all visible symbols in the module k4atypes.py.
2. "from k4a import *" will work the same way as "import k4a".

To see all symbols in k4atypes.py, use "import k4a.k4atypes".
This is considered to be a development or debug way of importing symbols.
Users are encouraged to use "import k4a".
  • Loading branch information
JonathanESantos committed Dec 10, 2020
commit b2443ddee7d4e07f276e74e6b9d0757d54b0952a
8 changes: 7 additions & 1 deletion src/python/k4a/src/k4a/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from .k4atypes import *
from ._bindings import *

# We want "import k4a" to import all symbols in k4atypes.py under k4a.<x>.
from .k4atypes import *

del _bindings
del k4atypes
17 changes: 16 additions & 1 deletion src/python/k4a/src/k4a/_bindings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import os.path
import sys
import ctypes


# Load the k4a.dll.
lib_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), '_libs')
try:
_k4a_dll = ctypes.CDLL(os.path.join(lib_dir, 'k4a.dll'))
except Exception as e:
try:
_k4a_dll = ctypes.CDLL(os.path.join(lib_dir, 'k4a.so'))
except Exception as ee:
print("Failed to load library", e, ee)
sys.exit(1)


# Define symbols that will be exported with "from .bindings import *".
__all__ = [
]
90 changes: 90 additions & 0 deletions src/python/k4a/src/k4a/_bindings/_k4a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
'''k4atypes.py

Defines Python _ctypes equivalent functions to those defined in k4a.h.

Credit given to hexops's github contribution for the
_ctypes.Structure definitions and _ctypes function bindings.
https://github.com/hexops/Azure-Kinect-Python
'''

import ctypes as _ctypes

# Either k4a library is installed, or user is running from the repo
# Either way, the expectation is that we can import the from k4a.k4atypes.
try:
from k4a.k4atypes import *
except Exception as e:
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from k4a.k4atypes import *


# Map _ctypes symbols to functions in the k4a.dll.
# The dll should have been loaded in __init__.py which is run when this subpackage is imported.


#K4A_EXPORT k4a_result_t k4a_device_open(uint32_t index, k4a_device_t *device_handle);
k4a_device_open = _k4a_dll.k4a_device_open
k4a_device_open.restype=k4a_result_t
k4a_device_open.argtypes=(_ctypes.c_uint32, _ctypes.POINTER(k4a_device_t))


#K4A_EXPORT k4a_result_t k4a_device_start_cameras(k4a_device_t device_handle, const k4a_device_configuration_t *config);
k4a_device_start_cameras = _k4a_dll.k4a_device_start_cameras
k4a_device_start_cameras.restype=_ctypes.c_int
k4a_device_start_cameras.argtypes=(k4a_device_t, _ctypes.POINTER(k4a_device_configuration_t))


"""
K4A_EXPORT k4a_result_t k4a_device_get_calibration(k4a_device_t device_handle,
const k4a_depth_mode_t depth_mode,
const k4a_color_resolution_t color_resolution,
k4a_calibration_t *calibration);
"""
k4a_device_get_calibration = _k4a_dll.k4a_device_get_calibration
k4a_device_get_calibration.restype=_ctypes.c_int
k4a_device_get_calibration.argtypes=(k4a_device_t, _ctypes.c_int, _ctypes.c_int, _ctypes.POINTER(k4a_calibration_t))


"""
K4A_EXPORT k4a_wait_result_t k4a_device_get_capture(k4a_device_t device_handle,
k4a_capture_t *capture_handle,
int32_t timeout_in_ms);
"""
k4a_device_get_capture = _k4a_dll.k4a_device_get_capture
k4a_device_get_capture.restype=_ctypes.c_int
k4a_device_get_capture.argtypes=(k4a_device_t, _ctypes.POINTER(k4a_capture_t), _ctypes.c_int32)


#K4A_EXPORT void k4a_capture_release(k4a_capture_t capture_handle);
k4a_capture_release = _k4a_dll.k4a_capture_release
k4a_capture_release.argtypes=(k4a_capture_t,)


#K4A_EXPORT void k4a_image_release(k4a_image_t image_handle);
k4a_image_release = _k4a_dll.k4a_image_release
k4a_image_release.argtypes=(k4a_image_t,)


#K4A_EXPORT void k4a_device_stop_cameras(k4a_device_t device_handle);
k4a_device_stop_cameras = _k4a_dll.k4a_device_stop_cameras
k4a_device_stop_cameras.argtypes=(k4a_device_t,)


#K4A_EXPORT void k4a_device_close(k4a_device_t device_handle);
k4a_device_close = _k4a_dll.k4a_device_close
k4a_device_close.argtypes=(k4a_device_t,)


#K4A_EXPORT k4a_buffer_result_t k4a_device_get_serialnum(k4a_device_t device_handle, char *serial_number, size_t *serial_number_size);
k4a_device_get_serialnum = _k4a_dll.k4a_device_get_serialnum
k4a_device_get_capture.restype=k4a_buffer_result_t
k4a_device_close.argtypes=(k4a_device_t, _ctypes.c_char_p, _ctypes.c_ulonglong)


# Define symbols that will be exported with "from _k4a import *".
__all__ = [
]

del _ctypes
21 changes: 0 additions & 21 deletions src/python/k4a/src/k4a/_bindings/_k4atypes.py

This file was deleted.

Loading