From 9144c5b2310d69b905c75cd0fc5fa3f81f0ff8f6 Mon Sep 17 00:00:00 2001 From: becker Date: Wed, 21 Feb 2024 12:13:27 +0100 Subject: [PATCH] patch --- dennis_nodes/tutel_depth_filter_option_01.py | 18 ++++++++++++------ dennis_nodes/tutel_depth_max_value_pure.py | 16 ++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/dennis_nodes/tutel_depth_filter_option_01.py b/dennis_nodes/tutel_depth_filter_option_01.py index b17ba10..19cc1fc 100644 --- a/dennis_nodes/tutel_depth_filter_option_01.py +++ b/dennis_nodes/tutel_depth_filter_option_01.py @@ -156,11 +156,15 @@ class tutel(): #x and y are swapped, because print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1])) if (self.top_left[0] - self.bottom_left[0]) in range (-10,10): - x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]] - y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]] + if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0]) + else: x = (self.top_right[0],self.top_left[0]) + if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1]) + else: y = (self.bottom_left[1],self.top_left[1]) elif (self.top_left[0] - self.top_right[0]) in range (-10,10): - x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]] - y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]] + if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0]) + else: x = (self.top_left[0],self.bottom_left[0]) + if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1]) + else: y = (self.bottom_right[1],self.bottom_left[1]) cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2) depth_values = [] for i in range(x[0], x[1]): @@ -168,13 +172,15 @@ class tutel(): if depth_image[j][i] > self.maxMinDepth: depth_values.append(depth_image[j][i]) for k in depth_values: + #print(str(max(depth_values)) + " !!!!!!!!!!!!!!!!!!!") if k > (max(depth_values) - 10): + #print("hello world!") self.last_depth += k self.number_of_operations += 1 - self.last_depth [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0] + self.last_depth = [0, self.last_depth/self.number_of_operations][self.number_of_operations > 0] print(self.depth_counter, self.last_depth, self.number_of_operations) self.number_of_operations = 0 - cv2.imshow("Tutel_Depth", depth_image) + #cv2.imshow("Tutel_Depth", depth_image) if self.last_depth < self.maxMinDepth and self.last_depth != 0: self.depth_counter += 1 if self.depth_counter > 0: diff --git a/dennis_nodes/tutel_depth_max_value_pure.py b/dennis_nodes/tutel_depth_max_value_pure.py index d43ad9d..93e3860 100644 --- a/dennis_nodes/tutel_depth_max_value_pure.py +++ b/dennis_nodes/tutel_depth_max_value_pure.py @@ -156,20 +156,24 @@ class tutel(): #x and y are swapped, because print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1])) if (self.top_left[0] - self.bottom_left[0]) in range (-10,10): - x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]] - y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]] + if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0]) + else: x = (self.top_right[0],self.top_left[0]) + if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1]) + else: y = (self.bottom_left[1],self.top_left[1]) elif (self.top_left[0] - self.top_right[0]) in range (-10,10): - x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]] - y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]] + if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0]) + else: x = (self.top_left[0],self.bottom_left[0]) + if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1]) + else: y = (self.bottom_right[1],self.bottom_left[1]) cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2) depth_values = [] for i in range(x[0], x[1]): for j in range(y[0], y[1]): - if depth_image[j][i] > self.maxMinDepth: + if depth_image[j][i] > 100: depth_values.append(depth_image[j][i]) self.last_depth = max(depth_values) print(self.depth_counter, self.last_depth) - cv2.imshow("Tutel_Depth", depth_image) + #cv2.imshow("Tutel_Depth", depth_image) if self.last_depth < self.maxMinDepth and self.last_depth != 0: self.depth_counter += 1 if self.depth_counter > 0: