You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using the pupil-apriltag to do some detection. It works well on my built-in camera on my Mac. However, when I try with my usb acr010 webcam, it doesn't work. I have calibrated my webcam and the frame shows on the windows. The frame rate is about 12, however, it doesn't detect apriltag at all.
Here below is my code that running a webcam to detect the Apriltags continuously and a simple test for one of the image that captured by my webcam.
importosimporttimeimportcv2importnumpyasnpfrompupil_apriltagsimportDetector# Camera information, NOT CONFIGURED# FPS = 50RES= (1920, 1080)
camera_info= {}
# Camera Resolutioncamera_info["res"] =RES# Camera Intrinsic Matrix (3x3)camera_info["K"] =np.array([[1129.106419355741, 0.0, 958.2530752561653],
[0.0, 1126.3550177287352, 546.954031682053],
[0.0, 0.0, 1.0]])
# Fisheye Camera Distortion Matrixcamera_info["D"] =np.array([[-0.09285509543388772],
[0.08508622717322474],
[-0.148664219994183],
[0.10812148818670442]])
# The non-default elements of the K array, in the AprilTag specificationcamera_info["params"] = [1129.106, 1126.355, 958.253, 546.954]
# Fisheye flagcamera_info["fisheye"] =Truecamera_info["map_1"], camera_info["map_2"] =cv2.fisheye.initUndistortRectifyMap(camera_info["K"], camera_info["D"],
np.eye(3), camera_info["K"],
camera_info["res"], cv2.CV_16SC2)
# Tag informationTAG_SIZE=.123FAMILIES='tag36h11'defmain():
print('\033]0;Video Base\007')
# Initialize the camera capturecamera=cv2.VideoCapture(0)
camera.set(3, RES[0]) # Set horizontal resolutioncamera.set(4, RES[1]) # Set vertical resolution# Configure the AprilTags detectordetector=Detector(families=FAMILIES, nthreads=4)
# Initialize variables for calculating frame ratestart_time=time.time()
frame_count=0whileTrue:
# Capture frame from the cameraret, frame=camera.read()
# Undistort the frame# frame = cv2.remap(frame, camera_info["map_1"], camera_info["map_2"], interpolation=cv2.INTER_LINEAR,# borderMode=cv2.BORDER_CONSTANT)# Convert the frame to grayscalegray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Detect AprilTags in the grayscale imageresults=detector.detect(gray, estimate_tag_pose=True, camera_params=camera_info["params"], tag_size=TAG_SIZE)
detected_tags= [tag.tag_idfortaginresults]
# Draw bounding boxes and IDs on the framefortaginresults:
# Add bounding rectanglecv2.polylines(frame, [np.int32(tag.corners)], True, (0, 255, 0), thickness=2)
# Add Tag ID textcv2.putText(frame, str(tag.tag_id),
org=(tag.corners[0, 0].astype(int) +10, tag.corners[0, 1].astype(int) +10),
fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=0.8,
color=(0, 0, 255),
thickness=3)
cv2.circle(frame, tuple(tag.corners[0].astype(int)), 2, color=(255, 0, 255), thickness=2)
# Display rotation and translationcv2.putText(frame, f"Rot: {tag.pose_R}",
(tag.corners[0][0].astype(int), tag.corners[0][1].astype(int) -30),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
cv2.putText(frame, f"Trans: {tag.pose_t}",
(tag.corners[0][0].astype(int), tag.corners[0][1].astype(int) -60),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
# Calculate frame rateframe_count+=1elapsed_time=time.time() -start_timefps=frame_count/elapsed_time# Display the frame rate on the framecv2.putText(frame, f"FPS: {fps:.2f}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
# Display the framecv2.imshow('AprilTags Detection', frame)
# Prepare the messagemessage= {
"badge_id": "B", # Replace with a unique ID for each badge"detected_tags": detected_tags
}
iflen(results) !=0:
print(message)
# Exit program when 'q' is pressedifcv2.waitKey(1) &0xFF==ord('q'):
break# Release the camera and close windowscamera.release()
cv2.destroyAllWindows()
if__name__=='__main__':
main()
Hi. I do not have answer to your question, but I am super curious of how did you calibrate this particular camera. Please reach me on [email protected] I have some questions.
Hi, I am using the pupil-apriltag to do some detection. It works well on my built-in camera on my Mac. However, when I try with my usb acr010 webcam, it doesn't work. I have calibrated my webcam and the frame shows on the windows. The frame rate is about 12, however, it doesn't detect apriltag at all.
Here below is my code that running a webcam to detect the Apriltags continuously and a simple test for one of the image that captured by my webcam.
The test image and the corresponding test code,
The text was updated successfully, but these errors were encountered: