-
Notifications
You must be signed in to change notification settings - Fork 0
Line detection colorimg #3
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: main
Are you sure you want to change the base?
Conversation
…d x vector chosen to be the vector 90 degrees on z vector and rotated by angle about z vector
…publisher outside the sync checks
…orks well in good ligting, but when it is covered by a shadow the edge detection does not detect shit roflcopter
pointcloud_pub_ = this->create_publisher<sensor_msgs::msg::PointCloud2>( | ||
"point_cloud", 10); | ||
line_pose_pub_ = this->create_publisher<geometry_msgs::msg::PoseStamped>( | ||
"line_pose", 10); | ||
"valve_pose", 10); | ||
line_points_pub_ = this->create_publisher<sensor_msgs::msg::PointCloud2>( | ||
"line_points", 10); | ||
near_plane_cloud_pub_ = | ||
this->create_publisher<sensor_msgs::msg::PointCloud2>( | ||
"near_plane_cloud", 10); | ||
canny_debug_image_pub_ = this->create_publisher<sensor_msgs::msg::Image>( | ||
"canny_valve_detection_image", 10); | ||
} |
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.
I would be mindful about the buffer size here and qos here. For image streams the best effort qos variable you defined over should be good instead
void ValveDetectionNode::process_and_publish_image( | ||
const sensor_msgs::msg::Image::ConstSharedPtr& image, | ||
const sensor_msgs::msg::Image::ConstSharedPtr& depth_image, | ||
const sensor_msgs::msg::Image::ConstSharedPtr& color_image, | ||
const vision_msgs::msg::Detection2DArray::ConstSharedPtr& detections) { |
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.
This method is very long, has too many indentations and does a lot of stuff. For a reader it is not so easy to see what is going on. I would suggest to look at these points that could improve the code readability and maintainability, and maybe also performance improvements.
Avoid unnecessary nesting:
Instead of
if (!condition) {
// Continue with stuff
}
you can do
if (condition) {
return; // or handle it in other ways
}
// Continue with stuff
This is especially nice for the reader since they don't have to keep track of the condition when reading the code.
Variable naming
Clear and more explanatory names are also something that ups the overall readability of the code, and makes it easier for readers to easier understand it. Although you have some good and clear names, there are some that can be improved. For instance cx
, cy
, dx
, dy
, x
, y
. It isnt easy to immediately see what they represent, even with context.
Helper functions
Well-named helper functions make the code easier to read and maintain. They are also following the single-responsibility principle that says that each function has one job.
Example:
float distance =
std::abs(coefficients->values[0] * point.x +
coefficients->values[1] * point.y +
coefficients->values[2] * point.z +
coefficients->values[3]) /
std::sqrt(coefficients->values[0] *
coefficients->values[0] +
coefficients->values[1] *
coefficients->values[1] +
coefficients->values[2] *
coefficients->values[2]);
could be a helper function. If a code block is repeated, then you could think about generalizing it as a helper function.
Use functions from the Standard Library / CV
There are a lot of nice algorithms and function from both the STL and CV, which can replace the longer and nested for loops
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 2 2
Lines 256 335 +79
Branches 21 29 +8
=====================================
- Misses 256 335 +79
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
line detection tuned for office, needs good lighting.