From f4c652f70f7610c2e5baa1777cc0a44b8474e0c8 Mon Sep 17 00:00:00 2001 From: becker Date: Sat, 17 Feb 2024 14:50:05 +0100 Subject: [PATCH] patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit progress session 02.17. white board notes zum korrigieren der tiefen. arithmetisches mittel durch ausreißer versaut. --- dennis_nodes/tutel.py | 2 +- dennis_nodes/tutel_depth.py | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dennis_nodes/tutel.py b/dennis_nodes/tutel.py index a96e8df..8ee0306 100644 --- a/dennis_nodes/tutel.py +++ b/dennis_nodes/tutel.py @@ -168,7 +168,7 @@ class tutel(): cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2) for i in range(x[0], x[1]): for j in range(y[0], y[1]): - self.last_depth += depth_image[j][x] + self.last_depth += depth_image[j][i] self.number_of_operations += 1 self.last_depth /= self.number_of_operations print(self.depth_counter, self.last_depth, self.number_of_operations) diff --git a/dennis_nodes/tutel_depth.py b/dennis_nodes/tutel_depth.py index b88b939..a450fb4 100644 --- a/dennis_nodes/tutel_depth.py +++ b/dennis_nodes/tutel_depth.py @@ -108,7 +108,6 @@ class Tutel_Depth(): y = (0,0) #self.number_of_operations = 0 #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): 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]) @@ -119,15 +118,16 @@ class Tutel_Depth(): 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) + cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (255,255,255), 2) for i in range(x[0], x[1]): for j in range(y[0], y[1]): - self.last_depth += depth_image[j][x] + print(depth_image[j][i]) + self.last_depth += depth_image[j][i] self.number_of_operations += 1 self.last_depth /= self.number_of_operations 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: @@ -154,4 +154,20 @@ class Tutel_Depth(): self.depth_state = True - return image \ No newline at end of file + return image + +def main(): + if len(sys.argv) != 4: + print("Please give the following arguments and and ") + print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw") + return 1 + ic = Tutel_Depth(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3])) + try: + rospy.spin() + except KeyboardInterrupt: + print("Shutting down") + cv2.destroyAllWindows() + + +if __name__ == "__main__": + main() \ No newline at end of file