luxonis / depthai-ros

Official ROS Driver for DepthAI Sensors.
MIT License
251 stars 185 forks source link

Noisy depth image from ros driver #223

Open ghost opened 1 year ago

ghost commented 1 year ago

HW Info

Camera: OAK-D-Pro-W ROS2 Version: Humble

Depth Image published by the depthai_ros_driver's camera node is very noisy when compared to the depth image shown by running the demo app

Sample, from depthai_demo.py:

Screenshot from 2023-02-07 19-40-10

Sample, from depthai-ros-driver:

Screenshot from 2023-02-07 19-41-00

Params kept consistent in both pipelines:

Median Filter (5x5) LR check: True LR Threshold: 10 Resolution: 1280x800 (L+R) Extended Disparity: False LaserDot Brightness: 500 IR FloodLight: 0

Things I've tried:

Enabling Threshold filter: Improves the quality but not by much

Enabling Spatial/Temporal filters: Improves quality slightly but introduces high latency

Changing LaserDot Brightness and enabling extended disparity: No change obsereved

Changing resolution/Median FIler Kernal size: No changes observed

Serafadam commented 1 year ago

Hi, can you post images from left/right camera as well? It can be looking at a simple white wall

ghost commented 1 year ago

Hi @Serafadam,

Thanks for your response, great work on the driver btw!

Here is a snapshot of the Depth, RIght and Left topics from the ros driver: Screenshot from 2023-02-09 11-23-11

And a snapshot in the same position (approximately) from the python api:

Screenshot from 2023-02-09 11-24-30

As you can see the python api is less noisy and note that I have used depth_preview.py which is not doing any post-processing on the host (or the device as far as I can tell).

Another note is that I have not modified the default params in the python API so I am pretty sure the lase brightness is 0 there. So I have tried launching the ros node with the brightness being 0 as well as 500 and 800; Observed no visible improvements or changes.

ghost commented 1 year ago

A quick update, I tried the same test on an OAK-D-LITE to eliminate the possibility of any hardware issues. It does seem to provide a slightly better depth image but when compared to the API, it does seem to be very noisy.

ROS Driver: Screenshot from 2023-02-09 11-46-32

API: Screenshot from 2023-02-09 11-47-43

Serafadam commented 1 year ago

Thanks for the information, could you also provide topic output when running stereo_inertial_node from depthai_examples?

ghost commented 1 year ago

Which topic(s) do you need me to capture? and would you like a bag?

Serafadam commented 1 year ago

Same, depth output, bags should be fine. You can also enable additional logs with export DEPTHAI_DEBUG=1

ghost commented 1 year ago

Here are the sanpshots, stereo_inertial_node: Screenshot from 2023-02-09 13-36-25

API: Screenshot from 2023-02-09 13-38-00

stereo_inertial_node:

Screenshot from 2023-02-09 13-40-40

Serafadam commented 1 year ago

Hm, that's a little bit weird. Could you place the camera in a fixed position, enable debug logging and post debug logs and stereo images (or rosbags) from:

ghost commented 1 year ago

Here are the logs and images:

Camera.launch.py:

Image: camera_launch

Log: camera_launch_2.log

stereo_inertial_node:

Image: stereo_inertial_node

Log: stereo_inertial_launch.log

rgbd_pcl.launch.py

Image: rgbd_pcl

Log: rgbd_pcl.log

Python API:

Image: python_api Log: python_api.log

Serafadam commented 1 year ago

Thanks for the logs, I'll try to come back at you starting next week after I go through all of them

ghost commented 1 year ago

Hi @Serafadam, any updates on this issue?

Serafadam commented 1 year ago

Hi, default config for camera.yaml has been updated a little bit, you can see if it helps. I've looked at the logs but unfortunately it's a little bit hard to analyze them since Node properties are obscured. You can try adding following lines:

    std::ofstream file("/tmp/pipeline.json");
    file << pipeline->serializeToJson()["pipeline"];

after this log line, for python add

        with open("/tmp/pipeline.json", 'w') as f:
            json.dump(self._pm.pipeline.serializeToJson()["pipeline"], f)

after this line.

ghost commented 1 year ago

Hi @Serafadam,

Here are the outputs and the json logs,

Demo App:

Screenshot from 2023-02-21 12-50-22

Log: pipeline_demo.json.log

ROS Driver:

Screenshot from 2023-02-21 12-48-46

Log: pipeline_ros.json.log

Serafadam commented 1 year ago

Hi, thanks! Notes based on those logs:

  1. It seems that in ROS depth is not aligned to RGB, is that on purpose? Default config values set RGBD alignment
  2. LRC Threshold is set to 10 in ROS, 4 in Python, although I would stick to 10.
  3. Confidence threshold is set to 245 in python, also shouldn't make a difference
  4. Threshold filter values are different but it's disabled in both pipelines anyway
  5. This one is a bigger difference - Mono Camera resolutions are set to 400 in python example and 800 in ROS-although it might seem that bigger is better, increased resolution might produce more noise depending on environment.

