camera capture testing

This commit is contained in:
Tylr-J42 2024-08-14 04:40:01 -04:00
parent 1535e13b62
commit 7a7af85dae
9 changed files with 17 additions and 17 deletions

View File

@ -2,14 +2,15 @@ from Picam2Vid import Picam2Vid
import cv2
import os
stream = Picam2Vid((1536, 864))
stream = Picam2Vid((2304, 1296))
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)
cv2.waitKey(0)
cv2.destroyAllWindows()
confirmation = input("keep y or n: ")
print(frame)
if confirmation == "y":

View File

@ -1,6 +1,5 @@
from picamera2 import Picamera2
from libcamera import Transform
from threading import Thread
# class for allocating a thread to only updating the camera stream,
# the other thread is used for detection processing
@ -11,10 +10,10 @@ class Picam2Vid:
# For specs - https://www.raspberrypi.com/documentation/accessories/camera.html
self.camera = Picamera2()
self.resolution = camera_res
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(main={"format": "XRGB8888", "size": self.resolution}, transform=Transform(hflip=True))
#config = self.camera.create_video_configuration(raw={"size":camera_res})
self.camera.configure(config)
self.camera.set_controls({"FrameRate": 120})
#self.camera.set_controls({"FrameRate": 120})
self.frame = None
self.stopped = False
self.camera.start()

View File

@ -17,27 +17,27 @@ detector = dt_apriltags.Detector(searchpath=['apriltags'],
quad_sigma=0.0,
refine_edges=1,
decode_sharpening=0.25,
debug=1)
debug=0)
image = cv2.imread("/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Static_Tag_Pics/7.png")
image = cv2.imread("/home/tyler/Desktop/FRC-Apriltag-Pose-Detection/FRC_Fiducial_Tracking/Static_Tag_Pics/13.jpg")
h, w = image.shape[:2]
newcameramtx, roi = cv2.getOptimalNewCameraMatrix(camera_matrix, dist, (w,h), 1, (w,h))
#h, w = image.shape[:2]
#newcameramtx, roi = cv2.getOptimalNewCameraMatrix(camera_matrix, dist, (w,h), 1, (w,h))
# undistort
dst = cv2.undistort(image, camera_matrix, dist, None, newcameramtx)
#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]
#x, y, w, h = roi
#dst = dst[y:y+h, x:x+w]
dst = cv2.cvtColor(dst, cv2.COLOR_BGR2GRAY)
grey = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
print(dst)
print(grey)
cv2.imshow("frame", dst)
cv2.waitKey(1)
cv2.imshow("frame", grey)
cv2.waitKey(0)
output = detector.detect(dst, estimate_tag_pose=False, camera_params=None, tag_size=None)
output = detector.detect(grey, estimate_tag_pose=False, camera_params=None, tag_size=None)
print(output)

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB