Skip to content

Commit 7ba3ef2

Browse files
feat(ui): 增强登录对话框和存储监控功能
- LoginDialog: 添加密码显示/隐藏切换按钮和登录失败弹窗提示 - StorageService: 新增多路径磁盘空间监控服务 - StorageSettingsPage: 集成StorageService显示各路径存储状态 - DefectTableModel: 集成到MainWindow作为缺陷列表标签页 - ImagePreviewDialog: 支持显示历史标注和保存手动标注到数据库 - HistoryView: 传递缺陷数据到图片预览对话框 - 添加版权头到所有源文件 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent f164711 commit 7ba3ef2

157 files changed

Lines changed: 4454 additions & 338 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/add_copyright.py

Lines changed: 584 additions & 0 deletions
Large diffs are not rendered by default.

src/algorithm/BaseDetector.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2025.12
3+
* All rights reserved.
4+
*
5+
* BaseDetector.h
6+
*
7+
* 初始版本:1.0
8+
* 作者:Vere
9+
* 创建日期:2025年12月03日
10+
* 摘要:检测器基类实现定义
11+
* 描述:检测器公共实现基类,提供参数管理、置信度过滤、结果构造等
12+
* 通用功能,具体检测器继承此类
13+
*
14+
* 当前版本:1.0
15+
*/
16+
117
#ifndef BASEDETECTOR_H
218
#define BASEDETECTOR_H
319

src/algorithm/DetectorFactory.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "DetectorFactory.h"
2+
#include "common/Logger.h"
23

34
// 预定义的检测器类型常量
45
const QString DetectorFactory::TYPE_SCRATCH = "scratch";
@@ -14,13 +15,16 @@ DetectorFactory& DetectorFactory::instance() {
1415

1516
void DetectorFactory::registerDetector(const QString& type, CreatorFunc creator) {
1617
m_creators[type] = std::move(creator);
18+
LOG_DEBUG("DetectorFactory: Registered detector type '{}'", type.toStdString());
1719
}
1820

1921
DetectorPtr DetectorFactory::create(const QString& type) const {
2022
auto it = m_creators.find(type);
2123
if (it != m_creators.end()) {
24+
LOG_DEBUG("DetectorFactory: Creating detector '{}'", type.toStdString());
2225
return it->second();
2326
}
27+
LOG_WARN("DetectorFactory: Unknown detector type '{}'", type.toStdString());
2428
return nullptr;
2529
}
2630

src/algorithm/DetectorFactory.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2025.12
3+
* All rights reserved.
4+
*
5+
* DetectorFactory.h
6+
*
7+
* 初始版本:1.0
8+
* 作者:Vere
9+
* 创建日期:2025年12月03日
10+
* 摘要:检测器工厂类定义
11+
* 描述:检测器对象工厂,根据类型字符串创建对应检测器实例,
12+
* 支持注册自定义检测器类型
13+
*
14+
* 当前版本:1.0
15+
*/
16+
117
#ifndef DETECTORFACTORY_H
218
#define DETECTORFACTORY_H
319

src/algorithm/DetectorManager.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2025.12
3+
* All rights reserved.
4+
*
5+
* DetectorManager.h
6+
*
7+
* 初始版本:1.0
8+
* 作者:Vere
9+
* 创建日期:2025年12月03日
10+
* 摘要:检测器管理模块接口定义
11+
* 描述:管理多个检测器的生命周期和执行,支持串行/并行检测、
12+
* 结果合并、配置同步等功能
13+
*
14+
* 当前版本:1.0
15+
*/
16+
117
#ifndef DETECTORMANAGER_H
218
#define DETECTORMANAGER_H
319

src/algorithm/IDefectDetector.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2025.12
3+
* All rights reserved.
4+
*
5+
* IDefectDetector.h
6+
*
7+
* 初始版本:1.0
8+
* 作者:Vere
9+
* 创建日期:2025年12月03日
10+
* 摘要:缺陷检测器接口基类定义
11+
* 描述:检测器抽象接口,定义initialize/release/detect等核心方法,
12+
* 以及参数管理、结果过滤等通用功能
13+
*
14+
* 当前版本:1.0
15+
*/
16+
117
#ifndef IDEFECTDETECTOR_H
218
#define IDEFECTDETECTOR_H
319

src/algorithm/algorithm_global.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (c) 2025.12
3+
* All rights reserved.
4+
*
5+
* algorithm_global.h
6+
*
7+
* 初始版本:1.0
8+
* 作者:Vere
9+
* 创建日期:2025年12月03日
10+
* 摘要:算法模块全局宏定义
11+
* 描述:定义ALGORITHM_LIBRARY导出宏,用于Windows DLL导出符号控制
12+
*
13+
* 当前版本:1.0
14+
*/
15+
116
#ifndef ALGORITHM_GLOBAL_H
217
#define ALGORITHM_GLOBAL_H
318

src/algorithm/detectors/CrackDetector.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "CrackDetector.h"
2+
#include "../common/Logger.h"
23
#include <QElapsedTimer>
34

45
CrackDetector::CrackDetector() {
@@ -58,21 +59,37 @@ DetectionResult CrackDetector::detect(const cv::Mat& image) {
5859
timer.start();
5960

6061
if (image.empty()) {
62+
LOG_ERROR("CrackDetector::detect - Input image is empty");
6163
return makeErrorResult("Empty input image");
6264
}
6365

6466
updateParameters();
67+
68+
LOG_DEBUG("CrackDetector::detect - Input: {}x{}, params: threshold={}, minArea={}, morphKernel={}",
69+
image.cols, image.rows, m_threshold, m_minArea, m_morphKernelSize);
6570

6671
// 预处理
6772
cv::Mat binary = preprocessImage(image);
6873

6974
// 查找裂纹
7075
std::vector<DefectInfo> defects = findCracks(binary, image);
76+
size_t beforeFilter = defects.size();
7177

7278
// 过滤低置信度
7379
defects = filterByConfidence(defects);
7480

7581
double timeMs = timer.elapsed();
82+
83+
// 统计信息
84+
double totalArea = 0, maxComplexity = 0;
85+
for (const auto& d : defects) {
86+
if (d.attributes.contains("area")) totalArea += d.attributes.value("area").toDouble();
87+
if (d.attributes.contains("complexity")) maxComplexity = std::max(maxComplexity, d.attributes.value("complexity").toDouble());
88+
}
89+
90+
LOG_INFO("CrackDetector::detect - Result: {} cracks (filtered:{}/{}), totalArea={:.0f}px, maxComplexity={:.1f}, time:{:.1f}ms",
91+
defects.size(), defects.size(), beforeFilter, totalArea, maxComplexity, timeMs);
92+
7693
return makeSuccessResult(defects, timeMs);
7794
}
7895

src/algorithm/detectors/CrackDetector.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2025.12
3+
* All rights reserved.
4+
*
5+
* CrackDetector.h
6+
*
7+
* 初始版本:1.0
8+
* 作者:Vere
9+
* 创建日期:2025年12月03日
10+
* 摘要:裂纹检测器接口定义
11+
* 描述:基于形态学和轮廓分析的裂纹检测算法,支持分支裂纹检测、
12+
* 裂纹长度和宽度测量
13+
*
14+
* 当前版本:1.0
15+
*/
16+
117
#ifndef CRACKDETECTOR_H
218
#define CRACKDETECTOR_H
319

src/algorithm/detectors/DimensionDetector.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "DimensionDetector.h"
2+
#include "../common/Logger.h"
23
#include <QElapsedTimer>
34

45
DimensionDetector::DimensionDetector() {
@@ -54,10 +55,14 @@ DetectionResult DimensionDetector::detect(const cv::Mat& image) {
5455
timer.start();
5556

5657
if (image.empty()) {
58+
LOG_ERROR("DimensionDetector::detect - Input image is empty");
5759
return makeErrorResult("Empty input image");
5860
}
5961

6062
updateParameters();
63+
64+
LOG_DEBUG("DimensionDetector::detect - Input: {}x{}, target: {:.2f}x{:.2f}mm, tolerance: {:.2f}mm, calibration: {:.4f}mm/px",
65+
image.cols, image.rows, m_targetWidth, m_targetHeight, m_tolerance, m_calibration);
6166

6267
// 预处理
6368
cv::Mat binary = preprocessImage(image);
@@ -66,6 +71,21 @@ DetectionResult DimensionDetector::detect(const cv::Mat& image) {
6671
std::vector<DefectInfo> defects = measureDimensions(binary, image);
6772

6873
double timeMs = timer.elapsed();
74+
75+
// 日志输出测量结果
76+
if (defects.empty()) {
77+
LOG_INFO("DimensionDetector::detect - OK, all dimensions within tolerance, time:{:.1f}ms", timeMs);
78+
} else {
79+
for (const auto& d : defects) {
80+
if (d.attributes.contains("measureType") && d.attributes.contains("deviation") && d.attributes.contains("actualValue")) {
81+
std::string type = d.attributes.value("measureType").toDouble() > 0.5 ? "height" : "width";
82+
LOG_WARN("DimensionDetector::detect - NG {}: actual={:.2f}mm, deviation={:.2f}mm (tolerance={:.2f}mm), severity={:.2f}",
83+
type, d.attributes.value("actualValue").toDouble(), d.attributes.value("deviation").toDouble(), m_tolerance, d.severity);
84+
}
85+
}
86+
LOG_INFO("DimensionDetector::detect - Result: {} dimension errors, time:{:.1f}ms", defects.size(), timeMs);
87+
}
88+
6989
return makeSuccessResult(defects, timeMs);
7090
}
7191

0 commit comments

Comments
 (0)