Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
Merged
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
18 changes: 14 additions & 4 deletions src/python/k4a/src/k4a/_bindings/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def __deepcopy__(self, src):
pass

def __del__(self):

# Ensure that handle is closed.
self.stop_cameras()
self.stop_imu()
self.close()

del self.__device_handle
Expand Down Expand Up @@ -276,10 +276,14 @@ def close(self):
been deleted to ensure that all memory is freed.
'''

self.stop_cameras()
self.stop_imu()
if self.__device_handle is None:
return

k4a_device_close(self.__device_handle)

del self.__device_handle
self.__device_handle = None

def get_capture(self, timeout_ms:int)->Capture:
'''! Reads a sensor capture.

Expand Down Expand Up @@ -435,6 +439,9 @@ def stop_cameras(self):

@see start_cameras
'''
if self.__device_handle is None:
return

k4a_device_stop_cameras(self.__device_handle)

def start_imu(self)->EStatus:
Expand Down Expand Up @@ -469,6 +476,9 @@ def stop_imu(self):
in get_imu_sample(). Calling this function while another thread is
in that function will result in that function returning a failure.
'''
if self.__device_handle is None:
return

k4a_device_stop_imu(self.__device_handle)

def get_color_control(self,
Expand Down