So, to sum up, I would try changing two parameters and see if we get the same results:

ghost commented 1 year ago

Hi, so the align_depth is purposely set to false since I will be using the Depth pipeline instead of RGBD to reduce bandwidth over USB. This should not affect the noise correct?

Reducing the resolution on the ROS does seem to improve the noise a little bit but not by much, I will test this a few more times to confirm.

And about the rendering, I did consider this, and the problem is not visual since the point cloud that is generated from the depth image is extremely noisy as well. It could be the case that the visualisation in the SDK is different and is "hiding" the noise but at the end of the day I need the noise on the ROS side to be minimal and that is the only reason for the comparison.

So apart from the resolution and depth alignment, there is nothing else that can be done to reduce the noise?

Quick note: I did notice that the streams are not rectified in the ros_driver but they seem to be in the stereo_inertial_node. And i cannot find which param to set in the camera.yaml file to set the rectification flag. So please let me know about this as well. Thanks!

Serafadam commented 1 year ago

Hi! Sorry for the delay Regarding noise, I would try playing with available filters via config files. Regarding alignment, different perspective might cause some distortions, though we'll be adding additional filtering for that in near future. Additionally, you can enable subpixel mode in newest humble release if you don't use NNs at the same time (this is a bug occuring with depthai v2.19, it's fixed in newest release). Additionally, there is a WLS based filtering node in progress that should be added soon. Regarding rectified streams from stereo, it's in the backlog and will be added probably at the same time as WLS filter - those functionalities are already coded in, but they've been postponed due to other tasks taking priority.

RemiFabre commented 1 year ago

@AJsamk did you fix your issue? I believe I have the same situation. I'm using an OAK-D, the outputs for the depthai_demo.py are clean, but I get a lot of noise when using the ROS driver.

This also seems linked to #214. For reference, my point cloud looks like this: image

Best,

Serafadam commented 1 year ago

Hi, are you using default config files? Regarding previous post - we've recently updated our docs on depth tuning, you can find more information here, hope that helps. WLS filter feature was delayed a little bit, but soon it's going to be added as part of new depthai_filters package

RemiFabre commented 1 year ago

Hi, Yes, I'm using the default config files. I'll update this thread if I have an improvement

Serafadam commented 1 year ago

Hi, WLS filter example has been added in https://github.com/luxonis/depthai-ros/pull/247

ghost commented 1 year ago

HI @Serafadam,

Thanks for the update, I tried the new PR, it does look a lot better in the stereo image as well as the filtered image, although the filtered image is too dark to see, the noise does seem improved quite a bit.

I will try and pipe the new images through to the pointcloud, since I don't see any pcl messages being published I am assuming the filter example does not add that component. Hopefully there will be low to no noise in the pcl.

Screenshot from 2023-03-30 13-46-21

LanWu076 commented 1 year ago

Hi @Serafadam,

Thank you for the updates. I have tried the latest noetic branch (not the 271_neotic). It seems the same issue remaining in the noetic version. The point cloud is okay when running the depthai_example but extremely noisy when running the depthai_ros_driver.

depthai_example (side view) it is okay Screenshot from 2023-04-14 16-00-35

depthai_ros_driver(side view) it is noisy Screenshot from 2023-04-14 15-59-53

depthai_example (top view) it is okay Screenshot from 2023-04-14 16-00-54

depthai_ros_driver(top view) it is noisy, even travel through the wall Screenshot from 2023-04-14 16-00-06

I tried to enable the filtering based on the default config file (camera.yaml). It does not affect the performance.

roboav8r commented 10 months ago

Hi all, I'm getting a similar issue when running camera.launch.py. The demo script looks like this: Screenshot from 2023-11-08 18-35-38 But the output from camera.launch.py when running RGBD and mobilenet looks like this: Screenshot from 2023-11-08 18-46-01

I first noticed this because my detections were incorrect, and found this issue as a possible culprit. For example, I was sitting at (0,0,8) but /oak/nn/spatial_detections/.../position was showing (-2.9, 1.2, 6.0). I tried:

Happy to help find the cause, @Serafadam please let me know if there is anything I can do.

Serafadam commented 10 months ago

Hi @roboav8r, one of the changes regarding ROS camera is subpixel mode, you can enable it by setting stereo.i_subpixel: true parameter. Regarding detection results, could you try with setting nn.i_disable_resize: true and setting the rgb.i_preview_size to one supported by the model?

roboav8r commented 9 months ago

Thanks @Serafadam! Looks like that did the trick and it is now outputting reasonable results.

If anyone else is curious, here is my configuration:

/oak:
  ros__parameters:
    camera:
      i_enable_imu: true
      i_enable_ir: true
      i_nn_type: spatial
      i_pipeline_type: RGBD
    stereo:
      i_subpixel: true
    nn:
      i_nn_config_path: depthai_ros_driver/yolo
      i_disable_resize: true
    rgb:
      i_preview_size: 416
flabrosse commented 1 month ago

Can the stereo depth confidence threshold be changed using the ROS driver? I can't see any option that would do that.