diff --git a/pykinect2/PyKinectRuntime.py b/pykinect2/PyKinectRuntime.py index 0454875..8913c1e 100644 --- a/pykinect2/PyKinectRuntime.py +++ b/pykinect2/PyKinectRuntime.py @@ -163,7 +163,8 @@ def __init__(self, frame_source_types): self._last_long_exposure_infrared_frame = None self._last_audio_frame = None - start_clock = time.clock() + # start_clock = time.perf_counter() + start_clock = time.perf_counter() self._last_color_frame_access = self._last_color_frame_time = start_clock self._last_body_frame_access = self._last_body_frame_time = start_clock self._last_body_index_frame_access = self._last_body_index_frame_time = start_clock @@ -243,7 +244,7 @@ def get_last_color_frame(self): with self._color_frame_lock: if self._color_frame_data is not None: data = numpy.copy(numpy.ctypeslib.as_array(self._color_frame_data, shape=(self._color_frame_data_capacity.value,))) - self._last_color_frame_access = time.clock() + self._last_color_frame_access = time.perf_counter() return data else: return None @@ -252,7 +253,7 @@ def get_last_infrared_frame(self): with self._infrared_frame_lock: if self._infrared_frame_data is not None: data = numpy.copy(numpy.ctypeslib.as_array(self._infrared_frame_data, shape=(self._infrared_frame_data_capacity.value,))) - self._last_infrared_frame_access = time.clock() + self._last_infrared_frame_access = time.perf_counter() return data else: return None @@ -261,7 +262,7 @@ def get_last_depth_frame(self): with self._depth_frame_lock: if self._depth_frame_data is not None: data = numpy.copy(numpy.ctypeslib.as_array(self._depth_frame_data, shape=(self._depth_frame_data_capacity.value,))) - self._last_depth_frame_access = time.clock() + self._last_depth_frame_access = time.perf_counter() return data else: return None @@ -270,7 +271,7 @@ def get_last_body_index_frame(self): with self._body_index_frame_lock: if self._body_index_frame_data is not None: data = numpy.copy(numpy.ctypeslib.as_array(self._body_index_frame_data, shape=(self._body_index_frame_data_capacity.value,))) - self._last_body_index_frame_access = time.clock() + self._last_body_index_frame_access = time.perf_counter() return data else: return None @@ -278,7 +279,7 @@ def get_last_body_index_frame(self): def get_last_body_frame(self): with self._body_frame_lock: if self._body_frame_bodies is not None: - self._last_body_frame_access = time.clock() + self._last_body_frame_access = time.perf_counter() return self._body_frame_bodies.copy() else: return None @@ -340,7 +341,7 @@ def handle_color_arrived(self, handle_index): try: with self._color_frame_lock: colorFrame.CopyConvertedFrameDataToArray(self._color_frame_data_capacity, self._color_frame_data, PyKinectV2.ColorImageFormat_Bgra) - self._last_color_frame_time = time.clock() + self._last_color_frame_time = time.perf_counter() except: pass colorFrame = None @@ -358,7 +359,7 @@ def handle_depth_arrived(self, handle_index): try: with self._depth_frame_lock: depthFrame.CopyFrameDataToArray(self._depth_frame_data_capacity, self._depth_frame_data) - self._last_depth_frame_time = time.clock() + self._last_depth_frame_time = time.perf_counter() except: pass depthFrame = None @@ -378,7 +379,7 @@ def handle_body_arrived(self, handle_index): with self._body_frame_lock: bodyFrame.GetAndRefreshBodyData(self._body_frame_data_capacity, self._body_frame_data) self._body_frame_bodies = KinectBodyFrameData(bodyFrame, self._body_frame_data, self.max_body_count) - self._last_body_frame_time = time.clock() + self._last_body_frame_time = time.perf_counter() # need these 2 lines as a workaround for handling IBody referencing exception self._body_frame_data = None @@ -402,7 +403,7 @@ def handle_body_index_arrived(self, handle_index): try: with self._body_index_frame_lock: bodyIndexFrame.CopyFrameDataToArray(self._body_index_frame_data_capacity, self._body_index_frame_data) - self._last_body_index_frame_time = time.clock() + self._last_body_index_frame_time = time.perf_counter() except: pass bodyIndexFrame = None @@ -419,7 +420,7 @@ def handle_infrared_arrived(self, handle_index): try: with self._infrared_frame_lock: infraredFrame.CopyFrameDataToArray(self._infrared_frame_data_capacity, self._infrared_frame_data) - self._last_infrared_frame_time = time.clock() + self._last_infrared_frame_time = time.perf_counter() except: pass infraredFrame = None