From 6227d57b55a8414839cbdd95c67f0fa2efaa5f53 Mon Sep 17 00:00:00 2001 From: becker Date: Wed, 6 Dec 2023 13:40:12 +0100 Subject: [PATCH] update marker working now, seems like light influences the markers pixel calculation. Definitely needs to be checked. With light on this works. Threshold possibly too big which causes the bot to change the angular.z too slow more tests in next version. --- marker_attack_node/marker_attack.py | 48 +++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/marker_attack_node/marker_attack.py b/marker_attack_node/marker_attack.py index 433ac7a..03ee78e 100644 --- a/marker_attack_node/marker_attack.py +++ b/marker_attack_node/marker_attack.py @@ -80,17 +80,53 @@ class image_converter: bottom_right = (int(bottom_right[0]), int(bottom_right[1])) bottom_left = (int(bottom_left[0]), int(bottom_left[1])) cv2.circle(img, top_left, 10, (0,255,0), -1) - if (top_left[1] or top_right[1] or bottom_left[1] or bottom_right[1]) >= thresh_left and (top_left[1] or top_right[1] or bottom_left[1] or bottom_right[1]) <= thresh_right: - print("###############################") - print(top_left[1]) - print(top_right[1]) - print(bottom_left[1]) - print(bottom_right[1]) + print("top_left(",top_left[0],",",top_left[1],")") + print("top_right(",top_right[0],",",top_right[1],")") + print("bottom_left(",bottom_left[0],",",bottom_left[1],")") + print("bottom_right(",bottom_right[0],",",bottom_right[1],")") + if ((top_left[0] > thresh_left and top_left[0] < thresh_right) or + (top_right[0] > thresh_left and top_right[0] < thresh_right) or + (bottom_left[0] > thresh_left and bottom_left[0] < thresh_right) or + (bottom_right[0] > thresh_left and bottom_right[0] < thresh_right)): + print("##########################") + print("Object found") + print("top_left(",top_left[0],",",top_left[1],")") + print("top_right(",top_right[0],",",top_right[1],")") + print("bottom_left(",bottom_left[0],",",bottom_left[1],")") + print("bottom_right(",bottom_right[0],",",bottom_right[1],")") print(thresh_left) print(thresh_right) print("##############################################") self.t.linear.x = 0.1 self.pub.publish(self.t) + self.rate.sleep() + elif(top_right[0] < thresh_left or + bottom_right[0] < thresh_left): + print("##########################") + print("Object found") + print("top_left(",top_left[0],",",top_left[1],")") + print("top_right(",top_right[0],",",top_right[1],")") + print("bottom_left(",bottom_left[0],",",bottom_left[1],")") + print("bottom_right(",bottom_right[0],",",bottom_right[1],")") + print(thresh_left) + print(thresh_right) + print("##############################################") + self.t.angular.z = 0.2 + self.pub.publish(self.t) + self.rate.sleep() + elif(top_left[0] > thresh_right or + bottom_left[0] > thresh_right): + print("##########################") + print("Object found") + print("top_left(",top_left[0],",",top_left[1],")") + print("top_right(",top_right[0],",",top_right[1],")") + print("bottom_left(",bottom_left[0],",",bottom_left[1],")") + print("bottom_right(",bottom_right[0],",",bottom_right[1],")") + print(thresh_left) + print(thresh_right) + print("##############################################") + self.t.angular.z = -0.2 + self.pub.publish(self.t) self.rate.sleep() #print(corners[0][0]) ids = ids.flatten()