Comments (2)
i find this question is caused by the .toimagemsg() function not work. it seems is due to the encoding stratage. the depth image encoding is 32FC1. dose the cv bridge support this encoding stratage? the imshow() seems ok,but the ros publish image is false , and i use the ubuntu 20.04 ,ros noetic.
`void DroneDetector::rcvDepthImgCallback(const sensor_msgs::ImageConstPtr& depth_img)
{
/* get depth image */
cv_bridge::CvImagePtr cv_ptr;
cv_ptr = cv_bridge::toCvCopy(depth_img, depth_img->encoding);
cv_ptr->image.copyTo(depth_img_);
// cv::Mat depth_img_ = cv_bridge::toCvShare(depth_img)->image;
debug_start_time_ = ros::Time::now();
Eigen::Vector2i true_pixel[max_drone_num_]; //数组
for (int i = 0; i < max_drone_num_; i++) {
if (in_depth_[i]) {
detect(i, true_pixel[i]);
}
}
cv_bridge::CvImage out_msg;
for (int i = 0; i < max_drone_num_; i++) {
if (in_depth_[i]) {
// erase hit pixels in depth
for(int k = 0; k < int(hit_pixels_[i].size()); k++) {
// depth_img_.at(hit_pixels_[i]k, hit_pixels_[i]k) = 0;
uint16_t row_ptr;
row_ptr = depth_img_.ptr<uint16_t>(hit_pixels_[i]k);
((row_ptr+hit_pixels_[i]k)) = 0.0;
// std::cout << "remove ______" <<std::endl;
}
}
}
cv::imshow("Image Viewer", depth_img);
cv::waitKey(10);
// depth_img
debug_end_time = ros::Time::now();
// ROS_WARN("cost_total_time = %lf", (debug_end_time - debug_start_time).toSec()*1000.0);
out_msg.header = depth_img->header;
out_msg.encoding = depth_img->encodingsss;
// std::cout << "remove __________"<< out_msg.encoding <<std::endl;
out_msg.image = depth_img.clone();
// sensor_msgs::ImagePtr modified_depth_msg = cv_bridge::CvImage(depth_img->header, "32FC1", depth_img_).toImageMsg();
new_depth_img_pub_.publish(out_msg.toImageMsg());
std_msgs::String msg;
std::stringstream ss;
if(debug_flag_) {
for (int i = 0; i < max_drone_num_; i++) {
if (in_depth_[i]) {
// add bound box in colormap
// cv::Rect rect(bbox_lu.x, bbox_lu.y, bbox_rd.x, bbox_rd.y);//左上坐标(x,y)和矩形的长(x)宽(y)
cv::rectangle(depth_img, cv::Rect(searchbox_lu[i], searchbox_rd[i]), cv::Scalar(0, 0, 0), 5, cv::LINE_8, 0);
cv::rectangle(depth_img, cv::Rect(boundingbox_lu_[i], boundingbox_rd_[i]), cv::Scalar(0, 0, 0), 5, cv::LINE_8, 0);
if (debug_detect_result_[i] == 1) {
ss << "no enough " << hit_pixels_[i].size();
} else if(debug_detect_result_[i] == 2) {
ss << "success";
}
} else {
ss << "no detect";
}
}
out_msg.header = depth_img->header;
out_msg.encoding = depth_img->encoding;
out_msg.image = depth_img_.clone();
debug_depth_img_pub_.publish(out_msg.toImageMsg());
msg.data = ss.str();
debug_info_pub_.publish(msg);
}
}`
from ego-planner-v2.
This part of code may help:
from ego-planner-v2.
Related Issues (20)
- Hardware list HOT 1
- Running the RVIZ node does not load the preset white grid
- Drone movement is too aggressive HOT 34
- Why is multi-threaded spinner not used? HOT 12
- How is 3d point converted to 1D representation in buffer HOT 2
- 2D planning? HOT 3
- Planner not planning the path and not stopping the drone at the end of trajectory HOT 7
- few questions related to inter drone communication HOT 10
- Planner Unable to create plan in case of wide obstacles HOT 5
- If the given target point only changes the z axis, no one will be able to rotate and rise. Is this a bug? HOT 1
- software of FMU
- The optimized trajectories will collide with obstacles HOT 9
- Sorry for a meaningless pull request
- Localization and drift correction HOT 1
- ID identification problem between drones
- Sub-optimal paths when planning around obstacles
- Drone node died when checkcollisionCallback and replan traj call planfromlocaltraj at the same time
- How to ensure the dynamics feasibility in trajectory optimization?
- Yaw will step violently in the beginning of the planning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ego-planner-v2.