-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing X and Y Coordinate Offsets in AprilTag Detection with Intel RealSense #12952
Comments
Hi @iamstrang3 If you have access to the RealSense Viewer tool then you could first try resetting the camera to its factory-new default calibration settings using the instructions at #10182 (comment) in order to eliminate the possibility of a mis-calibration in your camera's sensors. Mis-calibration can occur if the camera receives a physical shock such as a hard knock, a drop on the ground or severe vibration. |
Thank you for the response. I did the steps exactly as mentioned. But I still don't get the right coordinates. |
If the camera's projector is enabled then its IR emitter (which projects a pattern of dots onto the scene) may make fiducial image markers like apriltags harder for the camera to read by overlaying dots on the tag image. So please try making sure that the emitter is disabled by using the Python code at #10065 (comment) in order to eliminate the dot pattern as a potential cause of inaccuracy. |
Hi @iamstrang3 Do you require further assistance with this case, please? Thanks! |
Hi, sorry for the late reply. I tried to add those lines in my code but it did not help. I am getting the right coordinates at a certain distance then the error keeps increasing with distance. |
At what distance does the increase in error start becoming noticeable? It is normal for error to be near zero at the camera and increase linearly as the distance of an observed object / surface from the camera increases. This phenomenon is called RMS Error and becomes noticeable on the D435i model beyond 3 meters distance from the camera. |
I have the D435 model and the error is seen within a meter distance from the camera. Also the distance is almost accurate but the problem is with the conversion from pixel to 3d coordinates. |
Is it possible to make the AprilTags larger to test whether moving the camera further away makes the tags more difficult for the camera to read? |
The camera read the april tag just fine at larger distances. |
I note that you are using 640x480 resolution. As resolution is reduced, depth accuracy also reduces. For the D435 camera model, 848x480 is the optimal resolution for depth accuracy. Does accuracy improve at distance if you use 848x480 and 30 FPS for both depth and color streams if possible? This configuration will only be supported on a USB 3.2 connection, whilst a USB 2.1 connection is only able to use 640x480 at 30 FPS. |
I get the same coordinates after changing the resolution too. Difference was in 1 or 2 mm. |
Is there any improvement when observing the tags at 1 meter range if you maximize the Sharpness of the color image? Python code for doing so can be found at #11912 (comment) |
Hi @iamstrang3 Do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
Issue Description
I am using an Intel RealSense D435 series camera with Python to detect AprilTags and calculate their 3D coordinates. I am experiencing consistent offsets in the X and Y coordinates of the detected tags, which results in inaccuracies in the computed 3D positions. I am aligning the depth and color streams. This issue is affecting the precision of my robotic arm's movements, which rely on these coordinates. I have reviewed the SDK examples and documentation, but I have not found a clear solution to this problem.
Thank you!
Below is the code I am using:
import cv2
import numpy as np
import pyrealsense2 as rs
from pupil_apriltags import Detector
import time
Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
Start the camera
pipeline.start(config)
Initialize the AprilTag detector
detector = Detector(families='tag36h11', nthreads=4, quad_decimate=1.0,
quad_sigma=0.0, refine_edges=1, decode_sharpening=0.25, debug=0)
Create an align object
align = rs.align(rs.stream.color)
Get the intrinsic parameters of the aligned color camera
profile = pipeline.get_active_profile()
color_profile = rs.video_stream_profile(profile.get_stream(rs.stream.color))
intrinsics = color_profile.get_intrinsics()
Define init_pos correctly as a 1D array
init_pos = np.array([2.88055450e-01, 1.34160019e-18, 8.83400061e-02])
print("Waiting for 5 seconds to stabilize...")
time.sleep(5)
print("Starting frame processing...")
try:
while True:
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
depth_frame = aligned_frames.get_depth_frame()
color_frame = aligned_frames.get_color_frame()
finally:
pipeline.stop()
cv2.destroyAllWindows()
The text was updated successfully, but these errors were encountered: