-
Notifications
You must be signed in to change notification settings - Fork 6
2D->3D detection to pointcloud new pipeline #94
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
base: master
Are you sure you want to change the base?
Changes from 39 commits
6e7d5f4
96a8ce2
2ccc003
4782ec0
7a72f40
9844303
970078f
4252c39
d117ba6
6f62a5a
bf03804
913d02a
d1c8fab
37eda3d
aae3dab
ef905cd
f84f153
5264017
9fe979d
0af0aaf
046e257
cd350be
0342e9e
5730d57
23d5d85
6d52901
540ee56
8c50423
6aadaab
df14783
b15d832
8f82ba0
f77fc9c
61fe7e4
08658a0
d103982
58f4df7
70aa2ad
7a2532c
7a5dff6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,29 @@ | ||||||||||||||||||||
cmake_minimum_required(VERSION 3.0.2) | ||||||||||||||||||||
cmake_minimum_required(VERSION 3.5) | ||||||||||||||||||||
project(ed_sensor_integration) | ||||||||||||||||||||
|
||||||||||||||||||||
add_compile_options(-Wall -Werror=all) | ||||||||||||||||||||
add_compile_options(-Wextra -Werror=extra) | ||||||||||||||||||||
|
||||||||||||||||||||
#add_compile_options(-Wall -Werror=all) | ||||||||||||||||||||
#add_compile_options(-Wextra -Werror=extra) | ||||||||||||||||||||
|
||||||||||||||||||||
# -------------- ONNXRuntime Setup (define this early) ------------------# | ||||||||||||||||||||
set(ONNXRUNTIME_VERSION 1.21.1) | ||||||||||||||||||||
set(ONNXRUNTIME_ROOT "/home/amigo/Documents/repos/hero_sam.bak/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}") | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded absolute paths make the build non-portable. Use environment variables, find_package, or relative paths to make the build system more flexible and portable across different systems.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||
|
||||||||||||||||||||
# -------------- Neural Network Models ------------------# | ||||||||||||||||||||
|
||||||||||||||||||||
# Copy model files to the same folder as the executables | ||||||||||||||||||||
#configure_file(/home/amigo/Documents/repos/hero_sam.bak/yolo_inference/data/coco.yaml ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/coco.yaml COPYONLY) | ||||||||||||||||||||
#configure_file(/home/amigo/Documents/repos/hero_sam.bak/yolo_inference/model/yolo11m.onnx ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/yolo11m.onnx COPYONLY) | ||||||||||||||||||||
# configure_file(/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model/SAM_mask_decoder.onnx ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/SAM_mask_decoder.onnx COPYONLY) | ||||||||||||||||||||
# configure_file(/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model/SAM_encoder.onnx ${CATKIN_DEVEL_PREFIX}/lib/ed_sensor_integration/SAM_encoder.onnx COPYONLY) | ||||||||||||||||||||
#OR | ||||||||||||||||||||
# Define model paths | ||||||||||||||||||||
set(YOLO_MODELS_PATH "/home/amigo/Documents/repos/hero_sam.bak/yolo_inference/model") | ||||||||||||||||||||
set(SAM_MODELS_PATH "/home/amigo/Documents/repos/hero_sam.bak/sam_inference/model") | ||||||||||||||||||||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard-coded absolute paths make the build non-portable. These paths should be configurable through environment variables or CMake cache variables, e.g., Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded absolute paths make the build non-portable. Use environment variables, find_package, or relative paths to make the build system more flexible and portable across different systems.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||
|
||||||||||||||||||||
# Make these paths available to the C++ code | ||||||||||||||||||||
add_definitions(-DYOLO_MODELS_PATH="${YOLO_MODELS_PATH}") | ||||||||||||||||||||
add_definitions(-DSAM_MODELS_PATH="${SAM_MODELS_PATH}") | ||||||||||||||||||||
|
||||||||||||||||||||
find_package(OpenCV REQUIRED) | ||||||||||||||||||||
find_package(PCL REQUIRED COMPONENTS common kdtree) | ||||||||||||||||||||
|
@@ -21,6 +42,13 @@ find_package(catkin REQUIRED COMPONENTS | |||||||||||||||||||
tue_config | ||||||||||||||||||||
tue_filesystem | ||||||||||||||||||||
visualization_msgs | ||||||||||||||||||||
# 2D -> 3D point cloud estimation | ||||||||||||||||||||
yolo_onnx_ros | ||||||||||||||||||||
sam_onnx_ros | ||||||||||||||||||||
bmm_ros | ||||||||||||||||||||
# For displaying SAM MASK | ||||||||||||||||||||
cv_bridge | ||||||||||||||||||||
image_transport | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
|
@@ -29,8 +57,14 @@ find_package(catkin REQUIRED COMPONENTS | |||||||||||||||||||
|
||||||||||||||||||||
catkin_package( | ||||||||||||||||||||
INCLUDE_DIRS include | ||||||||||||||||||||
LIBRARIES ed_kinect | ||||||||||||||||||||
CATKIN_DEPENDS code_profiler ed ${PROJECT_NAME}_msgs geolib2 image_geometry rgbd rgbd_image_buffer roscpp tue_config visualization_msgs | ||||||||||||||||||||
LIBRARIES | ||||||||||||||||||||
ed_kinect | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_association | ||||||||||||||||||||
ed_laser | ||||||||||||||||||||
CATKIN_DEPENDS | ||||||||||||||||||||
code_profiler ed ${PROJECT_NAME}_msgs geolib2 image_geometry rgbd rgbd_image_buffer roscpp tue_config visualization_msgs | ||||||||||||||||||||
sam_onnx_ros bmm_ros cv_bridge image_transport | ||||||||||||||||||||
DEPENDS OpenCV PCL | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -43,14 +77,17 @@ include_directories( | |||||||||||||||||||
SYSTEM | ||||||||||||||||||||
${OpenCV_INCLUDE_DIRS} | ||||||||||||||||||||
${catkin_INCLUDE_DIRS} | ||||||||||||||||||||
${ONNXRUNTIME_ROOT}/include | ||||||||||||||||||||
|
||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
# LIBRARIES | ||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
add_library(${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
# Foward geolib2 and tue_filesystem logging to rosconsole | ||||||||||||||||||||
src/rosconsole_bridge.cpp | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -60,24 +97,34 @@ add_library(ed_association | |||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
add_library(ed_kinect | ||||||||||||||||||||
include/ed/kinect/association.h | ||||||||||||||||||||
include/ed/kinect/beam_model.h | ||||||||||||||||||||
include/ed/kinect/entity_update.h | ||||||||||||||||||||
include/ed/kinect/fitter.h | ||||||||||||||||||||
include/ed/kinect/mesh_tools.h | ||||||||||||||||||||
include/ed/kinect/renderer.h | ||||||||||||||||||||
include/ed/kinect/segmenter.h | ||||||||||||||||||||
include/ed/kinect/updater.h | ||||||||||||||||||||
|
||||||||||||||||||||
src/kinect/association.cpp | ||||||||||||||||||||
src/kinect/beam_model.cpp | ||||||||||||||||||||
src/kinect/fitter.cpp | ||||||||||||||||||||
src/kinect/mesh_tools.cpp | ||||||||||||||||||||
src/kinect/renderer.cpp | ||||||||||||||||||||
src/kinect/segmenter.cpp | ||||||||||||||||||||
src/kinect/updater.cpp | ||||||||||||||||||||
) | ||||||||||||||||||||
target_link_libraries(ed_kinect ${PROJECT_NAME}_console_bridge ed_association ${OpenCV_LIBRARIES} ${catkin_LIBRARIES}) | ||||||||||||||||||||
include/ed/kinect/association.h | ||||||||||||||||||||
include/ed/kinect/beam_model.h | ||||||||||||||||||||
include/ed/kinect/entity_update.h | ||||||||||||||||||||
include/ed/kinect/fitter.h | ||||||||||||||||||||
include/ed/kinect/mesh_tools.h | ||||||||||||||||||||
include/ed/kinect/renderer.h | ||||||||||||||||||||
include/ed/kinect/segmenter.h | ||||||||||||||||||||
include/ed/kinect/updater.h | ||||||||||||||||||||
src/kinect/association.cpp | ||||||||||||||||||||
src/kinect/beam_model.cpp | ||||||||||||||||||||
src/kinect/fitter.cpp | ||||||||||||||||||||
src/kinect/mesh_tools.cpp | ||||||||||||||||||||
src/kinect/renderer.cpp | ||||||||||||||||||||
src/kinect/segmenter.cpp | ||||||||||||||||||||
src/kinect/updater.cpp | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
add_library(ed_sam_segment_module | ||||||||||||||||||||
include/ed_sensor_integration/kinect/segmodules/sam_seg_module.h | ||||||||||||||||||||
src/kinect/sam_seg_module.cpp | ||||||||||||||||||||
) | ||||||||||||||||||||
target_link_libraries(ed_kinect | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_association | ||||||||||||||||||||
ed_sam_segment_module | ||||||||||||||||||||
${OpenCV_LIBRARIES} | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
add_dependencies(ed_kinect ${catkin_EXPORTED_TARGETS}) | ||||||||||||||||||||
|
||||||||||||||||||||
add_library(ed_laser | ||||||||||||||||||||
|
@@ -93,28 +140,36 @@ add_dependencies(ed_laser ${catkin_EXPORTED_TARGETS}) | |||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
|
||||||||||||||||||||
add_library(ed_kinect_plugin | ||||||||||||||||||||
src/kinect/kinect_plugin.cpp | ||||||||||||||||||||
src/kinect/kinect_plugin.h | ||||||||||||||||||||
src/kinect/ray_tracer.cpp | ||||||||||||||||||||
src/kinect/ray_tracer.h | ||||||||||||||||||||
src/kinect/kinect_plugin.cpp | ||||||||||||||||||||
src/kinect/kinect_plugin.h | ||||||||||||||||||||
src/kinect/ray_tracer.cpp | ||||||||||||||||||||
src/kinect/ray_tracer.h | ||||||||||||||||||||
) | ||||||||||||||||||||
target_link_libraries(ed_kinect_plugin ${PROJECT_NAME}_console_bridge ed_kinect ${catkin_LIBRARIES}) | ||||||||||||||||||||
|
||||||||||||||||||||
target_link_libraries(ed_kinect_plugin | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_kinect | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
add_dependencies(ed_kinect_plugin ${catkin_EXPORTED_TARGETS}) | ||||||||||||||||||||
|
||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
|
||||||||||||||||||||
add_library(ed_laser_plugin | ||||||||||||||||||||
src/laser/laser_plugin.cpp | ||||||||||||||||||||
src/laser/laser_plugin.h | ||||||||||||||||||||
src/laser/laser_plugin.cpp | ||||||||||||||||||||
src/laser/laser_plugin.h | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
target_link_libraries(ed_laser_plugin ${PROJECT_NAME}_console_bridge ed_laser ed_association ${catkin_LIBRARIES}) | ||||||||||||||||||||
|
||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
|
||||||||||||||||||||
add_library(ed_clearer_plugin | ||||||||||||||||||||
src/clearer/clearer_plugin.cpp | ||||||||||||||||||||
src/clearer/clearer_plugin.h | ||||||||||||||||||||
src/clearer/clearer_plugin.cpp | ||||||||||||||||||||
src/clearer/clearer_plugin.h | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
target_link_libraries(ed_clearer_plugin ${catkin_LIBRARIES}) | ||||||||||||||||||||
|
||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
|
@@ -126,13 +181,26 @@ target_link_libraries(ed_image_saver ${catkin_LIBRARIES}) | |||||||||||||||||||
add_dependencies(ed_image_saver ${catkin_EXPORTED_TARGETS}) | ||||||||||||||||||||
|
||||||||||||||||||||
add_executable(ed_segmenter tools/segmenter.cpp) | ||||||||||||||||||||
target_link_libraries(ed_segmenter ed_kinect ${catkin_LIBRARIES}) | ||||||||||||||||||||
target_link_libraries(ed_segmenter | ||||||||||||||||||||
ed_kinect | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
add_executable(ed_fitter_data tools/fitter_viz_data.cpp) | ||||||||||||||||||||
target_link_libraries(ed_fitter_data ${PROJECT_NAME}_console_bridge ed_kinect ${OpenCV_LIBRARIES} ${catkin_LIBRARIES}) | ||||||||||||||||||||
target_link_libraries(ed_fitter_data | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_kinect | ||||||||||||||||||||
${OpenCV_LIBRARIES} | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
add_executable(ed_fitter_live tools/fitter_viz_live.cpp) | ||||||||||||||||||||
target_link_libraries(ed_fitter_live ${PROJECT_NAME}_console_bridge ed_kinect ${OpenCV_LIBRARIES} ${catkin_LIBRARIES}) | ||||||||||||||||||||
target_link_libraries(ed_fitter_live | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_kinect | ||||||||||||||||||||
${OpenCV_LIBRARIES} | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
# ------------------------------------------------------------------------------------------------ | ||||||||||||||||||||
# Install | ||||||||||||||||||||
|
@@ -179,11 +247,18 @@ if (CATKIN_ENABLE_TESTING) | |||||||||||||||||||
catkin_add_catkin_lint_test("-W2 --ignore HEADER_OUTSIDE_PACKAGE_INCLUDE_PATH") | ||||||||||||||||||||
|
||||||||||||||||||||
catkin_add_gtest(test_furniture_fitting test/test_furniture_fit.cpp) | ||||||||||||||||||||
target_link_libraries(test_furniture_fitting ${PROJECT_NAME}_console_bridge ed_kinect ${OpenCV_LIBRARIES} ${catkin_LIBRARIES}) | ||||||||||||||||||||
target_link_libraries(test_furniture_fitting | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_kinect | ||||||||||||||||||||
${OpenCV_LIBRARIES} | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
catkin_add_gtest(test_laser_fitting test/test_laser_segmenter.cpp) | ||||||||||||||||||||
target_link_libraries(test_laser_fitting ${PROJECT_NAME}_console_bridge ed_laser ${OpenCV_LIBRARIES} ${catkin_LIBRARIES}) | ||||||||||||||||||||
target_link_libraries(test_laser_fitting | ||||||||||||||||||||
${PROJECT_NAME}_console_bridge | ||||||||||||||||||||
ed_laser | ||||||||||||||||||||
${OpenCV_LIBRARIES} | ||||||||||||||||||||
${catkin_LIBRARIES} | ||||||||||||||||||||
) | ||||||||||||||||||||
endif () | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <ros/ros.h> | ||
#include "yolo_inference.h" | ||
#include "sam_inference.h" | ||
#include <sensor_msgs/Image.h> | ||
#include <sensor_msgs/PointCloud2.h> | ||
#include <opencv2/core.hpp> | ||
//#include "ed/kinect/entity_update.h" | ||
#include <cv_bridge/cv_bridge.h> | ||
#include <geolib/sensors/DepthCamera.h> | ||
#include <geolib/Shape.h> | ||
#include <pcl/point_types.h> | ||
#include <pcl/point_cloud.h> | ||
#include <pcl/segmentation/extract_clusters.h> | ||
#include <pcl_conversions/pcl_conversions.h> | ||
#include <sensor_msgs/Image.h> | ||
#include <sensor_msgs/PointCloud2.h> | ||
|
||
// EntityUpdate and UpdateResult come from kinect (avoid including laser variant to prevent redefinition) | ||
#include <ed/kinect/entity_update.h> | ||
#include <ed/kinect/segmenter.h> // defines UpdateResult (and possibly other needed types) | ||
|
||
/** | ||
* @brief Segmentation pipeline that processes the input image and generates segmentation masks. | ||
* | ||
* @param img The input RGB image to segment. | ||
* @return std::vector<cv::Mat> The generated segmentation masks. | ||
*/ | ||
std::vector<cv::Mat> SegmentationPipeline(const cv::Mat& img); | ||
|
||
/** | ||
* @brief Overlay segmentation masks on the RGB image for visualization purposes. | ||
* | ||
* @param rgb The RGB image to overlay masks on. | ||
* @param masks The segmentation masks to overlay. | ||
*/ | ||
void overlayMasksOnImage_(cv::Mat& rgb, const std::vector<cv::Mat>& masks); | ||
|
||
/** | ||
* @brief Publish segmentation results and pointcloud estimation as ROS messages. | ||
* | ||
* @param filtered_depth_image The filtered depth image to publish. | ||
* @param rgb The RGB image to publish. | ||
* @param sensor_pose The pose of the sensor. | ||
* @param clustered_images The clustered segmentation masks. | ||
* @param mask_pub_ The ROS publisher for the mask images. | ||
* @param cloud_pub_ The ROS publisher for the point cloud data. | ||
* @param res_updates The entity updates to publish. | ||
*/ | ||
void publishSegmentationResults(const cv::Mat& filtered_depth_image, const cv::Mat& rgb, | ||
const geo::Pose3D& sensor_pose, std::vector<cv::Mat>& clustered_images, | ||
ros::Publisher& mask_pub_, ros::Publisher& cloud_pub_, std::vector<EntityUpdate>& res_updates); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded absolute paths make the build non-portable. These paths should be configurable through environment variables or CMake cache variables, e.g.,
set(ONNXRUNTIME_ROOT $ENV{ONNXRUNTIME_ROOT} CACHE PATH \"Path to ONNX Runtime\")
.Copilot uses AI. Check for mistakes.