Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2024 Recoil Robotics
Copyright (c) 2024 FRC 9577 Recoil Robotics
Copyright (c) 2024 Central Texas FRC Alliane, Inc. dba Innovatiion Treehouse

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 16 additions & 0 deletions detection_object
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Detection object:
tag_family = b'tag36h11'
tag_id = 2
hamming = 0
decision_margin = 44.62813949584961
homography = [[ 2.69612366e+01 1.67040375e+00 7.11355833e+02]
[-7.04108208e-01 2.86574596e+01 1.15765181e+02]
[-1.03034204e-03 2.04496354e-03 1.00000000e+00]]
center = [711.35583265 115.7651814 ]
corners = [[683.96160889 144.68180847]
[739.23742676 143.57286072]
[738.91906738 86.67015076]
[683.41760254 87.90101624]]
pose_R = None
pose_t = None
pose_err = None
55 changes: 55 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import cv2
import pupil_apriltags as apriltag


# define a video capture object
vid = cv2.VideoCapture(0)

detector = apriltag.Detector()
first_image = True
while(True):

# Capture the video frame
# by frame
ret, frame = vid.read()

# convert the frame to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

results = detector.detect(gray)

# loop over the AprilTag detection results
for r in results:
# extract the bounding box (x, y)-coordinates for the AprilTag
# and convert each of the (x, y)-coordinate pairs to integers
(ptA, ptB, ptC, ptD) = r.corners
ptB = (int(ptB[0]), int(ptB[1]))
ptC = (int(ptC[0]), int(ptC[1]))
ptD = (int(ptD[0]), int(ptD[1]))
ptA = (int(ptA[0]), int(ptA[1]))
# draw the bounding box of the AprilTag detection
cv2.line(frame, ptA, ptB, (0, 255, 0), 2)
cv2.line(frame, ptB, ptC, (0, 255, 0), 2)
cv2.line(frame, ptC, ptD, (0, 255, 0), 2)
cv2.line(frame, ptD, ptA, (0, 255, 0), 2)
# draw the center (x, y)-coordinates of the AprilTag
(cX, cY) = (int(r.center[0]), int(r.center[1]))
cv2.circle(frame, (cX, cY), 5, (0, 0, 255), -1)
# draw the tag family on the image
tagFamily = str(r.tag_id)
if first_image:
print(r)
first_image=False
cv2.putText(frame, tagFamily, (cX + 20, cY + 20 ),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 255), 2)
cv2.imshow("Image",frame)
# the 'q' button is set as the
# quitting button you may use any
# desired button of your choice
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()