diff --git a/CMakeLists.txt b/CMakeLists.txt index c0d2460..e28661f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.14.0) project(handdleai VERSION 0.1.0) string(TIMESTAMP RUN_TIME) message( " project start : " ${RUN_TIME}) - +add_compile_definitions(NOMINMAX) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) set(CMAKE_DISABLE_SOURCE_CHANGES ON) diff --git a/include/global.h b/include/global.h index 0331dd3..52e2893 100644 --- a/include/global.h +++ b/include/global.h @@ -100,18 +100,6 @@ static cv::Mat qImageToCvMat(const QImage& inImage) } return cv::Mat(); } -template -T getMax(const T& a, const T& b) { - return (a > b) ? a : b; -} -template -T getMin(const T& a, const T& b) { - return (a < b) ? a : b; -} -template -T getAbs(const T& value) { - return (value < 0) ? -value : value; -} static void cvMatToQPixMap(cv::Mat& src,QPixmap& pixmap) { pixmap = QPixmap::fromImage(cvMatToQImage(src)); diff --git a/include/simpleAlgo.h b/include/simpleAlgo.h index 2e15925..cdda621 100644 --- a/include/simpleAlgo.h +++ b/include/simpleAlgo.h @@ -88,16 +88,16 @@ static cv::Mat cutImg2Cls(cv::Rect boundingBox, cv::Mat imgInput, cv::Size targe // 以目标框中心为正方形中心,边长为 max(max(w,h),128) const cv::Point mid(boundingBox.x + boundingBox.width / 2, boundingBox.y + boundingBox.height / 2); - const int sideLength = getMax(getMax(boundingBox.width, boundingBox.height), 128); + const int sideLength = std::max(std::max(boundingBox.width, boundingBox.height), 128); // 期望在原图上的 ROI(可能越界) cv::Rect expectRect(mid.x - sideLength / 2, mid.y - sideLength / 2, sideLength, sideLength); // 计算需要的边界填充(反射填充) - const int left = getMax(0, -expectRect.x); - const int top = getMax(0, -expectRect.y); - const int right = getMax(0, expectRect.x + expectRect.width - imgInput.cols); - const int bottom = getMax(0, expectRect.y + expectRect.height - imgInput.rows); + const int left = std::max(0, -expectRect.x); + const int top = std::max(0, -expectRect.y); + const int right = std::max(0, expectRect.x + expectRect.width - imgInput.cols); + const int bottom = std::max(0, expectRect.y + expectRect.height - imgInput.rows); cv::Mat padded; if (left || top || right || bottom) { @@ -126,7 +126,7 @@ static std::vector cutImg2ClsVec(cv::Rect boundingBox, cv::Mat imgInput const int w = boundingBox.width; const int h = boundingBox.height; - const int minSide = getMin(w, h); + const int minSide = std::min(w, h); if (minSide <= 0) { std::cerr << "Bounding box has zero width or height." << std::endl; return result; @@ -622,7 +622,7 @@ static cv::Rect doMatchTemplate(const cv::Mat& templateImg, const cv::Mat& srcIm static bool isContoursOverlap(const std::vector& contour1, const std::vector& contour2, double thresholdPercent = 0) { cv::Rect rect1 = cv::boundingRect(contour1); cv::Rect rect2 = cv::boundingRect(contour2); - cv::Size tempImgSize(getMax(rect1.x + rect1.width, rect2.x + rect2.width), getMax(rect1.y + rect1.height, rect2.y + rect2.height)); + cv::Size tempImgSize(std::max(rect1.x + rect1.width, rect2.x + rect2.width), std::max(rect1.y + rect1.height, rect2.y + rect2.height)); cv::Mat binaryImage = cv::Mat::zeros(tempImgSize, CV_8U); // 画出目标轮廓 @@ -651,7 +651,7 @@ static bool isRectOverlap(const cv::Rect& rect1, const cv::Rect& rect2, double t cv::Rect intersection = rect1 & rect2; if (thresholdPercent != 0)//如果有阈值 { - int maxCnotourArea = getMax(rect1.area(), rect2.area()); + int maxCnotourArea = std::max(rect1.area(), rect2.area()); if (intersection.area() / maxCnotourArea < thresholdPercent) return false; } @@ -740,7 +740,7 @@ static cv::Mat tiledImages(std::vector& imgs) int matWidth = 0, matHeight = 0; for (auto& mat : imgs) { - matHeight = getMax(mat.rows, matHeight); + matHeight = std::max(mat.rows, matHeight); matWidth += mat.cols; } cv::Mat showMat(matHeight, matWidth, CV_8UC3); @@ -806,7 +806,7 @@ static void denoiseImage(const cv::Mat& inputMat, cv::Mat& outputMat, int kernel } // 兜底:使用可分离高斯滤波,适合较大核或需要指定平滑强度的场景 - const double sigmaChecked = getMax(0.0, sigma); + const double sigmaChecked = std::max(0.0, sigma); cv::GaussianBlur(inputMat, outputMat, cv::Size(k, k), sigmaChecked, sigmaChecked, cv::BORDER_DEFAULT); } diff --git a/include/simpleTools/writeExcel.cpp b/include/simpleTools/writeExcel.cpp index 045e6aa..db013e8 100644 --- a/include/simpleTools/writeExcel.cpp +++ b/include/simpleTools/writeExcel.cpp @@ -12,9 +12,9 @@ // std::vector < std::pair> // sonMerges = writeExcelLoop(sheet, input.nexCols[i], depth + 1, cols + depthCount); // mergeStr.insert(mergeStr.end(), sonMerges.begin(), sonMerges.end()); -// depthCount += getMax((int)input.nexCols[i].nexCols.size(), 1); +// depthCount += std::max((int)input.nexCols[i].nexCols.size(), 1); // } -// std::string endUnit = char(65 + depth) + std::to_string(cols + getMax(depthCount - 1, 0)); +// std::string endUnit = char(65 + depth) + std::to_string(cols + std::max(depthCount - 1, 0)); // sheet.cell(startUnit).value() = input.text; // mergeStr.push_back(std::make_pair(startUnit, endUnit)); // return mergeStr; diff --git a/src/core/service/detCallbackChain.hpp b/src/core/service/detCallbackChain.hpp index a9ccdcb..0c3f553 100644 --- a/src/core/service/detCallbackChain.hpp +++ b/src/core/service/detCallbackChain.hpp @@ -46,7 +46,7 @@ public: if (data->resultImgs.size() > 0) { for (int i = 0; i < data->resultImgs.size() && i < data->resultImgShowSet.size(); i++) { - auto pack = data->resultImgShowSet[getMin(i, (int)data->resultImgShowSet.size() - 1)]; + auto pack = data->resultImgShowSet[std::min(i, (int)data->resultImgShowSet.size() - 1)]; int resizeRate = qMax(data->resultImgs[i].cols / uiShowImgCompressThreshold, data->resultImgs[i].rows / uiShowImgCompressThreshold) ; resizeRate = std::pow(2, resizeRate); if (resizeRate > 1) { diff --git a/src/launcher/GUI/mainwindow.h b/src/launcher/GUI/mainwindow.h index 7befdad..432ff44 100644 --- a/src/launcher/GUI/mainwindow.h +++ b/src/launcher/GUI/mainwindow.h @@ -459,7 +459,7 @@ protected: void mouseMoveEvent(QMouseEvent* event) override { if (event->buttons() == Qt::LeftButton && isMoving) { QPoint pos = event->globalPos(); - if (getMax(getAbs(pos.x()- startPos.x()), getAbs(pos.y() - startPos.y()))>10) + if (std::max(std::abs(pos.x()- startPos.x()), std::abs(pos.y() - startPos.y()))>10) if(lastWindowMoveTime.elapsed()> freshDelay)//每秒刷新100次 { lastWindowMoveTime.restart(); diff --git a/src/launcher/GUI/uiModule/components/fancyProcessBar.h b/src/launcher/GUI/uiModule/components/fancyProcessBar.h index 34dfada..05104fe 100644 --- a/src/launcher/GUI/uiModule/components/fancyProcessBar.h +++ b/src/launcher/GUI/uiModule/components/fancyProcessBar.h @@ -48,8 +48,8 @@ public: } void addData(int value) { - maxValue = getMax(value, maxValue); - minValue = getMin(value, minValue); + maxValue = std::max(value, maxValue); + minValue = std::min(value, minValue); currentValue = value; if((maxValue - minValue) ==0) setProgress(1); diff --git a/src/launcher/GUI/uiModule/uiModule_dumpToExcel.h b/src/launcher/GUI/uiModule/uiModule_dumpToExcel.h index 3e9a66c..ecb15c2 100644 --- a/src/launcher/GUI/uiModule/uiModule_dumpToExcel.h +++ b/src/launcher/GUI/uiModule/uiModule_dumpToExcel.h @@ -27,7 +27,7 @@ public: { int time1 = startTimeEdit->time().hour() * 60 + startTimeEdit->time().minute(); int time2 = endTimeEdit->time().hour() * 60 + startTimeEdit->time().minute(); - return { getMax(time1,time2),getMax(time1,time2) }; + return { std::max(time1,time2),std::max(time1,time2) }; } QTime getStartTime() const { diff --git a/src/launcher/GUI/uiModule/uiModule_imageView.h b/src/launcher/GUI/uiModule/uiModule_imageView.h index 7f11d38..632c358 100644 --- a/src/launcher/GUI/uiModule/uiModule_imageView.h +++ b/src/launcher/GUI/uiModule/uiModule_imageView.h @@ -211,7 +211,7 @@ protected: // deleteAllRect(); // if (width != 0 && height != 0) { - // double scaleRate = getMax(width == 0 ? 1.0 : rect().width() / width,height == 0 ? 1.0 : rect().height() / height); + // double scaleRate = std::max(width == 0 ? 1.0 : rect().width() / width,height == 0 ? 1.0 : rect().height() / height); // scale(scaleRate, scaleRate); // centerOn(startPos + QPointF(width / 2, height / 2)); // } diff --git a/src/mission/581-Dgh-DB-2/581-Dgh-DB-2.h b/src/mission/581-Dgh-DB-2/581-Dgh-DB-2.h index 94fa59e..3e3567a 100644 --- a/src/mission/581-Dgh-DB-2/581-Dgh-DB-2.h +++ b/src/mission/581-Dgh-DB-2/581-Dgh-DB-2.h @@ -121,7 +121,7 @@ cv::Mat LocalCutImg_DET(handdleAI::pDetection* pDet, cv::Mat src, float zoom, in static std::vectordingGaiHanClsCut(cv::Rect boundingBox, cv::Mat imgInput, cv::Size targetSize = cv::Size(128, 128)) { std::vector result; - int splitCount = getMax(boundingBox.width, boundingBox.height) / getMax(boundingBox.width, boundingBox.height); + int splitCount = std::max(boundingBox.width, boundingBox.height) / std::max(boundingBox.width, boundingBox.height); //std::cout << "splitCount" << splitCount; if (splitCount > 2) {//大于2分段裁 if (boundingBox.width > boundingBox.height) {//宽大于高,横着裁 diff --git a/tools/.clang-format b/tools/.clang-format new file mode 100644 index 0000000..3d10ea8 --- /dev/null +++ b/tools/.clang-format @@ -0,0 +1,7 @@ +Language: Cpp +BasedOnStyle: Google +UseTab: Never # 使用空格而不是制表符。 +IndentWidth: 4 # 缩进宽度为4个空格。 +TabWidth: 4 # Tab长度 +ColumnLimit: 0 +SortIncludes: false \ No newline at end of file diff --git a/tools/clang-format.exe b/tools/clang-format.exe new file mode 100644 index 0000000..7a176ce Binary files /dev/null and b/tools/clang-format.exe differ diff --git a/tools/formatter.bat b/tools/formatter.bat new file mode 100644 index 0000000..de6bd06 --- /dev/null +++ b/tools/formatter.bat @@ -0,0 +1,54 @@ +@echo off +echo Starting code formatting... + +:: 定义要格式化的多个文件夹 +set "FOLDER_1=../src" +set "FOLDER_2=../include" +set "FOLDER_3=../subModule" +set "FOLDER_4=../rpcModule" + +echo Formatting multiple folders... +echo. + +:: 格式化第一个文件夹 +if exist "%FOLDER_1%" ( + echo Processing folder: %FOLDER_1% + for /r "%FOLDER_1%" %%i in (*.cpp *.h) do ( + echo Formatting: %%i + clang-format -i "%%i" + ) + echo. +) + +:: 格式化第二个文件夹 +if exist "%FOLDER_2%" ( + echo Processing folder: %FOLDER_2% + for /r "%FOLDER_2%" %%i in (*.cpp *.h) do ( + echo Formatting: %%i + clang-format -i "%%i" + ) + echo. +) + +:: 格式化第三个文件夹 +if exist "%FOLDER_3%" ( + echo Processing folder: %FOLDER_3% + for /r "%FOLDER_3%" %%i in (*.cpp *.h) do ( + echo Formatting: %%i + clang-format -i "%%i" + ) + echo. +) + +:: 格式化第4个文件夹 +if exist "%FOLDER_4%" ( + echo Processing folder: %FOLDER_4% + for /r "%FOLDER_4%" %%i in (*.cpp *.h) do ( + echo Formatting: %%i + clang-format -i "%%i" + ) + echo. +) + +echo Formatting completed! +pause \ No newline at end of file diff --git a/tools/fuck-u-code-windows-amd64.exe b/tools/fuck-u-code-windows-amd64.exe new file mode 100644 index 0000000..c9da3c8 Binary files /dev/null and b/tools/fuck-u-code-windows-amd64.exe differ