From 2a68782e33dc48bcccab61d628b56d810b99f51a Mon Sep 17 00:00:00 2001 From: tscherne Date: Tue, 19 Dec 2023 13:08:39 +0100 Subject: [PATCH] Orginal Aruco --- den/marker_test.py | 10 +++++++- turtle_control/scripts/marker_test.py | 37 ++++++++++++++------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/den/marker_test.py b/den/marker_test.py index f16a70c..994fce3 100644 --- a/den/marker_test.py +++ b/den/marker_test.py @@ -42,7 +42,7 @@ def talker(): "-t", "--type", type=str, - default="DICT_7X7_50", + default="DICT_ARUCO_ORIGINAL", help="type of ArCUo tag to detect", ) args = vars(ap.parse_args()) @@ -67,6 +67,7 @@ def talker(): rospy.init_node("turtle_control", anonymous=True) rate = rospy.Rate(10) # t = Twist() + self.storedMarkerPoints = [] while not rospy.is_shutdown(): # grab the frame from the threaded video and resize it # to have a maximum width of 1000 pixels @@ -120,6 +121,13 @@ def talker(): (0, 255, 0), 2, ) + storedSize = len(self.storedMarkerPoints) + if storedSize < 20: + self.storedMarkerPoints += (cX,cY) + if storedSize > 5: + self.storedMarkerPoints.pop(0) + for x in self.storedMarkerPoints: + cv.circle(frame, x, 4, (255, 0, 0), -1) # show the output frame cv.imshow("Frame", frame) diff --git a/turtle_control/scripts/marker_test.py b/turtle_control/scripts/marker_test.py index 2c462f7..1ee2dcf 100755 --- a/turtle_control/scripts/marker_test.py +++ b/turtle_control/scripts/marker_test.py @@ -42,7 +42,7 @@ def talker(): "-t", "--type", type=str, - default="DICT_4X4_50", + default="DICT_ARUCO_ORIGINAL", help="type of ArCUo tag to detect", ) args = vars(ap.parse_args()) @@ -55,26 +55,30 @@ def talker(): # load the ArUCo dictionary and grab hte ArUCo parameters print("[INFO] detecting '{}' tags...".format(args["type"])) arucoDict = cv.aruco.getPredefinedDictionary(ARUCO_DICT[args["type"]]) - arucoParams = cv.aruco.DetectorParameters() - detector = cv.aruco.ArucoDetector(arucoDict, arucoParams) + arucoParams = cv.aruco.DetectorParameters_create() + # detector = cv.aruco.ArucoDetector(arucoDict, arucoParams) # initialize the video stream and allow the camera sensor to warm up print("[INFO] starting video stream...") vs = VideoStream(src=0).start() - time.sleep(1.0) + time.sleep(2.0) pub = rospy.Publisher("turtle1/cmd_vel", Twist, queue_size=10) rospy.init_node("turtle_control", anonymous=True) - rate = rospy.Rate(30) # + rate = rospy.Rate(10) # t = Twist() + self.storedMarkerPoints = [] while not rospy.is_shutdown(): # grab the frame from the threaded video and resize it # to have a maximum width of 1000 pixels frame = vs.read() - frame = imutils.resize(frame) + frame = imutils.resize(frame, width=1000) # detect ArUCo markers in the input frame - (corners, ids, rejected) = detector.detectMarkers(frame) + (corners, ids, rejected) = cv2.aruco.detectMarkers( + frame, arucoDict, parameters=arucoParams + ) + print(ids) # verify *at least* one ArUCo marker was detected if len(corners) > 0: @@ -117,17 +121,14 @@ def talker(): (0, 255, 0), 2, ) - idString = "IDs:" + str(ids) - cv.putText( - frame, - idString, - (50, 50), - cv.FONT_HERSHEY_SIMPLEX, - 1, - (40, 10, 100), - 3, - cv.LINE_AA, - ) + storedSize = len(self.storedMarkerPoints) + print("Size:" + len(storedSize)) + if storedSize < 20: + self.storedMarkerPoints += (cX,cY) + if storedSize > 5: + self.storedMarkerPoints.pop(0) + for x in self.storedMarkerPoints: + cv.circle(frame, x, 4, (255, 0, 0), -1) # show the output frame cv.imshow("Frame", frame)