Skip to content
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

How can I execute the box_dimensioner_multicam_demo.py for ROS communication? #2855

Closed
kevinDrawn opened this issue Aug 23, 2023 · 10 comments
Closed
Labels

Comments

@kevinDrawn
Copy link

kevinDrawn commented Aug 23, 2023

My Ros environment is Ubuntu 18.04 Melodic. And Depth Camera Model is D405.

I want to run the code "box_dimensioner_multicam_demo.py" for Box dimensions calculation.

I want to communicate 3D object information within ROS. (Width, Length, Height)

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python/examples/box_dimensioner_multicam

#11157

Realsense Camera 3D Object Detection

@MartyG-RealSense
Copy link
Collaborator

Hi @kevinDrawn Pyrealsense2 code can be run from ROS as a node script. An example of such a script provided by the ROS wrapper is show_center_depth.py, which displays the depth value at the center of the camera's view.

https://github.com/IntelRealSense/realsense-ros/blob/ros2-development/realsense2_camera/scripts/show_center_depth.py

The command below demonstrates how to run the node script.

python src/realsense/realsense2_camera/scripts/show_center_depth.py --all

@kevinDrawn
Copy link
Author

kevinDrawn commented Aug 27, 2023

Hello! Thanks your reply.
I'm struggling to try the python code "the box_dimensioner_multicam_demo.py"
I did the command you suggested.

cd ~/Documents/librealsense-2.51.1/wrappers/python/examples/box_dimensioner_multicam
python3 box_dimensioner_multicam_demo.py --all

And then, the below command was came out.

1 devices have been found
Place the chessboard on the plane where the object needs to be detected..
Place the chessboard on the plane where the object needs to be detected..
RMS error for calibration with device number 128422271045 is : 0.00477936051841 m
Calibration completed... 
Place the box in the field of view of the devices...

This command are given the instruction to place an object on the checkerboard, but the grid is not being generated even when I place the object. How can I proceed?

image

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Aug 27, 2023

The box_dimensioner_multicam example has a 'sweet spot' distance to place the camera away from the chessboard. The program may not work as expected if the camera is at a distance outside of that range. Placing the camera between 0.5 and 1 meters from the chessboard is likely to work best.

@kevinDrawn
Copy link
Author

kevinDrawn commented Aug 27, 2023

  1. Is it acceptable to set the distance to objects from 50cm to 100cm, even though the ideal depth measurement range for the d405 camera is 7 to 50cm? I'm conducting an experiment, and the camera only seems to recognize objects when fingers are brought close, as shown in the image below.

  2. I'm also curious whether the camera needs to remain in a fixed position while recognizing the checkerboard and obtaining object volume information.0

  3. it's possible to enclose the object in a rectangular box without using a checkerboard.

image

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Aug 27, 2023

box_dimensioner_multicam was written years before the D405 model was released. Whilst most 400 Series cameras use the same depth unit scale of '0.001', the D405 uses a different depth scale of 0.01 because it is designed for short-range capture. It is possible to change the default depth scale of the camera with program scripting. Python code for doing so with the rs.option.depth_units instruction is at IntelRealSense/librealsense#10973

The camera should be in a fixed position, yes.

It is possible to use box_dimensioner_multicam without the chessboard when only using one camera with it. Details about doing so can be found at IntelRealSense/librealsense#9951 (comment)

@kevinDrawn
Copy link
Author

kevinDrawn commented Aug 29, 2023

Where do i modify for setting the depth scale of the camera??

box_dimensioner_multicam_demo.py ? Or realsense_device_manager.py ?

I added the code line in the 'realsense_device_manager.py'.

def enable_emitter(self, enable_ir_emitter=True):
...
sensor=device.pipline_profile.get_device().first_depth_sensor()
sensor.set_option(rs.option.depth_units, 0.01)
...
Thank you a lot.

@MartyG-RealSense
Copy link
Collaborator

realsense_device_manager.py would be the appropriate file to make the edit in, yes, as it handles the camera device.

The scale would be set to 0.001 rather than 0.01, as the D405's scale is already 0.01 by default and so you would not be changing anything by using 0.01.

@kevinDrawn
Copy link
Author

Thank you Bro!! I solve my problem!

@MartyG-RealSense
Copy link
Collaborator

That's great to hear that you have a solution. Thanks very much for the update!

@MartyG-RealSense
Copy link
Collaborator

Case closed due to solution achieved and no further comments received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants