fictionlab / ros_aruco_opencv

ROS wrapper for ArUco Opencv module
MIT License
16 stars 16 forks source link

Inaccurate #31

Open dylan-gonzalez opened 7 months ago

dylan-gonzalez commented 7 months ago

Hi there,

I have tried using your library on the humble branch, but it appears to be inaccurate by about 20cm.

I am using a ZED2i camera, and giving the rectified image of the right camera lens as input. FYI when I use the zed_aruco_localization example package, it gives detections with +- 1cm error.

Is there something I should tune?

I am using 6X6_50 dictionary.

bjsowa commented 7 months ago

when using rectified images, make sure to set image_is_rectified parameter to true. I forgot to add this parameter to example config. Let me know if it fixes the accuraccy.

dylan-gonzalez commented 7 months ago

Ah I have already set that parameter

bjsowa commented 7 months ago

Is the offset from the actual position stable? Are the axes properly aligned with the marker on /aruco_tracker/debug images?

dylan-gonzalez commented 7 months ago

The offset is stable. z-axis:

x-axis:

y-axis:

The axes seem aligned image (1) image .

bjsowa commented 7 months ago

How are you estimating the error?

Could you try opening RViz, adding TF display and Camera display (for the rectified images) and checking if the axes are correctly overlayed on the camera images?

dylan-gonzalez commented 7 months ago

I am estimating the error by measuring with a tape measure the ground truth, and then looking at the output of /aruco_opencv/aruco_detections (the z-axis mainly for now)

In this example, it is off by 10cm. It is reporting 1.26-1.29m when it is actually 1.18m The axes look to be correctly overlayed.

image

Also the camera appears to be perfectly level horizontally: PXL_20240419_082903333

PXL_20240419_082855957

dylan-gonzalez commented 7 months ago

It also does not seem to make a difference if I use rectified or un-rectified images.

dylan-gonzalez commented 7 months ago

I also noticed that zed_aruco_localization have a refine parameter that I think uses the corners of the marker to improve detection. I noticed that when I turn this parameter off, I get pretty much the same result as ros_aruco_opencv, and when it is turned on I get an error of only ~3cm.

Ah, I have found that setting this parameter to "1" (for subpixel mode) makes it accurate for my example to ~1.5cm !

But for distances at around 2m, I am now getting ~10cm error. But increasing the resolution to 1080 reduces the error back to ~2cm. So I guess it is more or less fine tuning parameters.

Edit: looks like I might have misspoke. I didn't realise that but markers are 0.15m, not 0.16m (could have sworn I printed them out as such). Pose estimation is relatively accurate at a distance of around 1m, but drops off significantly approaching 2m.

bjsowa commented 7 months ago

Ah, I have found that setting this parameter to "1" (for subpixel mode) makes it accurate for my example to ~1.5cm !

That's interesting! I used the contour corner refinement as it resulted in more stable positions and was (I think) faster. I never actually measured the pose accuracy though. If you are using subpixel refinement, you can also experiment with cornerRefinementWinSize, cornerRefinementMaxIterations and cornerRefinementMinAccuracy parameters as they are applicable in this case.

But for distances at around 2m, I am now getting ~10cm error. But increasing the resolution to 1080 reduces the error back to ~2cm. So I guess it is more or less fine tuning parameters.

This package just passes the images and detection parameters to OpenCV library that's installed on the system, so I don't have much influence on the algorithms it uses. Though, with enough feedback, I might come up with better default detection parameters.