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 API: Adding more tests to test the Device, Capture, Image, and…
… Calibration classes. Fixing shallow copy and deep copy of Image objects.
  • Loading branch information
JonathanESantos committed Dec 24, 2020
commit d0239028e0dd5bb3cbb61dbd148b46b7d4611e9d
4 changes: 3 additions & 1 deletion src/python/k4a/src/k4a/_bindings/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

class Calibration:

def __init__(self, _calibration:_Calibration):
def __init__(self, _calibration:_Calibration=None):
self._calibration = _calibration
if self._calibration is None:
self._calibration = _Calibration()

# Allow "with" syntax.
def __enter__(self):
Expand Down
18 changes: 12 additions & 6 deletions src/python/k4a/src/k4a/_bindings/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ def __str__(self):
# Define properties and get/set functions. ###############
@property
def color(self):
image_handle = k4a_capture_get_color_image(self._capture_handle)
self._color = Image._create_from_existing_image_handle(image_handle)
if self._color is None:
image_handle = k4a_capture_get_color_image(self._capture_handle)
self._color = Image._create_from_existing_image_handle(image_handle)

return self._color

@color.setter
Expand All @@ -135,8 +137,10 @@ def color(self):

@property
def depth(self):
image_handle = k4a_capture_get_depth_image(self._capture_handle)
self._depth = Image._create_from_existing_image_handle(image_handle)
if self._depth is None:
image_handle = k4a_capture_get_depth_image(self._capture_handle)
self._depth = Image._create_from_existing_image_handle(image_handle)

return self._depth

@depth.setter
Expand All @@ -156,8 +160,10 @@ def depth(self):

@property
def ir(self):
image_handle = k4a_capture_get_ir_image(self._capture_handle)
self._ir = Image._create_from_existing_image_handle(image_handle)
if self._ir is None:
image_handle = k4a_capture_get_ir_image(self._capture_handle)
self._ir = Image._create_from_existing_image_handle(image_handle)

return self._ir

@ir.setter
Expand Down
56 changes: 29 additions & 27 deletions src/python/k4a/src/k4a/_bindings/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
k4a_device_get_imu_sample, k4a_device_get_color_control, \
k4a_device_start_cameras, k4a_device_stop_cameras, \
k4a_device_start_imu, k4a_device_stop_imu, \
k4a_device_get_color_control, k4a_device_get_raw_calibration, \
k4a_device_set_color_control, k4a_device_get_raw_calibration, \
k4a_device_get_sync_jack, k4a_device_get_capture, k4a_device_get_calibration

from .capture import Capture
Expand Down Expand Up @@ -106,15 +106,15 @@ def open(device_index:int=0):

# Create a dictionary of color control capabilities.
color_control_commands = [
('backlight_comp', EColorControlCommand.BACKLIGHT_COMPENSATION),
('brightness', EColorControlCommand.BRIGHTNESS),
('contrast', EColorControlCommand.CONTRAST),
('exposure_time', EColorControlCommand.EXPOSURE_TIME_ABSOLUTE),
('gain', EColorControlCommand.GAIN),
('powerline_freq', EColorControlCommand.POWERLINE_FREQUENCY),
('saturation', EColorControlCommand.SATURATION),
('sharpness', EColorControlCommand.SHARPNESS),
('whitebalance', EColorControlCommand.WHITEBALANCE)
EColorControlCommand.BACKLIGHT_COMPENSATION,
EColorControlCommand.BRIGHTNESS,
EColorControlCommand.CONTRAST,
EColorControlCommand.EXPOSURE_TIME_ABSOLUTE,
EColorControlCommand.GAIN,
EColorControlCommand.POWERLINE_FREQUENCY,
EColorControlCommand.SATURATION,
EColorControlCommand.SHARPNESS,
EColorControlCommand.WHITEBALANCE
]

supports_auto = _ctypes.c_bool(False)
Expand All @@ -128,7 +128,7 @@ def open(device_index:int=0):

status = k4a_device_get_color_control_capabilities(
device.__device_handle,
command[1],
command,
_ctypes.byref(supports_auto),
_ctypes.byref(min_value),
_ctypes.byref(max_value),
Expand All @@ -137,17 +137,17 @@ def open(device_index:int=0):
_ctypes.byref(color_control_mode))

if (status == EStatus.SUCCEEDED):
device._color_ctrl_cap.__dict__[command[0]] = _EmptyClass()
device._color_ctrl_cap.__dict__[command[0]].supports_auto = bool(supports_auto.value)
device._color_ctrl_cap.__dict__[command[0]].min_value = int(min_value.value)
device._color_ctrl_cap.__dict__[command[0]].max_value = int(max_value.value)
device._color_ctrl_cap.__dict__[command[0]].step_value = int(step_value.value)
device._color_ctrl_cap.__dict__[command[0]].default_value = int(default_value.value)
device._color_ctrl_cap.__dict__[command[0]].default_mode = EColorControlMode(color_control_mode.value)
device._color_ctrl_cap.__dict__[command] = _EmptyClass()
device._color_ctrl_cap.__dict__[command].supports_auto = bool(supports_auto.value)
device._color_ctrl_cap.__dict__[command].min_value = int(min_value.value)
device._color_ctrl_cap.__dict__[command].max_value = int(max_value.value)
device._color_ctrl_cap.__dict__[command].step_value = int(step_value.value)
device._color_ctrl_cap.__dict__[command].default_value = int(default_value.value)
device._color_ctrl_cap.__dict__[command].default_mode = EColorControlMode(color_control_mode.value)

# Read the sync jack.
(device._sync_in_connected, device._sync_out_connected) = \
_read_sync_jack_helper(device.__device_handle)
# Read the sync jack.
(device._sync_in_connected, device._sync_out_connected) = \
_read_sync_jack_helper(device.__device_handle)

return device

Expand Down Expand Up @@ -233,16 +233,16 @@ def start_imu(self)->EStatus:
def stop_imu(self):
k4a_device_stop_imu(self.__device_handle)

def get_color_control(
color_ctrl_command:EColorControlCommand,
color_ctrl_mode:EColorControlMode)->int:
def get_color_control(self,
color_ctrl_command:EColorControlCommand)->(int, EColorControlMode):

retval = None
retmode = None

color_ctrl_value = _ctypes.c_int32(0)
command = _ctypes.c_int(color_ctrl_command.value)
mode = _ctypes.c_int(color_ctrl_mode.value)

