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()