attempting to undistort not promising still

This commit is contained in:
2024-07-24 06:02:30 -04:00
parent a652fae56f
commit 1535e13b62
19 changed files with 119440 additions and 48827 deletions

View File

@@ -9,9 +9,10 @@ path = "/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/St
stream.update()
frame = stream.read()
cv2.imshow("frame", frame)
cv2.waitKey(2)
cv2.waitKey(1)
confirmation = input("keep y or n: ")
print(frame)
if confirmation == "y":
file_order = len(os.listdir(path))
cv2.imwrite(path+str(file_order)+".png", frame)
cv2.imwrite(path+str(file_order)+".jpg", frame)
stream.stop()

View File

@@ -11,7 +11,7 @@ class Picam2Vid:
# For specs - https://www.raspberrypi.com/documentation/accessories/camera.html
self.camera = Picamera2()
self.resolution = camera_res
config = self.camera.create_video_configuration(main={"size": self.resolution}, transform=Transform(hflip=True), lores={"size": (640,480)}, encode='main')
config = self.camera.create_still_configuration(main={"size": self.resolution}, 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})
@@ -25,6 +25,7 @@ class Picam2Vid:
self.camera.stop()
return
self.frame=self.camera.capture_array('main')
print(self.frame.dtype)
#print("debug threading")
def read(self):

View File

@@ -2,6 +2,14 @@ import dt_apriltags
import numpy as np
import cv2
FOCAL_LEN_PIXELS = 976.16482142
camera_matrix = np.array([[FOCAL_LEN_PIXELS, 0., 771.05155174],
[ 0., FOCAL_LEN_PIXELS, 408.52081949],
[ 0., 0., 1. ]])
dist = np.array([[-0.04790604, 0.08489533, -0.00387366, 0.00616192, -0.03875398]])
detector = dt_apriltags.Detector(searchpath=['apriltags'],
families='tag36h11',
nthreads=2,
@@ -11,15 +19,25 @@ detector = dt_apriltags.Detector(searchpath=['apriltags'],
decode_sharpening=0.25,
debug=1)
image = cv2.imread("/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Static_Tag_Pics/bw_img.png")
image = cv2.imread("/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Static_Tag_Pics/7.png")
tagFrame = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
h, w = image.shape[:2]
newcameramtx, roi = cv2.getOptimalNewCameraMatrix(camera_matrix, dist, (w,h), 1, (w,h))
print(tagFrame.dtype)
# undistort
dst = cv2.undistort(image, camera_matrix, dist, None, newcameramtx)
# crop the image
x, y, w, h = roi
dst = dst[y:y+h, x:x+w]
cv2.imshow("frame", image)
cv2.waitKey(0)
dst = cv2.cvtColor(dst, cv2.COLOR_BGR2GRAY)
output = detector.detect(tagFrame, estimate_tag_pose=False, camera_params=None, tag_size=None)
print(dst)
cv2.imshow("frame", dst)
cv2.waitKey(1)
output = detector.detect(dst, estimate_tag_pose=False, camera_params=None, tag_size=None)
print(output)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB