debugging apriltag image detection problems

This commit is contained in:
Tylr-J42 2024-07-14 05:28:11 -04:00
parent 6504de4270
commit a63d659fc6
6 changed files with 27 additions and 8 deletions

View File

@ -135,7 +135,7 @@ def display_features(image, imgpts, totalDist):
return image
# setting up apriltag detection. Make sure this is OUTSIDE the loop next time
options = apriltag.DetectorOptions(families='tag36h11', border=1, nthreads=4,
options = apriltag.DetectorOptions(families='tag36h11', border=1, nthreads=1,
quad_decimate=1.0, quad_blur=0.0, refine_edges=True,
refine_decode=False, refine_pose=False, debug=False, quad_contours=True)
detector = apriltag.Detector(options)
@ -144,6 +144,7 @@ detector = apriltag.Detector(options)
time.sleep(0.1)
while True:
frame_start = time.time()
cam.update()
image = cam.read()
data_array = []
visible_tags = []
@ -197,9 +198,7 @@ while True:
image = cv2.putText(image, "FPS: "+str(round(FPS, 4)), (25,440), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 2, cv2.LINE_AA)
cv2.imshow("Frame", image)
key = cv2.waitKey(1) & 0xFF
if key ==ord("q"):
break
key = cv2.waitKey(1)
# frame rate for performance
FPS = (1/(time.time()-frame_start))

View File

@ -4,8 +4,9 @@ import os
stream = Picam2Vid((640, 480))
path = "/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Calibration_Pics_Wide_640x480/"
path = "/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Static_Tag_Pics/"
stream.update()
frame = stream.read()
cv2.imshow("frame", frame)
cv2.waitKey(1)

View File

@ -12,6 +12,7 @@ class Picam2Vid:
self.camera = Picamera2()
self.resolution = camera_res
config = self.camera.create_video_configuration(main={"size": self.resolution, "format": "RGB888"}, transform=Transform(hflip=True), lores={"size": (640,480)}, encode='main')
#config = self.camera.create_video_configuration(raw={"size":camera_res})
self.camera.configure(config)
self.camera.set_controls({"FrameRate": 120})
self.frame = None
@ -19,13 +20,15 @@ class Picam2Vid:
self.camera.start()
# output the frame we want
def read(self):
self.frame=self.camera.capture_array()
def update(self):
if self.stopped:
self.camera.stop()
return
self.frame=self.camera.capture_array('main')
#print("debug threading")
def read(self):
return self.frame
# end threading
def stop(self):
self.stopped = True

View File

@ -0,0 +1,16 @@
import apriltag
import numpy as np
import cv2
options = apriltag.DetectorOptions(families='tag36h11', border=1, nthreads=1,
quad_decimate=1.0, quad_blur=0.0, refine_edges=True,
refine_decode=False, refine_pose=False, debug=False, quad_contours=True)
detector = apriltag.Detector(options)
image = cv2.imread("/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Static_Tag_Pics/0.jpg")
tagFrame = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
output = detector.detect(tagFrame)
print(output)

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB