Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Bugfix/pep8 formatting #1968

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 23 additions & 22 deletions src/python/k4a/src/k4a/_bindings/calibration.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
'''!
"""!
@file calibration.py

Defines a Calibration class that is a container for a device calibration.

Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
Kinect For Azure SDK.
'''
"""

import ctypes as _ctypes

from .k4atypes import _Calibration, EStatus, EDepthMode, EColorResolution, _Calibration
from .k4atypes import _Calibration, EStatus, EDepthMode, EColorResolution

from .k4a import k4a_calibration_get_from_raw


class Calibration:
'''! Camera calibration contains intrinsic and extrinsic calibration
"""! Camera calibration contains intrinsic and extrinsic calibration
information for a camera.

Name | Type | Description
Expand All @@ -25,13 +26,13 @@ class Calibration:
resolution_width | int | Resolution width of the calibration sensor.
resolution_height | int | Resolution height of the calibration sensor.
metric_radius | float | Max FOV of the camera.
'''
def __init__(self, _calibration:_Calibration=None):
"""

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

# Allow "with" syntax.
def __enter__(self):
return self
Expand All @@ -45,24 +46,24 @@ def __str__(self):

@staticmethod
def create_from_raw(
raw_calibration:bytearray,
depth_mode:EDepthMode,
color_resolution:EColorResolution):
'''! Get the camera calibration for a device from a raw calibration blob.
raw_calibration: bytearray,
depth_mode: EDepthMode,
color_resolution: EColorResolution):
"""! Get the camera calibration for a device from a raw calibration blob.

@param raw_calibration (bytearray): Raw calibration blob obtained from
@param raw_calibration: (bytearray): Raw calibration blob obtained from
a device or recording. The raw calibration must be NULL terminated.

@param depth_mode (EDepthMode): Mode in which depth camera is operated.
@param depth_mode: (EDepthMode): Mode in which depth camera is operated.

@param color_resolution (EColorResolution): Resolution in which color
@param color_resolution: (EColorResolution): Resolution in which color
camera is operated.

@returns Calibration: A Calibration instance.

@remarks
- The calibration represents the data needed to transform between the
camera views and is different for each operating @p depth_mode and
camera views and is different for each operating @p depth_mode and
@p color_resolution the device is configured to operate in.

@remarks
Expand All @@ -74,14 +75,14 @@ def create_from_raw(
@remarks
- This function is equivalent to Device.get_calibration() function.
Both functions return the same calibration data.
'''
"""

calibration = None

# Get the _Calibration struct from the raw buffer.
if (isinstance(raw_calibration, bytearray) and
isinstance(depth_mode, EDepthMode) and
isinstance(color_resolution, EColorResolution)):
isinstance(depth_mode, EDepthMode) and
isinstance(color_resolution, EColorResolution)):

buffer_size_bytes = _ctypes.c_size_t(len(raw_calibration))
cbuffer = (_ctypes.c_uint8 * buffer_size_bytes.value).from_buffer(raw_calibration)
Expand All @@ -102,15 +103,15 @@ def create_from_raw(
return calibration

# Define properties and get/set functions. ###############

@property
def depth_cam_cal(self):
return self._calibration.depth_camera_calibration

@property
def color_cam_cal(self):
return self._calibration.color_camera_calibration

@property
def extrinsics(self):
return self._calibration.extrinsics
Expand All @@ -123,4 +124,4 @@ def depth_mode(self):
def color_resolution(self):
return self._calibration.color_resolution

# ###############
# ###############
75 changes: 38 additions & 37 deletions src/python/k4a/src/k4a/_bindings/capture.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''!
"""!
@file capture.py

Defines a Capture class that is a container for a single capture of data
Expand All @@ -7,7 +7,7 @@
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
Kinect For Azure SDK.
'''
"""

import ctypes as _ctypes
import copy as _copy
Expand All @@ -23,8 +23,9 @@

from .image import Image


class Capture:
'''! A class that represents a capture from an Azure Kinect device.
"""! A class that represents a capture from an Azure Kinect device.

Property Name | Type | R/W | Description
------------- | ----- | --- | -----------------------------------------
Expand All @@ -33,44 +34,44 @@ class Capture:
ir | Image | R/W | The IR image container.
temperature | float | R/W | The temperature

@remarks
- A capture represents a set of images that were captured by a
@remarks
- A capture represents a set of images that were captured by a
device at approximately the same time. A capture may have a color, IR,
and depth image. A capture may have up to one image of each type. A
and depth image. A capture may have up to one image of each type. A
capture may have no image for a given type as well.
@remarks

@remarks
- Do not use the Capture() constructor to get a Capture instance. It
will return an object that does not have a handle to the capture
resources held by the SDK. Instead, use the create() function.

@remarks
- Captures also store a temperature value which represents the
@remarks
- Captures also store a temperature value which represents the
temperature of the device at the time of the capture.

@remarks
@remarks
- While all the images associated with the capture were collected at
approximately the same time, each image has an individual timestamp
which may differ from each other. If the device was configured to
capture depth and color images separated by a delay,
Device.get_capture() will return a capture containing both image types
approximately the same time, each image has an individual timestamp
which may differ from each other. If the device was configured to
capture depth and color images separated by a delay,
Device.get_capture() will return a capture containing both image types
separated by the configured delay.

@remarks
@remarks
- Empty captures are created with create().

@remarks
@remarks
- Captures can be obtained from a Device object using get_capture().

@remarks
@remarks
- A Capture object may be copied or deep copied. A shallow copy
shares the same images as the original, and any changes in one will
affect the other. A deep copy does not share any resources with the
original, and changes in one will not affect the other. In both shallow
and deep copies, deleting one will have no effects on the other.
'''
"""

def __init__(self, capture_handle:_CaptureHandle):
def __init__(self, capture_handle: _CaptureHandle):
self._capture_handle = capture_handle
self._color = None
self._depth = None
Expand All @@ -79,13 +80,13 @@ def __init__(self, capture_handle:_CaptureHandle):

@staticmethod
def create():
'''! Create an empty capture object.
"""! Create an empty capture object.

@returns Capture instance with empty contents.
@remarks

@remarks
- If unsuccessful, None is returned.
'''
"""

capture = None

Expand All @@ -105,7 +106,7 @@ def _reference(self):
k4a_capture_reference(self._capture_handle)

def __copy__(self):
# Create a shallow copy.
# Create a shallow copy.
new_capture = Capture(self._capture_handle)
new_capture.color = _copy.copy(self.color)
new_capture.depth = _copy.copy(self.depth)
Expand All @@ -118,7 +119,7 @@ def __copy__(self):
return new_capture

def __deepcopy__(self, memo):

# Create a new capture.
new_capture = Capture.create()

Expand All @@ -132,7 +133,7 @@ def __deepcopy__(self, memo):
# Since it is a completely different capture, there is no need to
# increment the reference count. Just return the deep copy.
return new_capture

def __enter__(self):
return self

Expand Down Expand Up @@ -176,12 +177,12 @@ def color(self):
return self._color

@color.setter
def color(self, image:Image):
def color(self, image: Image):
if image is not None and isinstance(image, Image):
del self._color

k4a_capture_set_color_image(
self._capture_handle,
self._capture_handle,
image._image_handle)

self._color = image
Expand All @@ -199,12 +200,12 @@ def depth(self):
return self._depth

@depth.setter
def depth(self, image:Image):
def depth(self, image: Image):
if image is not None and isinstance(image, Image):
del self._depth

k4a_capture_set_depth_image(
self._capture_handle,
self._capture_handle,
image._image_handle)

self._depth = image
Expand All @@ -222,12 +223,12 @@ def ir(self):
return self._ir

@ir.setter
def ir(self, image:Image):
def ir(self, image: Image):
if image is not None and isinstance(image, Image):
del self._ir

k4a_capture_set_ir_image(
self._capture_handle,
self._capture_handle,
image._image_handle)

self._ir = image
Expand All @@ -242,17 +243,17 @@ def temperature(self):
return self._temperature

@temperature.setter
def temperature(self, temperature:float):
def temperature(self, temperature: float):
if temperature is not None and isinstance(temperature, float):
del self._temperature

k4a_capture_set_temperature_c(
self._capture_handle,
self._capture_handle,
_ctypes.c_float(temperature))

self._temperature = temperature

@temperature.deleter
def temperature(self):
del self._temperature
# ###############
# ###############
Loading