Orginal Aruco

This commit is contained in:
2023-12-19 13:08:39 +01:00
parent 33544298ea
commit 2a68782e33
2 changed files with 28 additions and 19 deletions
+9 -1
View File
@@ -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)
+19 -18
View File
@@ -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)