Orginal Aruco
This commit is contained in:
+9
-1
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user