diff --git a/modules/perception/camera/app/lane_camera_perception.cc b/modules/perception/camera/app/lane_camera_perception.cc index d49ed8c04c087a339b207d751928ff9baf6e5463..68a7dcaf6db8869c9b8210f1732f28ec6e2081b0 100644 --- a/modules/perception/camera/app/lane_camera_perception.cc +++ b/modules/perception/camera/app/lane_camera_perception.cc @@ -117,6 +117,25 @@ void LaneCameraPerception::InitLane( CHECK(lane_postprocessor_->Init(postprocessor_init_options)) << "Failed to init " << lane_postprocessor_param.name(); AINFO << "lane_postprocessor: " << lane_postprocessor_->Name(); + + // Init output file folder + if (perception_param_.has_debug_param() && + perception_param_.debug_param().has_lane_out_dir()) { + write_out_lane_file_ = true; + out_lane_dir_ = perception_param_.debug_param().lane_out_dir(); + std::string command; + command = "mkdir -p " + out_lane_dir_; + system(command.c_str()); + } + + if (perception_param_.has_debug_param() && + perception_param_.debug_param().has_calibration_out_dir()) { + write_out_calib_file_ = true; + out_calib_dir_ = perception_param_.debug_param().calibration_out_dir(); + std::string command; + command = "mkdir -p " + out_calib_dir_; + system(command.c_str()); + } } } @@ -208,12 +227,13 @@ bool LaneCameraPerception::Perception( PERCEPTION_PERF_BLOCK_END_WITH_INDICATOR( frame->data_provider->sensor_name(), "LanePostprocessor3D"); - std::string save_path = perception_param_.debug_param().lane_out_dir() - + "/" + std::to_string(frame->frame_id) + ".txt"; - WriteLanelines(perception_param_.has_debug_param() && - perception_param_.debug_param().has_lane_out_dir(), - save_path, - frame->lane_objects); + if (write_out_lane_file_) { + std::string lane_file_path = + out_lane_dir_ + "/" + std::to_string(frame->frame_id) + ".txt"; + WriteLanelines(write_out_lane_file_, + lane_file_path, + frame->lane_objects); + } } else { AINFO << "Skip lane detection & calibration due to sensor mismatch."; AINFO << "Will use service sync from obstacle camera instead."; @@ -223,13 +243,13 @@ bool LaneCameraPerception::Perception( frame->data_provider->sensor_name(), "CalibrationService"); } - std::string save_calibration_path = - perception_param_.debug_param().calibration_out_dir() - + "/" + std::to_string(frame->frame_id) + ".txt"; - WriteCalibrationOutput(perception_param_.has_debug_param() && - perception_param_.debug_param().has_calibration_out_dir(), - save_calibration_path, frame); - + if (write_out_calib_file_) { + std::string calib_file_path = + out_calib_dir_ + "/" + std::to_string(frame->frame_id) + ".txt"; + WriteCalibrationOutput(write_out_calib_file_, + calib_file_path, + frame); + } return true; } } // namespace camera diff --git a/modules/perception/camera/app/lane_camera_perception.h b/modules/perception/camera/app/lane_camera_perception.h index 730465b59d4499cbec1eacbc949e53a0c8e54c44..81714c370910092e1fdc62bf3841d4461d183f6d 100644 --- a/modules/perception/camera/app/lane_camera_perception.h +++ b/modules/perception/camera/app/lane_camera_perception.h @@ -70,6 +70,10 @@ class LaneCameraPerception : public BaseCameraPerception { std::shared_ptr calibration_service_; app::PerceptionParam perception_param_; std::string lane_calibration_working_sensor_name_ = ""; + bool write_out_lane_file_ = false; + bool write_out_calib_file_ = false; + std::string out_lane_dir_; + std::string out_calib_dir_; }; } // namespace camera diff --git a/modules/perception/camera/app/obstacle_camera_perception.cc b/modules/perception/camera/app/obstacle_camera_perception.cc index 3247ac95496aae19b5c82ef7e8bc22b3501444fb..ed7f49faf8e37422785acd1b427622578a677e72 100644 --- a/modules/perception/camera/app/obstacle_camera_perception.cc +++ b/modules/perception/camera/app/obstacle_camera_perception.cc @@ -228,6 +228,25 @@ void ObstacleCameraPerception::InitLane( CHECK(lane_postprocessor_->Init(postprocessor_init_options)) << "Failed to init " << lane_postprocessor_param.name(); AINFO << "lane_postprocessor: " << lane_postprocessor_->Name(); + + // Init output file folder + if (perception_param_.has_debug_param() && + perception_param_.debug_param().has_lane_out_dir()) { + write_out_lane_file_ = true; + out_lane_dir_ = perception_param_.debug_param().lane_out_dir(); + std::string command; + command = "mkdir -p " + out_lane_dir_; + system(command.c_str()); + } + + if (perception_param_.has_debug_param() && + perception_param_.debug_param().has_calibration_out_dir()) { + write_out_calib_file_ = true; + out_calib_dir_ = perception_param_.debug_param().calibration_out_dir(); + std::string command; + command = "mkdir -p " + out_calib_dir_; + system(command.c_str()); + } } } @@ -323,12 +342,13 @@ bool ObstacleCameraPerception::Perception( PERCEPTION_PERF_BLOCK_END_WITH_INDICATOR( frame->data_provider->sensor_name(), "LanePostprocessor3D"); - std::string save_path = perception_param_.debug_param().lane_out_dir() - + "/" + std::to_string(frame->frame_id) + ".txt"; - WriteLanelines(perception_param_.has_debug_param() && - perception_param_.debug_param().has_lane_out_dir(), - save_path, - frame->lane_objects); + if (write_out_lane_file_) { + std::string lane_file_path = + out_lane_dir_ + "/" + std::to_string(frame->frame_id) + ".txt"; + WriteLanelines(write_out_lane_file_, + lane_file_path, + frame->lane_objects); + } } else { AINFO << "Skip lane detection & calibration due to sensor mismatch."; AINFO << "Will use service sync from obstacle camera instead."; @@ -338,12 +358,13 @@ bool ObstacleCameraPerception::Perception( frame->data_provider->sensor_name(), "CalibrationService"); } - std::string save_calibration_path = - perception_param_.debug_param().calibration_out_dir() - + "/" + std::to_string(frame->frame_id) + ".txt"; - WriteCalibrationOutput(perception_param_.has_debug_param() && - perception_param_.debug_param().has_calibration_out_dir(), - save_calibration_path, frame); + if (write_out_calib_file_) { + std::string calib_file_path = + out_calib_dir_ + "/" + std::to_string(frame->frame_id) + ".txt"; + WriteCalibrationOutput(write_out_calib_file_, + calib_file_path, + frame); + } // obstacle if (!tracker_->Predict(tracker_options, frame)) { diff --git a/modules/perception/camera/app/obstacle_camera_perception.h b/modules/perception/camera/app/obstacle_camera_perception.h index e26ec5f3d070d2bdd80964cab418efd0d978f6d1..2c2b32a569f8e2e2eb4a272972fce3fb1bd37fd7 100644 --- a/modules/perception/camera/app/obstacle_camera_perception.h +++ b/modules/perception/camera/app/obstacle_camera_perception.h @@ -87,6 +87,10 @@ class ObstacleCameraPerception : public BaseCameraPerception { std::ofstream out_track_; std::ofstream out_pose_; std::string lane_calibration_working_sensor_name_ = ""; + bool write_out_lane_file_ = false; + bool write_out_calib_file_ = false; + std::string out_lane_dir_; + std::string out_calib_dir_; protected: ObjectTemplateManager *object_template_manager_ = nullptr; diff --git a/modules/perception/production/conf/perception/camera/obstacle.pt b/modules/perception/production/conf/perception/camera/obstacle.pt index 2c371b82d7f2c4e440e94c27ef6548cb35e0ec7d..44edab21ca9648dbbeed993b0b405032c44f2181 100644 --- a/modules/perception/production/conf/perception/camera/obstacle.pt +++ b/modules/perception/production/conf/perception/camera/obstacle.pt @@ -72,7 +72,3 @@ object_template_param { } } -debug_param { - lane_out_dir : "/apollo/debug_output/lane/" - calibration_out_dir : "/apollo/debug_output/calib/" -}