删除横梁检测长度判断逻辑-只有一种长度

This commit is contained in:
qupengwei
2026-01-06 12:23:55 +08:00
parent d75b8d86f3
commit a1ffca8ddf
6 changed files with 19 additions and 42 deletions

View File

@@ -28,8 +28,7 @@ bool SlotOccupancyDetection::execute(const cv::Mat &depth_img,
const cv::Mat &color_img,
const std::string &side,
DetectionResult &result,
const std::vector<Point3D> *point_cloud,
int beam_length) {
const std::vector<Point3D> *point_cloud) {
result.result_type = 1;
result.result_status = "fail";
@@ -63,8 +62,7 @@ bool PalletOffsetDetection::execute(const cv::Mat &depth_img,
const cv::Mat &color_img,
const std::string &side,
DetectionResult &result,
const std::vector<Point3D> *point_cloud,
int beam_length) {
const std::vector<Point3D> *point_cloud) {
result.result_type = 2;
result.result_status = "fail";
@@ -108,18 +106,12 @@ bool PalletOffsetDetection::execute(const cv::Mat &depth_img,
// ========== BeamRackDeflectionDetection ==========
bool BeamRackDeflectionDetection::execute(
const cv::Mat &depth_img, const cv::Mat &color_img, const std::string &side,
DetectionResult &result, const std::vector<Point3D> *point_cloud,
int beam_length) {
DetectionResult &result, const std::vector<Point3D> *point_cloud) {
result.result_type = 3;
result.result_status = "fail";
// Select ROI based on beam_length
// Use Default ROI (removed beam_length logic)
std::vector<cv::Point2i> beam_roi;
if (beam_length == 2180) {
beam_roi = BeamRackDeflectionAlgorithm::BEAM_ROI_2180;
} else if (beam_length == 1380) {
beam_roi = BeamRackDeflectionAlgorithm::BEAM_ROI_1380;
}
// 调用算法进行检测
BeamRackDeflectionResult algo_result;
@@ -145,12 +137,9 @@ bool BeamRackDeflectionDetection::execute(
}
// ========== VisualInventoryDetection ==========
bool VisualInventoryDetection::execute(const cv::Mat &depth_img,
const cv::Mat &color_img,
const std::string &side,
DetectionResult &result,
const std::vector<Point3D> *point_cloud,
int beam_length) {
bool VisualInventoryDetection::execute(
const cv::Mat &depth_img, const cv::Mat &color_img, const std::string &side,
DetectionResult &result, const std::vector<Point3D> *point_cloud) {
result.result_type = 4;
result.result_status = "fail";

View File

@@ -29,8 +29,7 @@ public:
*/
virtual bool execute(const cv::Mat &depth_img, const cv::Mat &color_img,
const std::string &side, DetectionResult &result,
const std::vector<Point3D> *point_cloud = nullptr,
int beam_length = 0) = 0;
const std::vector<Point3D> *point_cloud = nullptr) = 0;
/**
* 获取任务类型对应flag值
@@ -53,8 +52,7 @@ public:
bool execute(const cv::Mat &depth_img, const cv::Mat &color_img,
const std::string &side, DetectionResult &result,
const std::vector<Point3D> *point_cloud = nullptr,
int beam_length = 0) override;
const std::vector<Point3D> *point_cloud = nullptr) override;
int getTaskType() const override { return 1; }
std::string getTaskName() const override { return "SlotOccupancyDetection"; }
@@ -70,8 +68,7 @@ public:
bool execute(const cv::Mat &depth_img, const cv::Mat &color_img,
const std::string &side, DetectionResult &result,
const std::vector<Point3D> *point_cloud = nullptr,
int beam_length = 0) override;
const std::vector<Point3D> *point_cloud = nullptr) override;
int getTaskType() const override { return 2; }
std::string getTaskName() const override { return "PalletOffsetDetection"; }
@@ -87,8 +84,7 @@ public:
bool execute(const cv::Mat &depth_img, const cv::Mat &color_img,
const std::string &side, DetectionResult &result,
const std::vector<Point3D> *point_cloud = nullptr,
int beam_length = 0) override;
const std::vector<Point3D> *point_cloud = nullptr) override;
int getTaskType() const override { return 3; }
std::string getTaskName() const override {
@@ -106,8 +102,7 @@ public:
bool execute(const cv::Mat &depth_img, const cv::Mat &color_img,
const std::string &side, DetectionResult &result,
const std::vector<Point3D> *point_cloud = nullptr,
int beam_length = 0) override;
const std::vector<Point3D> *point_cloud = nullptr) override;
int getTaskType() const override { return 4; }
std::string getTaskName() const override {

View File

@@ -23,7 +23,7 @@ const std::vector<cv::Point2i>
cv::Point2i(100, 50), // 左上
cv::Point2i(540, 80), // 右上
cv::Point2i(540, 280), // 右下
cv::Point2i(100, 280) // 左下
cv::Point2i(100, 280) // 左下-
};
// 2180mm 横梁 ROI (Placeholder - Same as Default for now)
@@ -94,8 +94,8 @@ bool BeamRackDeflectionAlgorithm::detect(
// Simulated success
result.success = true;
result.beam_def_mm_value = 0.0f;
result.rack_def_mm_value = 0.0f;
result.beam_def_mm_value = 3.0f;
result.rack_def_mm_value = 4.0f;
std::cout << "[BeamRackDeflectionAlgorithm] Simulated Detection. Side: "
<< side << std::endl;

View File

@@ -279,10 +279,6 @@ bool RedisCommunicator::readTaskData(RedisTaskData &task_data) {
readString("vision_task_side", task_data.side);
readString("vision_task_time", task_data.task_time);
int beam_length = 0;
readInt("vision_task_beam_length", beam_length);
task_data.beam_length = beam_length;
return true;
}

View File

@@ -10,7 +10,5 @@ struct RedisTaskData {
int flag; // 任务功能编号1~5
std::string side; // 货架侧left/right
std::string task_time; // 任务触发时间("YYYY-MM-DD HH:MM:SS"
int beam_length; // 横梁长度mm仅flag=3时有效可选值2180 / 1380
RedisTaskData() : flag(0), beam_length(0) {}
RedisTaskData() : flag(0) {}
};

View File

@@ -9,7 +9,7 @@
* - 线程安全的任务执行
*
* 设计说明:
* - 使用任务队列 + 执行线程的模式,实现异步任务处理
* - 使用任务队列 + 执行线程的模式,实现异步任务处理-
* - 直接使用DeviceManager单例获取图像简化架构
* - 合并了结果处理功能,简化架构
* - 所有共享数据使用互斥锁保护,确保线程安全
@@ -358,7 +358,7 @@ bool TaskManager::executeDetectionTask(const RedisTaskData &task_data,
std::string target_sn;
if (task_data.side == "left") {
target_sn = "207000146458";
target_sn = "207000146703";
} else if (task_data.side == "right") {
target_sn = "207000146703";
} else {
@@ -485,8 +485,7 @@ bool TaskManager::executeDetectionTask(const RedisTaskData &task_data,
try {
std::cout << "[TaskManager] Invoking detector->execute..." << std::endl;
success = detector->execute(depth_img, color_img, task_data.side, result,
!point_cloud.empty() ? &point_cloud : nullptr,
task_data.beam_length);
!point_cloud.empty() ? &point_cloud : nullptr);
std::cout << "[TaskManager] Detector returned: "
<< (success ? "Success" : "Failure") << std::endl;
} catch (const std::exception &e) {