From a72c728f336626caebdc30739e456ad4886e1bfb Mon Sep 17 00:00:00 2001 From: becker Date: Mon, 11 Mar 2024 02:56:45 +0100 Subject: [PATCH] Dateien nach "tutel" hochladen --- tutel/tutel_max_value_pure.py | 48 ++++++++++------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/tutel/tutel_max_value_pure.py b/tutel/tutel_max_value_pure.py index d871ef3..510cc16 100644 --- a/tutel/tutel_max_value_pure.py +++ b/tutel/tutel_max_value_pure.py @@ -256,17 +256,17 @@ class tutel(): depth_image = self.depth_bridge.imgmsg_to_cv2(data, "passthrough") #if self.verbose == "window" or self.verbose == "both": cv2.rotate(depth_image, cv2.ROTATE_180, depth_image) #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]: self.x = (self.top_left[0],self.top_right[0]) - else: self.x = (self.top_right[0],self.top_left[0]) - if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1]) - else: self.y = (self.bottom_left[1],self.top_left[1]) - elif (self.top_left[0] - self.top_right[0]) in range (-10,10): - if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0]) - else: self.x = (self.top_left[0],self.bottom_left[0]) - if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1]) - else: self.y = (self.bottom_right[1],self.bottom_left[1]) + #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]: self.x = (self.top_left[0],self.top_right[0]) + # else: self.x = (self.top_right[0],self.top_left[0]) + # if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1]) + # else: self.y = (self.bottom_left[1],self.top_left[1]) + #elif (self.top_left[0] - self.top_right[0]) in range (-10,10): + # if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0]) + # else: self.x = (self.top_left[0],self.bottom_left[0]) + # if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1]) + # else: self.y = (self.bottom_right[1],self.bottom_left[1]) #self.pixel_length = (self.x[1] - self.x[0] + self.y[1] - self.y[0]) / 2 #Approximation function for the amount of marker side's pixel for a specific distance to the camera #f(x)=2914.2987x^-1.0159, with x := distance between camera and marker. Values rounded down to 4 digits. @@ -339,8 +339,6 @@ class tutel(): def markDetected(self, image, corners): - thresh_left = self.w//2 - 100 - thresh_right = self.w//2 + 100 for markerCorner in corners: (self.top_left, self.top_right, self.bottom_right, self.bottom_left) = markerCorner.reshape((4,2)) self.top_left = (int(self.top_left[0]), int(self.top_left[1])) @@ -358,34 +356,13 @@ class tutel(): else: self.x = (self.top_left[0],self.bottom_left[0]) if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1]) else: self.y = (self.bottom_right[1],self.bottom_left[1]) + cv2.line(image, self.top_left, self.top_right, (0,255,0), 2) cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2) cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2) cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2) self.depth_state = True - - #self.last_marker_position = ((self.top_left), (self.bottom_right)) - #if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or - #(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or - #(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or - #(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)): - #print("ATTACK") - #self.t.linear.x = 0.15 * self.vel_fac - #self.t.angular.z = 0.0 * self.vel_fac - #self.pub.publish(self.t) - #elif(self.top_right[0] < thresh_left or - #self.bottom_right[0] < thresh_left): - #print("LEFT") - #self.t.linear.x = 0.0 * self.vel_fac - #self.t.angular.z = 0.2 * self.vel_fac - #self.pub.publish(self.t) - #elif(self.top_left[0] > thresh_right or - #self.bottom_left[0] > thresh_right): - #print("RIGHT") - #self.t.linear.x = 0.0 * self.vel_fac - #self.t.angular.z = -0.2 * self.vel_fac - #self.pub.publish(self.t) if self.last_depth > 1000: if self.x[1] < self.w//2 - 80: if self.verbose == "terminal" or self.verbose == "both": print("LEFT") @@ -440,6 +417,7 @@ class tutel(): #self.board.flush() self.board.write(bytes("0 0 0", "utf-8")) self.board.flush() + self.board.reset_input_buffer() self.board.reset_output_buffer() while self.board.in_waiting < 6: pass