mode = _ctypes.c_int32(EColorControlMode.MANUAL.value)
status = k4a_device_get_color_control(
self.__device_handle,
color_ctrl_command,
Expand All @@ -251,10 +251,12 @@ def get_color_control(

if status == EStatus.SUCCEEDED:
retval = color_ctrl_value.value
retmode = EColorControlMode(mode.value)

return retval
return (retval, retmode)

def set_color_control(
self,
color_ctrl_command:EColorControlCommand,
color_ctrl_mode:EColorControlMode,
color_ctrl_value:int)->EStatus:
Expand Down
22 changes: 11 additions & 11 deletions src/python/k4a/src/k4a/_bindings/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,17 @@ def __copy__(self):

# Create a shallow copy.
new_image = Image(self._image_handle)
new_image._data = _copy.copy(self._data)
new_image._image_format = _copy.copy(self._image_format)
new_image._size_bytes = _copy.copy(self._size_bytes)
new_image._width_pixels = _copy.copy(self._width_pixels)
new_image._height_pixels = _copy.copy(self._height_pixels)
new_image._stride_bytes = _copy.copy(self._stride_bytes)
new_image._device_timestamp_usec = _copy.copy(self._device_timestamp_usec)
new_image._system_timestamp_nsec = _copy.copy(self._system_timestamp_nsec)
new_image._exposure_usec = _copy.copy(self._exposure_usec)
new_image._white_balance = _copy.copy(self._white_balance)
new_image._iso_speed = _copy.copy(self._iso_speed)
new_image._data = self._data.view()
new_image._image_format = self._image_format
new_image._size_bytes = self._size_bytes
new_image._width_pixels = self._width_pixels
new_image._height_pixels = self._height_pixels
new_image._stride_bytes = self._stride_bytes
new_image._device_timestamp_usec = self._device_timestamp_usec
new_image._system_timestamp_nsec = self._system_timestamp_nsec
new_image._exposure_usec =self._exposure_usec
new_image._white_balance = self._white_balance
new_image._iso_speed = self._iso_speed

# Update reference count.
new_image._reference()
Expand Down
30 changes: 15 additions & 15 deletions src/python/k4a/src/k4a/_bindings/k4atypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class ETransformInterpolationType(_IntEnum):


@_unique
class EFramePerSecond(_IntEnum):
class EFramesPerSecond(_IntEnum):
"""
Color and depth sensor frame rate.

Expand Down Expand Up @@ -437,7 +437,7 @@ class ECalibrationType(_IntEnum):
NUM_TYPES Number of types excluding unknown type.
================================ ==========================================
"""
UNKNOWN = 0
UNKNOWN = -1
DEPTH = _auto()
COLOR = _auto()
GYRO = _auto()
Expand Down Expand Up @@ -587,15 +587,15 @@ class DeviceConfiguration(_ctypes.Structure):
]

def __init__(self,
color_format:EImageFormat,
color_resolution:EColorResolution,
depth_mode:EDepthMode,
camera_fps:EFramePerSecond,
synchronized_images_only:bool,
depth_delay_off_color_usec:int,
wired_sync_mode:EWiredSyncMode,
subordinate_delay_off_master_usec:int,
disable_streaming_indicator:bool):
color_format:EImageFormat=EImageFormat.CUSTOM,
color_resolution:EColorResolution=EColorResolution.RES_720P,
depth_mode:EDepthMode=EDepthMode.OFF,
camera_fps:EFramesPerSecond=EFramesPerSecond.FPS_5,
synchronized_images_only:bool=True,
depth_delay_off_color_usec:int=0,
wired_sync_mode:EWiredSyncMode=EWiredSyncMode.STANDALONE,
subordinate_delay_off_master_usec:int=0,
disable_streaming_indicator:bool=False):

self.color_format = color_format
self.color_resolution = color_resolution
Expand Down Expand Up @@ -885,7 +885,7 @@ def __str__(self):
color_format = EImageFormat.COLOR_MJPG,
color_resolution = EColorResolution.OFF,
depth_mode = EDepthMode.OFF,
camera_fps = EFramePerSecond.FPS_30,
camera_fps = EFramesPerSecond.FPS_30,
synchronized_images_only = False,
depth_delay_off_color_usec = 0,
wired_sync_mode = EWiredSyncMode.STANDALONE,
Expand All @@ -896,7 +896,7 @@ def __str__(self):
color_format = EImageFormat.COLOR_BGRA32,
color_resolution = EColorResolution.RES_2160P,
depth_mode = EDepthMode.WFOV_2X2BINNED,
camera_fps = EFramePerSecond.FPS_15,
camera_fps = EFramesPerSecond.FPS_15,
synchronized_images_only = True,
depth_delay_off_color_usec = 0,
wired_sync_mode = EWiredSyncMode.STANDALONE,
Expand All @@ -913,7 +913,7 @@ def __str__(self):

if len(keys) > 0:
for n in range(len(keys)-1):
tempstr = tempstr + keys[n] + "=" + str(self.__dict__[keys[n]]) + ", "
tempstr = tempstr + keys[len(keys)-1] + "=" + str(self.__dict__[keys[len(keys)-1]])
tempstr = tempstr + str(keys[n]) + "=" + str(self.__dict__[keys[n]]) + ", "
tempstr = tempstr + str(keys[len(keys)-1]) + "=" + str(self.__dict__[keys[len(keys)-1]])

return tempstr
Loading