Commit 6150ca42 authored by xin.wang.waytous's avatar xin.wang.waytous

stone-tracker-filter

parent 67f18462
rgb_sub_topic_name: /front_rgb/image rgb_sub_topic_name: /sensor/camera/front_middle/image/bgr
pointcloud_sub_topic_name: /total_calib_pointcloud pointcloud_sub_topic_name: /total_calib_pointcloud
detection_pub_topic_name: /perception/camera/obstacle detection_pub_topic_name: /perception/camera/obstacle
# static_gridmap_pub_topic_name: /perception/camera/bev_static_gridmap # static_gridmap_pub_topic_name: /perception/camera/bev_static_gridmap
...@@ -12,21 +12,17 @@ device: 0 ...@@ -12,21 +12,17 @@ device: 0
period_time: 5 period_time: 5
vis_res: true vis_res: true
vis_frame_id: Lidar vis_frame_id: Lidar
vis_project: false vis_project: true
# ["pedestrian", "two_wheel", "car", "truck", "construction_machine", "fence", "stone", "dust", "cone"] # ["pedestrian", "vehicle", "stone"]
pub_classes: ["stone", "cone"] pub_classes: ["stone", "cone"]
obstacle_height_threshold: 25 # cm obstacle_height_threshold: 5 # cm
camera_intrinsic: [1346.61241105747, 0, 951.014999441565, camera_intrinsic: [1346.61241105747, 0, 951.014999441565,
0, 1344.43795511862, 530.562496955385, 0, 1344.43795511862, 530.562496955385,
0, 0, 1] 0, 0, 1]
distortion_coefficients: [-0.449196898930979, 0.253956763950171, -0.00139403693782871, -0.00111424348026907, -0.0870171627456232] distortion_coefficients: [-0.449196898930979, 0.253956763950171, -0.00139403693782871, -0.00111424348026907, -0.0870171627456232]
# camera2lidar_extrinsic: [-0.0423904, -0.999009, 0.0135863, 0.0656235, camera2lidar_extrinsic: [ 0.0177667, -0.9994557, -0.0277972, 0.258,
# 0.0313214, -0.0149206, -0.999398, -0.167858, -0.0891004, 0.0261083, -0.9956804, 3.431,
# 0.99861, -0.0419393, 0.0319228, -0.0162872, 0.9958642, 0.0201667, -0.0885880, 0.212,
# 0, 0, 0, 1]
camera2lidar_extrinsic: [ 0.0029218, -0.9999551, 0.0090201, -0.339,
0.0170034, -0.0089692, -0.9998152, 3.404,
0.9998512, 0.0030746, 0.0169764, -0.164,
0, 0, 0, 1 ] 0, 0, 0, 1 ]
src_img_width: 1920 src_img_width: 1920
src_img_height: 1080 src_img_height: 1080
......
rgb_sub_topic_name: /sensor/camera/front_middle/image/bgr
pointcloud_sub_topic_name: /total_calib_pointcloud
detection_pub_topic_name: /camera/objects
# static_gridmap_pub_topic_name: /perception/camera/bev_static_gridmap
creator_id: 0000
creator_name: camera_bev_node
sensor_frame_id: camera_01
config_root_path: /home/nvidia/Projects/perception/ros_camera_bev/src/camera_bev_infer
#config_root_path: /home/ubuntu/projects/ros_camera_bev/src/camera_bev_infer
rgb_config_path: configs/weights/multi_yolov5m.yaml
device: 0
period_time: 5
vis_res: true
vis_frame_id: Lidar
vis_project: false
# ["pedestrian", "two_wheel", "car", "truck", "construction_machine", "fence", "stone", "dust", "cone"]
pub_classes: ["stone", "cone"]
obstacle_height_threshold: 25 # cm
camera_intrinsic: [1346.61241105747, 0, 951.014999441565,
0, 1344.43795511862, 530.562496955385,
0, 0, 1]
distortion_coefficients: [-0.449196898930979, 0.253956763950171, -0.00139403693782871, -0.00111424348026907, -0.0870171627456232]
camera2lidar_extrinsic: [ 0.0177667, -0.9994557, -0.0277972, 0.258,
-0.0891004, 0.0261083, -0.9956804, 3.431,
0.9958642, 0.0201667, -0.0885880, 0.212,
0, 0, 0, 1 ]
src_img_width: 1920
src_img_height: 1080
dst_img_width: 960
dst_img_height: 540
rgb_sub_topic_name: /sensor/camera/front_middle/image/bgr
pointcloud_sub_topic_name: /total_calib_pointcloud
detection_pub_topic_name: /camera/objects
# static_gridmap_pub_topic_name: /perception/camera/bev_static_gridmap
creator_id: 0000
creator_name: camera_bev_node
sensor_frame_id: camera_01
config_root_path: /home/nvidia/Projects/perception/ros_camera_bev/src/camera_bev_infer
#config_root_path: /home/ubuntu/projects/ros_camera_bev/src/camera_bev_infer
rgb_config_path: configs/weights/multi_yolov5m.yaml
device: 0
period_time: 5
vis_res: true
vis_frame_id: Lidar
vis_project: false
# ["pedestrian", "two_wheel", "car", "truck", "construction_machine", "fence", "stone", "dust", "cone"]
pub_classes: ["stone", "cone"]
obstacle_height_threshold: 25 # cm
camera_intrinsic: [1346.61241105747, 0, 951.014999441565,
0, 1344.43795511862, 530.562496955385,
0, 0, 1]
distortion_coefficients: [-0.449196898930979, 0.253956763950171, -0.00139403693782871, -0.00111424348026907, -0.0870171627456232]
camera2lidar_extrinsic: [ 0.0357085, -0.9993340, -0.0075053, 0.168,
-0.0840158, 0.0044816, -0.9964544, 3.492,
0.9958244, 0.0362125, -0.0837998, 0.074,
0, 0, 0, 1 ]
src_img_width: 1920
src_img_height: 1080
dst_img_width: 960
dst_img_height: 540
...@@ -28,8 +28,8 @@ units: ...@@ -28,8 +28,8 @@ units:
inputNames: [resizeNormImages] inputNames: [resizeNormImages]
outputNames: [detections, seg_protos, depths, semantics] outputNames: [detections, seg_protos, depths, semantics]
runMode: 1 # 0-fp32 1-fp16 2-int8 (int8 not supported) runMode: 1 # 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath: "configs/weights/isp_m_best.onnx" weightsPath: "configs/weights/isp_x0228m_last.onnx"
engineFile: "configs/weights/isp_m_best_fp16.engine" engineFile: "configs/weights/isp_x0228m_last_fp16.engine"
inferDynamic: false inferDynamic: false
inferBatchSize: 1 inferBatchSize: 1
inputWidth: 960 inputWidth: 960
...@@ -47,12 +47,12 @@ units: ...@@ -47,12 +47,12 @@ units:
scoreThreshold: 0.15 # used when inference, can be modified scoreThreshold: 0.15 # used when inference, can be modified
truncatedThreshold: 0.05 truncatedThreshold: 0.05
maxOutputNum: 1000 maxOutputNum: 1000
rawDetectionLength: 32130 # 25200 rawDetectionLength: 42840 # 32130
keepTopK: 100 keepTopK: 100
segProtoDim: 32 segProtoDim: 32
instanceDownScale: 4 instanceDownScale: 4
instanceClassNumber: 9 instanceClassNumber: 3
instanceClassNames: ["pedestrian", "two_wheel", "car", "truck", "construction_machine", "fence", "stone", "dust", "cone"] instanceClassNames: ["pedestrian", "vehicle", "stone"]
# semantic-seg # semantic-seg
semanticDownScale: 4 semanticDownScale: 4
semanticClassNumber: 2 semanticClassNumber: 2
...@@ -66,7 +66,7 @@ units: ...@@ -66,7 +66,7 @@ units:
outputNames: [tracked_instances] outputNames: [tracked_instances]
frame_rate: 10 frame_rate: 10
track_buffer: 30 track_buffer: 30
track_thresh: 0.2 track_thresh: 0.15
high_thresh: 0.2 high_thresh: 0.2
match_thresh: 0.6 match_thresh: 0.6
init_frames: 2 init_frames: 2
......
name: CameraModel name: CameraModel
inputNames: [cvImage] inputNames: [cvImage]
outputNames: [out_instances, out_semantics, out_depths, undistortVisImage] outputNames: [tracked_instances, out_semantics, out_depths, undistortVisImage]
units: units:
- -
...@@ -28,8 +28,8 @@ units: ...@@ -28,8 +28,8 @@ units:
inputNames: [resizeNormImages] inputNames: [resizeNormImages]
outputNames: [detections, seg_protos, depths, semantics] outputNames: [detections, seg_protos, depths, semantics]
runMode: 1 # 0-fp32 1-fp16 2-int8 (int8 not supported) runMode: 1 # 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath: "configs/weights/isp_s_best.onnx" weightsPath: "configs/weights/isp_m_best.onnx"
engineFile: "configs/weights/isp_s_best_fp16.engine" engineFile: "configs/weights/isp_m_best_fp16.engine"
inferDynamic: false inferDynamic: false
inferBatchSize: 1 inferBatchSize: 1
inputWidth: 960 inputWidth: 960
...@@ -44,7 +44,7 @@ units: ...@@ -44,7 +44,7 @@ units:
fixAspectRatio: false fixAspectRatio: false
# instance-seg # instance-seg
nmsThreshold: 0.45 nmsThreshold: 0.45
scoreThreshold: 0.2 # used when inference, can be modified scoreThreshold: 0.15 # used when inference, can be modified
truncatedThreshold: 0.05 truncatedThreshold: 0.05
maxOutputNum: 1000 maxOutputNum: 1000
rawDetectionLength: 32130 # 25200 rawDetectionLength: 32130 # 25200
...@@ -60,6 +60,17 @@ units: ...@@ -60,6 +60,17 @@ units:
# depth # depth
depthDownScale: 4 depthDownScale: 4
depthDistanceScale: 256 depthDistanceScale: 256
-
name: ByteTracker
inputNames: [out_instances]
outputNames: [tracked_instances]
frame_rate: 10
track_buffer: 30
track_thresh: 0.15
high_thresh: 0.15
match_thresh: 0.6
init_frames: 2
out_lost_threshold: 0
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @Date: 2023-09-03 01:53:20 * @Date: 2023-09-03 01:53:20
* @email: xin.wang@waytous.com * @email: xin.wang@waytous.com
* @LastEditors: wxin * @LastEditors: wxin
* @LastEditTime: 2023-12-14 07:06:26 * @LastEditTime: 2024-02-29 03:17:36
*/ */
#ifndef SENSORMANAGER_H #ifndef SENSORMANAGER_H
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @Date: 2023-09-03 03:13:41 * @Date: 2023-09-03 03:13:41
* @email: xin.wang@waytous.com * @email: xin.wang@waytous.com
* @LastEditors: wxin * @LastEditors: wxin
* @LastEditTime: 2024-01-18 04:25:22 * @LastEditTime: 2024-02-28 10:32:38
*/ */
...@@ -714,7 +714,6 @@ cv::RotatedRect Visione_3D::getObjectAreaRect(const cv::Mat& imgBin, const cv:: ...@@ -714,7 +714,6 @@ cv::RotatedRect Visione_3D::getObjectAreaRect(const cv::Mat& imgBin, const cv::
} }
} }
} }
if( vPoints.size() > 3) if( vPoints.size() > 3)
{ {
rRect = minAreaRect(vPoints); rRect = minAreaRect(vPoints);
...@@ -963,10 +962,13 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in ...@@ -963,10 +962,13 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
} }
// std::cout<<" instance find table vision "<<double(clock()-start_)/CLOCKS_PER_SEC<<"s"<<std::endl; //输出时间(单位:s) // std::cout<<" instance find table vision "<<double(clock()-start_)/CLOCKS_PER_SEC<<"s"<<std::endl; //输出时间(单位:s)
float project_ratio = project_count / (mask_count + 1e-5); float project_ratio = project_count / (mask_count + 1e-5);
bool valid = validTracks.find(obj.track_id) != validTracks.end(); if(Tracks.find(obj.track_id) == Tracks.end()){
// std::cout<<"obj: "<< obj.name <<" with project ratio: "<< project_ratio << ", " << valid << std::endl; Tracks[obj.track_id] = STrack(); // init
}
bool valid = Tracks[obj.track_id].valid;
// std::cout<<"obj: "<< obj.track_id<< ","<< obj.name <<" with project ratio: "<< project_ratio << ", " << project_count << std::endl;
if(valid){ if(valid){
validTracks[obj.track_id] = 0; // update Tracks[obj.track_id].last_update_age = 0; // update
} }
bool pointEnough = false; bool pointEnough = false;
cv::Rect objRc = cv::Rect(objX1, objY1, MIN(objBin.cols, objX2 + 1) - objX1, MIN(objBin.rows, objY2 + 1) - objY1); cv::Rect objRc = cv::Rect(objX1, objY1, MIN(objBin.cols, objX2 + 1) - objX1, MIN(objBin.rows, objY2 + 1) - objY1);
...@@ -989,82 +991,57 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in ...@@ -989,82 +991,57 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
insobj.fConfidence = obj.fConfidence; insobj.fConfidence = obj.fConfidence;
vGrid.vInsObjs.push_back(insobj); vGrid.vInsObjs.push_back(insobj);
obj.valid = obj.valid + 1; obj.valid = obj.valid + 1;
// std::cout<< obj.track_id<<"valid----------------"<<std::endl;
}else{ }else{
// std::cout<< obj.track_id<<"depth----------------"<<std::endl;
return -1; // depth estimination return -1; // depth estimination
} }
}else{ }else{
if(pointEnough) if(pointEnough)
{ {
// 静态目标根据高度差过滤误检 // 静态目标根据高度差过滤误检
bool filtered = false;
// if(std::find(perception::camera::StaticTypes.begin(), perception::camera::StaticTypes.end(), obj.name) // if(std::find(perception::camera::StaticTypes.begin(), perception::camera::StaticTypes.end(), obj.name)
// != perception::camera::StaticTypes.end()) // != perception::camera::StaticTypes.end())
if(obj.name == "stone") // 过滤多余点
{ auto bundingRect = insobj.rrc.boundingRect2f();
// 过滤多余点 for(auto iter = points3d.begin(); iter != points3d.end();){
auto bundingRect = insobj.rrc.boundingRect2f(); bool in_rect = ((iter->x <= bundingRect.x+bundingRect.width) && (iter->x >= bundingRect.x) &&
for(auto iter = points3d.begin(); iter != points3d.end();){ (iter->y <= bundingRect.y+bundingRect.height) && (iter->y >= bundingRect.y));
bool in_rect = ((iter->x <= bundingRect.x+bundingRect.width) && (iter->x >= bundingRect.x) && if(!in_rect){
(iter->y <= bundingRect.y+bundingRect.height) && (iter->y >= bundingRect.y)); iter = points3d.erase(iter);
if(!in_rect){ }else{
iter = points3d.erase(iter); iter++;
}else{
iter++;
}
} }
// 获得高低差 }
float min_z = 1e5, max_z = -1e5; // 获得高低差
for(auto& p3d_: points3d){ float min_z = 1e5, max_z = -1e5;
if(p3d_.z > max_z){ for(auto& p3d_: points3d){
max_z = p3d_.z; if(p3d_.z > max_z){
} max_z = p3d_.z;
if(p3d_.z < min_z){
min_z = p3d_.z;
}
} }
filtered = (max_z - min_z < obstacle_height_threshold * 0.01); if(p3d_.z < min_z){
if(!filtered){ min_z = p3d_.z;
validTracks[obj.track_id] = 0; // init
std::cout << "------------------------ "<< obj.track_id <<" stone with "<<points3d.size() << " points, height diff: " << max_z - min_z << "m." << std::endl;
} }
/*else{// 扬尘遮挡,点少
if(unvalidTracks.find(obj.track_id) != unvalidTracks.end()){
if(project_ratio < 0.05 && obj.fConfidence > 0.5){
unvalidTracks[obj.track_id].second++;
}
// 长时间跟踪上,但是未被激活,用深度估计激活
if(unvalidTracks[obj.track_id].second >= 10){
unvalidTracks.erase(obj.track_id);
validTracks[obj.track_id] = 0; // init
return -1; // using depth estimination
}
}else if(project_ratio < 0.05 && obj.fConfidence > 0.5){ // 当遮挡比例大时
unvalidTracks[obj.track_id] = std::make_pair(0, 0);
}
}*/
} }
// 高差大于阈值输出
bool filtered = (max_z - min_z < obstacle_height_threshold * 0.01) && (max_z > obstacle_height_threshold * 0.01 * 0.5);
if(!filtered){ if(!filtered){
insobj.rc = obj.rc; Tracks[obj.track_id].valid_frame_num++; // add
insobj.color = uColor; std::cout << "------------------------ "<< obj.track_id <<": " << obj.name <<" with "<<points3d.size() <<
insobj.names = obj.name; " points, height diff: " << max_z - min_z << "m, max-z: " << max_z << "m." << std::endl;
insobj.fConfidence = obj.fConfidence; if(Tracks[obj.track_id].valid_frame_num >= 2){
vGrid.vInsObjs.push_back(insobj); Tracks[obj.track_id].valid = true;
obj.valid = obj.valid + 1; insobj.rc = obj.rc;
} insobj.color = uColor;
}else{ insobj.names = obj.name;
if(unvalidTracks.find(obj.track_id) != unvalidTracks.end()){ insobj.fConfidence = obj.fConfidence;
unvalidTracks[obj.track_id].second++; vGrid.vInsObjs.push_back(insobj);
// 长时间跟踪上,但是未被激活,用深度估计激活 obj.valid = obj.valid + 1;
// if(unvalidTracks[obj.track_id].second >= 10){ }
// unvalidTracks.erase(obj.track_id);
// validTracks[obj.track_id] = 0; // init
// return -1; // using depth estimination
// }
}else{
unvalidTracks[obj.track_id] = std::make_pair(0, 0);
} }
// point enough, filtered by
} }
// todo, point not enough
} }
return 0; return 0;
...@@ -1139,29 +1116,17 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& depth, Clou ...@@ -1139,29 +1116,17 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& depth, Clou
Process_Segmantic_Objects(obj, point_index_in_camera, pcl_cloud, vGrid); Process_Segmantic_Objects(obj, point_index_in_camera, pcl_cloud, vGrid);
} }
} }
// update and delete valid stones // update and delete tracks
for(auto t = validTracks.begin(); t != validTracks.end();){ for(auto t=Tracks.begin(); t != Tracks.end();){
t->second++; t->second.last_update_age++;
// std::cout<<t->first<<","<<t->second<<std::endl; t->second.tracked_age++;
if(t->second > 30){ if(t->second.last_update_age > 30){
validTracks.erase(t++); Tracks.erase(t++);
}else{ }else{
t++; t++;
} }
} }
// std::cout<<"-----valid stones:" << validTracks.size() << std::endl;
// update and delete unvalid stones
for(auto t = unvalidTracks.begin(); t != unvalidTracks.end();){
t->second.first++;
// std::cout<<t->first<<","<<t->second.first<<","<<t->second.second<<std::endl;
if(t->second.first > 30){
unvalidTracks.erase(t++);
}else{
t++;
}
}
// std::cout<<"-----unvalid stones:" << unvalidTracks.size() << std::endl;
// 将静态目标投影到栅格地图中 // 将静态目标投影到栅格地图中
pcl::PointXYZI bev_point; pcl::PointXYZI bev_point;
cv::Point2f pt2f; cv::Point2f pt2f;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @Date: 2023-04-13 14:37:39 * @Date: 2023-04-13 14:37:39
* @emal: qingshui.cheng@waytous.com * @emal: qingshui.cheng@waytous.com
* @LastEditors: wxin * @LastEditors: wxin
* @LastEditTime: 2023-12-04 06:11:33 * @LastEditTime: 2024-02-28 09:14:51
*/ */
#ifndef VISION_3D_H #ifndef VISION_3D_H
...@@ -214,10 +214,17 @@ private: ...@@ -214,10 +214,17 @@ private:
std::string current_frame_id = "Lidar"; std::string current_frame_id = "Lidar";
bool vis_project = false; bool vis_project = false;
struct STrack{
bool valid = false;
int valid_frame_num = 0;
int tracked_age = 0;
int last_update_age = 0;
};
// 保存跟踪后高度够的落石, id: last_update_age // 保存跟踪后高度够的落石, id: last_update_age
std::map<int, int> validTracks; std::map<int, STrack> Tracks;
// 保存跟踪的,但是高度不够,未被激活的落石, id: (tracked_age, last_update_age) // 保存跟踪的,但是高度不够,未被激活的落石, id: (tracked_age, last_update_age)
std::map<int, std::pair<int, int>> unvalidTracks; // std::map<int, std::pair<int, int>> unvalidTracks;
cv::Mat m_matrixQ; cv::Mat m_matrixQ;
Eigen::Matrix4d m_lidar2camera; Eigen::Matrix4d m_lidar2camera;
// Eigen::Matrix4d m_lidar2odom; // Eigen::Matrix4d m_lidar2odom;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment