diff --git a/2023.5.19-八相机剩余软件问题.doc b/2023.5.19-八相机剩余软件问题.doc deleted file mode 100644 index 7b98c4d..0000000 Binary files a/2023.5.19-八相机剩余软件问题.doc and /dev/null differ diff --git a/230731软件问题汇总.docx b/230731软件问题汇总.docx new file mode 100644 index 0000000..c95ffe9 Binary files /dev/null and b/230731软件问题汇总.docx differ diff --git a/Cigarette.sln b/Cigarette.sln index 5741173..243d8ea 100644 --- a/Cigarette.sln +++ b/Cigarette.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cigarette", "Cigarette\Cigarette.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CigaretteSingle", "CigaretteSingle\CigaretteSingle.vcxproj", "{795A8611-044A-46D3-8DD9-13A338925BC4}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -23,20 +21,12 @@ Global {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x64.ActiveCfg = Debug|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x64.Build.0 = Debug|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x86.ActiveCfg = Debug|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Debug|x86.Build.0 = Debug|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x64.ActiveCfg = Release|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x64.Build.0 = Release|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x86.ActiveCfg = Release|x64 - {795A8611-044A-46D3-8DD9-13A338925BC4}.Release|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - Qt5Version = 5.15.2_msvc2019_64 SolutionGuid = {0AF1A30E-A12C-4014-ACD5-65A1E6D54D46} + Qt5Version = 5.15.2_msvc2019_64 EndGlobalSection EndGlobal diff --git a/Cigarette/CaptureThreadHIK.cpp b/Cigarette/CaptureThreadHIK.cpp index 8395fdb..20f136e 100644 --- a/Cigarette/CaptureThreadHIK.cpp +++ b/Cigarette/CaptureThreadHIK.cpp @@ -259,17 +259,18 @@ void CaptureThreadHIK::process( void ) MVCC_INTVALUE_EX stIntValue = { 0 }; nRet = MV_CC_GetIntValueEx(CamHandle, "PayloadSize", &stIntValue); if (nRet) { std::cout << "Get PayloadSize error" << std::endl; } - nDataSize = stIntValue.nCurValue; + nDataSize = stIntValue.nCurValue*3;/// MV_CC_StartGrabbing(CamHandle); Ready = true; while(!boTerminated_) { - nRet = MV_CC_GetOneFrameTimeout(CamHandle, g_pImage_buf, nDataSize, &stFrameInfo, 200); + //nRet = MV_CC_GetOneFrameTimeout(CamHandle, g_pImage_buf, nDataSize, &stFrameInfo, 200); + nRet = MV_CC_GetImageForBGR(CamHandle, g_pImage_buf, nDataSize, &stFrameInfo, 200); if (MV_OK == nRet) { m_cntGrabbedImages++; - cv::Mat openCVImage(stFrameInfo.nHeight, stFrameInfo.nWidth, CV_8UC1, g_pImage_buf); + cv::Mat openCVImage(stFrameInfo.nHeight, stFrameInfo.nWidth, CV_8UC3, g_pImage_buf); cv::Mat image_clone = openCVImage.clone(); if (!g_debug_mode) { diff --git a/Cigarette/CryptoToolLib.lib b/Cigarette/CryptoToolLib.lib index 6ccc11e..3c7cebf 100644 Binary files a/Cigarette/CryptoToolLib.lib and b/Cigarette/CryptoToolLib.lib differ diff --git a/Cigarette/alg_jd.cpp b/Cigarette/alg_jd.cpp index 9bea4ef..0ca6301 100644 --- a/Cigarette/alg_jd.cpp +++ b/Cigarette/alg_jd.cpp @@ -1,5 +1,8 @@ #include "alg_jd.h" -#include //Ŀļ +#include "common.h" +// ļ +#define CONFIGURE_FILE "D:/conf/conf.txt" +extern SysConf g_sys_conf; // Remove the bounding boxes with low confidence using non-maxima suppression static void post_process(cv::Mat& frame, std::vector& outs, std::vector > &results); @@ -12,27 +15,59 @@ static std::vector getOutputsNames(const cv::dnn::Net& net); static void drawPred(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame); // Initialize the parameters -static float confThreshold = 0.1; // Confidence threshold +static float confThreshold = g_sys_conf.ConfThreshold*0.01; // Confidence threshold static float nmsThreshold = 0.4; // Non-maximum suppression threshold static int inpWidth = 416; // Width of network's input image static int inpHeight = 416; // Height of network's input image static std::vector classes; -bool AlgJd::init(QString path_model, QString path_jpg) +bool AlgJd::init() { + QString model_path; + QString jpg_path; + std::fstream cfg_file; + cfg_file.open(CONFIGURE_FILE); + if (!cfg_file.is_open()) + { + std::cout << "Error: Open config file " << CONFIGURE_FILE << std::endl; + return false; + } + while (!cfg_file.eof()) + { + char tmp[256] = ""; + cfg_file.getline(tmp, 256); + std::string line(tmp); + if (line.length() > 0) + { + size_t pos = line.find('='); + std::string tmp_key = line.substr(0, pos); + if (tmp_key == "MODELPATH") + { + model_path = line.substr(pos + 1).c_str(); + } + if (tmp_key == "JPGPATH") + { + jpg_path = line.substr(pos + 1).c_str(); + } + } + } + cfg_file.close(); + + //std::cout << "MODEL PATH IS " << model_path.toStdString().c_str() << std::endl; + // Load names of classes - std::string classesFile = "../model/jd.names"; + std::string classesFile = "D:/model/jd.names"; // Give the configuration and weight files for the model - cv::String modelConfiguration = "../model/jd.cfg"; + cv::String modelConfiguration = "D:/model/jd.cfg"; cv::String modelWeights; - if (path_model.length() > 0) { - modelWeights = path_model.toStdString(); + if (model_path.length() > 0) { + modelWeights = model_path.toStdString(); } else { - modelWeights = "../model/jd.weights"; + modelWeights = "D:/model/jd.weights"; } std::ifstream classNamesFile(classesFile.c_str()); @@ -54,11 +89,11 @@ bool AlgJd::init(QString path_model, QString path_jpg) //cv::Mat image = cv::imread("alg_jd.jpg"); cv::Mat image; - if (path_jpg.length() > 0) { - image = cv::imread(path_jpg.toStdString()); + if (jpg_path.length() > 0) { + image = cv::imread(jpg_path.toStdString()); } else { - image = cv::imread("alg_jd.jpg"); + image = cv::imread("D:/Release/alg_jd.bmp"); } //ʶһͼģǷȷGPUݼ if (!image.data) return false; //жϲͼƬǷȡ @@ -281,6 +316,7 @@ void AlgJd::detect_batch(std::vector& vec_in, std::vector &vec static void post_process_batch(std::vector& vec_frame, std::vector& outs, std::vector > > &vec_results) { int batch = vec_frame.size(); + double confidence;/// for (int k = 0; k < batch; k++) { std::vector classIds; @@ -305,7 +341,7 @@ static void post_process_batch(std::vector& vec_frame, std::vector& vec_frame, std::vector 15) + + if (confidences[idx] > g_sys_conf.ConfThreshold * 0.01)///ʶȵֵNG { - drawPred(classIds[idx], confidences[idx], box.x, box.y, - box.x + box.width, box.y + box.height, vec_frame[k]); - results.push_back(std::make_pair(classIds[idx], box)); + if (box.width > 15) + {//ʶȴ15ʾʶСΪ޽㣬NG + drawPred(classIds[idx], confidences[idx], box.x, box.y, + box.x + box.width, box.y + box.height, vec_frame[k]); + results.push_back(std::make_pair(classIds[idx], box)); + } } } diff --git a/Cigarette/alg_jd.h b/Cigarette/alg_jd.h index 9b3bc83..ac12df2 100644 --- a/Cigarette/alg_jd.h +++ b/Cigarette/alg_jd.h @@ -8,11 +8,11 @@ #include #include #include -#include "common.h" + class AlgJd { public: - bool init(QString path_model, QString path_jpg); + bool init(); bool test_detect(); bool test_detect_batcht(int shoot); int detect(cv::Mat& in, cv::Mat &out, std::vector > &results); diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index a9b4487..e6a2806 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -7,7 +7,23 @@ #include #include +// ļ +#define CONFIGURE_FILE "D:/conf/conf.txt" +// תǶļ +#define ROTATE_FILE "D:/conf/rotate.txt" +#define MODBUS_CONFIGURE_FILE "D:/conf/modbus.txt" +#define PLC_CONFIG_FILE "D:/conf/plc.txt" +#define SELECT_RECTS_FILE "D:/conf/SelectRects%d%d.txt" +#define STATISTIC_FILE "D:/conf/camera%d_statistic.txt" +#define ALARM_RECORD_FILE "alarm.txt" +#define OUTPUT_HIGH_WIDTH 20000 //źŵȣ΢ + +#define OP_TIME 300 //OPȨʱĬ300룩 + +#define ADMIN_TIME 600 //ADMINȨʱĬ300룩 + +#define STOP_SECONDS 3 //ٴβ䴥Զ int g_op_time; //OPȨʱĬ300룩 @@ -25,9 +41,7 @@ QDateTime g_ts_start; extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; AlgJd alg_jd[NumberOfSupportedCameras]; //⽺AI㷨 -#ifdef __DEBUG -AlgJd alg_test;//test AI㷨 -#endif + QThread* pThread[NumberOfSupportedCameras]; //³ @@ -279,7 +293,7 @@ Cigarette::Cigarette(QWidget *parent) { if(SingleCamInfo[i].Detect){ cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); - if (!alg_jd[i].init(g_sys_conf.path_model,g_sys_conf.path_jpg)) + if (!alg_jd[i].init()) { QMessageBox::information(NULL, QStringLiteral("ϵͳԼʧ"), QStringLiteral("AIģ1ʼʧܣ"), QMessageBox::Ok); exit(-1); @@ -287,9 +301,7 @@ Cigarette::Cigarette(QWidget *parent) CreatWorkThread(SingleCamInfo[i].CamClass, i, this); } } -#ifdef __DEBUG - alg_test.init(g_sys_conf.path_model,g_sys_conf.path_jpg); -#endif + //Զ if (g_sys_conf.auto_open == 1) { @@ -324,7 +336,7 @@ Cigarette::Cigarette(QWidget *parent) clean_pTimer = new QTimer(this); connect(clean_pTimer,SIGNAL(timeout()), this, SLOT(CleanThreadStartAuto())); - clean_pTimer->start(86400000); + clean_pTimer->start(3600000); connect(ui.label_alarm, SIGNAL(QlabelDoubleClick()), this, SLOT(OnCancelAlarm()));//ǩ˫ @@ -639,10 +651,6 @@ void Cigarette::on_btn_setup_released() { dialog_setup = new DialogSetup(this); connect(dialog_setup, SIGNAL(system_exit()), this, SLOT(OnExit())); -#ifdef __DEBUG - connect(dialog_setup, SIGNAL(_testimg()), this, SLOT(TestImg())); - connect(dialog_setup, SIGNAL(_testimgs()), this, SLOT(TestImgs())); -#endif dialog_setup->setModal(true); dialog_setup->show(); dialog_setup->move((this->width() - dialog_setup->width()) / 2, (this->height() - dialog_setup->height()) / 2); @@ -651,60 +659,7 @@ void Cigarette::on_btn_setup_released() QMessageBox::information(NULL, QStringLiteral("Ȩ޼"), QStringLiteral("ȵťԱģʽ"), QMessageBox::Ok); } } -#ifdef __DEBUG -void Cigarette::TestImg() -{ - QString srcDirPath = QString::fromStdString(SelectFileOFN()); - - //ͼ - std::cout << "open file------ " << srcDirPath.toStdString() << std::endl; - cv::Mat imagein = cv::imread(srcDirPath.toStdString(), cv::IMREAD_COLOR); - if (!imagein.data) - { - return; - } - std::vector > results; - cv::Mat output; - alg_test.detect(imagein, output,results); - cv::imshow("TestImg", output); - cv::waitKeyEx(1); -} - -void Cigarette::TestImgs() -{ - QString srcDirPath = QString::fromStdString(SelectDirIFD()); - - vector files; - std::cout << "srcDirPath=" << srcDirPath.toStdString() << std::endl; - srcDirPath += "/"; - //ȡ·µļ - getFiles(srcDirPath.toStdString() + "*.jpg", files); - if (files.size() == 0) - { - QMessageBox::StandardButton result = QMessageBox::information(NULL, QStringLiteral("ʾ"), QStringLiteral("ûҵͼƬ")); - return; - } - for (int index = 0; index < files.size(); index++) - { - //ͼ - std::cout << "open file------ " << files[index] << std::endl; - cv::Mat imagein = cv::imread(srcDirPath.toStdString() + files[index], cv::IMREAD_COLOR); - if (!imagein.data) - { - break; - } - - cv::Mat output; - std::vector > results; - alg_test.detect(imagein, output,results); - cv::imshow("TestImg", output); - int k = cv::waitKeyEx(1); - if (k == 27)break;//ESC - QCoreApplication::processEvents(); - } -} -#endif //Ա½ void Cigarette::OnAdmin() { @@ -1878,7 +1833,7 @@ void Cigarette::on_pushButton_clear_released()// QString Cigarette::read_pswd() { std::fstream cfg_file; - cfg_file.open("pswd.txt"); + cfg_file.open("D:/Release/pswd.txt"); if (!cfg_file.is_open()) { std::cout << "Error: Open config file pswd.txt"<< std::endl; @@ -1910,7 +1865,7 @@ QString Cigarette::read_pswd() QString Cigarette::read_op_pswd() { std::fstream cfg_file; - cfg_file.open("pswd_op.txt"); + cfg_file.open("D:/Release/pswd_op.txt"); if (!cfg_file.is_open()) { std::cout << "Error: Open config file pswd_op.txt" << std::endl; @@ -1970,15 +1925,19 @@ bool Cigarette::read_sys_config(SysConf &conf) { /// Ƭ conf.save_days = atoi(line.substr(pos + 1).c_str()); } - else if (tmp_key == "FREESIZE") { + else if (tmp_key == "FREESIZE") + { /// ͼƬ趨Сռֵ conf.freesize = atoi(line.substr(pos + 1).c_str()); } else if (tmp_key == "ComPort") - {/// COM + { /// COM conf.ComPort = line.substr(pos + 1); } - + else if (tmp_key == "CONFTHRESHOLD") + { ///ƶ + conf.ConfThreshold = atoi(line.substr(pos + 1).c_str()); + } else if (tmp_key == "AUTO_OPEN") { /// ǷԶ01 conf.auto_open = atoi(line.substr(pos + 1).c_str()); @@ -2028,7 +1987,7 @@ bool Cigarette::read_sys_config(SysConf &conf) } else if (tmp_key == "MODELPATH") { - conf.path_model = line.substr(pos + 1).c_str(); + conf.path = line.substr(pos + 1).c_str(); } else if (tmp_key == "JPGPATH") { diff --git a/Cigarette/cigarette.h b/Cigarette/cigarette.h index a8a1e24..7a24f1d 100644 --- a/Cigarette/cigarette.h +++ b/Cigarette/cigarette.h @@ -42,9 +42,10 @@ #include #include #include + + #include -#include class QTimer; #define OPEN true @@ -116,11 +117,8 @@ private slots : void OnOp(); void OnExit(); void OnRestart(); + void OnAdmin(); -#ifdef __DEBUG - void TestImg(); - void TestImgs(); -#endif private: Ui::CigaretteClass ui; DialogSetupPasswd *dialog_setup_passwd; diff --git a/Cigarette/common.cpp b/Cigarette/common.cpp index 892aa2e..de4e86e 100644 --- a/Cigarette/common.cpp +++ b/Cigarette/common.cpp @@ -1,8 +1,6 @@ #include "common.h" #include #include "stdarg.h" -#include - int string_split(std::string str, std::string pattern,std::vector &out) { std::string::size_type pos; @@ -115,247 +113,4 @@ bool CheckSelectRects( } } return false; -} - -void getFiles(std::string path, std::vector& files) -{ - //文件句柄 - intptr_t hFile = 0; - //文件信息 - struct _finddata_t fileinfo; - std::string p; - if ((hFile = _findfirst(p.assign(path).c_str(), &fileinfo)) != -1) - { - do - { - if (!(fileinfo.attrib & _A_SUBDIR)) - { - files.push_back(fileinfo.name); - } - } while (_findnext(hFile, &fileinfo) == 0); - _findclose(hFile); - } -} - -std::string WstringToString(std::wstring wstr) -{ - int nLen = wcslen(wstr.c_str()); - std::string str; - str.resize(nLen * 2, ' '); - int nResult = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wstr.c_str(), -1, (LPSTR)str.c_str(), nLen * 2, NULL, NULL); - return str; -} - -/* -TCHAR*转char* -*/ -char* LPWSTR2LPSTR(LPWSTR lpwszStrIn) -{ - LPSTR pszOut = NULL; - if (lpwszStrIn != NULL) { - int nInputStrLen = wcslen(lpwszStrIn); - int nOutputStrLen = WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, NULL, 0, 0, 0) + 2; - pszOut = new char[nOutputStrLen]; - if (pszOut != NULL) { - memset(pszOut, 0x00, nOutputStrLen); - WideCharToMultiByte(CP_ACP, 0, lpwszStrIn, nInputStrLen, pszOut, nOutputStrLen, 0, 0); - } - } - return pszOut; -} - -//从string s的位置pos开始,向后找,找到第一个等于x的位置返回其位置 -//找到,返回找到的位置,找不到返回-1 -int __find(const std::string s, const int start, const char x) { - if (start >= s.length())return -1; - for (int i = start; i < s.length(); ++i) { - if (s[i] == x) return i; - } - return -1; -} -//双斜杠转单斜杠 -void pathConvert_Double2Single(std::string& s) { - int start = 0; - while (start < s.length()) { - int pos = s.find('\\', start); - if (pos == -1)break; - s.replace(pos, 1,"/"); - start = pos + 1; - } -} - -int CALLBACK BrowseCallbackProc( - HWND hwnd, UINT uMsg, LPARAM /*lParam*/, LPARAM lpData) -{ - LPWSTR buf[1000]; - GetCurrentDirectory(1000, (LPWSTR)buf); - if (uMsg == BFFM_INITIALIZED) - { - SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, (LPARAM)buf); - } - - return 0; -} - -std::string SelectDirBRI() -{ - BROWSEINFO bi; - bi.hwndOwner = NULL; - bi.pidlRoot = CSIDL_DESKTOP; - bi.pszDisplayName = NULL; - bi.lpszTitle = NULL;//显?位于对话框左上部的提?信息 - bi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;//有新建?件夹按钮 - bi.lpfn = BrowseCallbackProc; - bi.iImage = 0; - LPITEMIDLIST pidl = SHBrowseForFolder(&bi);//调?选择对话框 - if (pidl == NULL) - { - std::cout << "没有选择目录" << std::endl; - return ""; - } - TCHAR strFolder[MAX_PATH]; - SHGetPathFromIDList(pidl, strFolder); - std::string sFolder = ""; - sFolder = WstringToString(strFolder); - int pos = sFolder.find('\0'); - if (pos) - { - sFolder = sFolder.substr(0, pos); - } - return sFolder; -} - -std::string SelectFileOFN() -{ - OPENFILENAME ofn;//#include - TCHAR szOpenFileNames[80 * MAX_PATH] = { 0 }; - TCHAR szPath[MAX_PATH]; - TCHAR szFileName[80 * MAX_PATH]; - - int nLen = 0; - TCHAR* p = NULL; - ZeroMemory(&ofn, sizeof(ofn)); - - // 结构体大小 - ofn.lStructSize = sizeof(ofn); - // 拥有着窗口句柄 - ofn.hwndOwner = NULL; - // 接收返回的文件名,注意第一个字符需要为NULL - ofn.lpstrFile = szOpenFileNames; - // 缓冲区长度 - ofn.nMaxFile = sizeof(szOpenFileNames); - // _T可替换为TEXT,使用_T需要引tchar.h - ofn.lpstrFile[0] = _T('\0'); - // 设置过滤 - ofn.lpstrFilter = _T("All\0*.*\0.mp4\0*.mp4\0.avi\0*.avi\0.mkv\0*.mkv\0.rmvb\0*.rmvb\0.f4v\0*.f4v\0.flv\0*.flv\0.m4v\0*.m4v\0.mpg\0*.mpg\0\0"); - // 过滤器索引 - ofn.nFilterIndex = 1; - // 窗口标题 - ofn.lpstrTitle = _T("请选择图片"); - - // 文件必须存在、允许多选、隐藏只读选项、对话框使用资源管理器风格的用户界面 - // 官方文档:https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamea - ofn.Flags = OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY | OFN_EXPLORER; - - // 如果打开文件失败,则不操作 - if (!::GetOpenFileName(&ofn)) { - return ""; - } - - // 把第一个文件名前的复制到szPath,即: - // 如果只选了一个文件,就复制到最后一个'/' - // 如果选了多个文件,就复制到第一个NULL字符 - lstrcpyn(szPath, szOpenFileNames, ofn.nFileOffset); - - // 当只选了一个文件时,下面这个NULL字符是必需的. - // 这里不区别对待选了一个和多个文件的情况 - szPath[ofn.nFileOffset] = '\0'; - nLen = lstrlen(szPath); - - // 如果选了多个文件,则必须加上'//' - if (szPath[nLen - 1] != '\\') { - lstrcat(szPath, _T("\\")); - } - - // 把指针移到第一个文件 - p = szOpenFileNames + ofn.nFileOffset; - - // 对szFileName进行清零 - ZeroMemory(szFileName, sizeof(szFileName)); - - // 定义字符串,用于拼接所选的所有文件的完整路径 - std::string str = ""; - - while (*p) { - // 读取文件名 - std::string fileName = LPWSTR2LPSTR(p); - // 读取文件所在文件夹路径 - std::string filePath = LPWSTR2LPSTR(szPath); - // 拼接文件完整路径 - std::string completePath = filePath + fileName; - // 拼接字符串 - str += completePath; - //移至下一个文件 - p += lstrlen(p) + 1; - } - - return str; - // 将string转为char* - //char* strc = new char[strlen(str.c_str()) + 1]; - //const char* cc = str.c_str(); - //strcpy_s(strc, str.size() + 1, cc); -} - -//https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog?redirectedfrom=MSDN -std::string SelectDirIFD() -{ - std::string folderpath = ""; - // CoCreate the File Open Dialog object. - IFileDialog* pfd = NULL; - HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, - NULL, - CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(&pfd)); - if (SUCCEEDED(hr)) - { - // Set the options on the dialog. - DWORD dwFlags; - - // Before setting, always get the options first in order - // not to override existing options. - hr = pfd->GetOptions(&dwFlags); - if (SUCCEEDED(hr)) - { - // In this case, get shell items only for file system items. - hr = pfd->SetOptions(dwFlags | FOS_PICKFOLDERS); - if (SUCCEEDED(hr)) - { - // Show the dialog - hr = pfd->Show(NULL); - if (SUCCEEDED(hr)) - { - // Obtain the result once the user clicks - // the 'Open' button. - // The result is an IShellItem object. - IShellItem* psiResult; - hr = pfd->GetResult(&psiResult); - if (SUCCEEDED(hr)) - { - // We are just going to print out the - // name of the file for sample sake. - PWSTR pszFilePath = NULL; - hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH,&pszFilePath); - if (SUCCEEDED(hr)) - { - folderpath = LPWSTR2LPSTR(pszFilePath); - CoTaskMemFree(pszFilePath); - } - psiResult->Release(); - } - } - } - } - pfd->Release(); - } - return folderpath; } \ No newline at end of file diff --git a/Cigarette/common.h b/Cigarette/common.h index c9574f9..95175c7 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -2,19 +2,15 @@ #include #include -#include #include "basecamera.h" +#include #include "QtCore\qdatetime.h" -#include -#include -#include -#include -#define __DEBUG //debugϢ -//#define __UDPSend //緢͹ +//#define __DEBUG //debugϢ +#define __UDPSend //緢͹ #define USB_BASLER_NEW_FW //ʹbaslerƹ̼ //#define IMM_PROCESS //պУź -//#define IMM_FEED_BACK //Уź +#define IMM_FEED_BACK //Уź //#define ONE_TIME_SHIFT //һķͷ(Ĭϴ) #define AI_WARM_UP //AIʶʼǰ //#define LICENSE_VERIFY //licenseļУ @@ -35,30 +31,8 @@ #define DEBUG(format, ...) #endif -// ļ -#define CONFIGURE_FILE "../conf/conf.txt" -// תǶļ -#define ROTATE_FILE "../conf/rotate.txt" -#define MODBUS_CONFIGURE_FILE "../conf/modbus.txt" -#define PLC_CONFIG_FILE "../conf/plc.txt" -#define SELECT_RECTS_FILE "../conf/SelectRects%d%d.txt" -#define STATISTIC_FILE "../conf/camera%d_statistic.txt" -#define ALARM_RECORD_FILE "alarm.txt" - -#define OUTPUT_HIGH_WIDTH 20000 //źŵȣ΢ - -#define OP_TIME 300 //OPȨʱĬ300룩 - -#define ADMIN_TIME 600 //ADMINȨʱĬ300룩 - -#define STOP_SECONDS 3 //ٴβ䴥Զ - int string_split(std::string str, std::string pattern,std::vector &out); std::string format(const char *pszFmt, ...); -void getFiles(std::string path, std::vector& files); -std::string SelectDirBRI(); -std::string SelectFileOFN(); -std::string SelectDirIFD(); class SysConf { public: @@ -68,6 +42,7 @@ public: int save_days; ///Ƭ int freesize; /// 趨ͼƬСռ std::string ComPort; ///COM + int ConfThreshold; //ʶ int auto_open; //ǷԶ01 int auto_work; //ǷԶʼ01 int auto_shift; //ǷԶ࣬01 @@ -76,7 +51,7 @@ public: QTime shiftB; //Bʱ QTime shiftC; //Cʱ QString location; // ڵ - QString path_model; // ģ· + QString path; // ģ· QString path_jpg; // ͼƬ· int timing_shift; //Ƿʱ࣬01 int expo[NumberOfSupportedCameras]; //عʱ䣬λ΢ @@ -99,15 +74,16 @@ public: save=0; //ͼƬǷ񱣴棬0棬1NG, 2ȫ MisMatchAct=1; //λΪ1NG,0ok save_days = 1; ///Ƭ - freesize = 10; - ComPort = "COM1"; + freesize = 10; /// 趨ͼƬСռ + ComPort = "COM1"; ///COM + ConfThreshold = 1; ///ٷֱʶ auto_open=1; //ǷԶ01 auto_work=1; //ǷԶʼ01 auto_shift=0; //ǷԶ࣬01 shift_byhand = 1; timing_shift=0; //Ƿʱ࣬01 location = ""; - path_model = ""; + path = ""; path_jpg = ""; shiftA.setHMS(0, 0, 0); shiftB.setHMS(0, 0, 0); @@ -224,5 +200,5 @@ public: uint8_t Flag[2] = {0}; std::vector RectVet[2]; }; -void DrawSelectRects(cv::Mat input, DisplayLabelConf& t_DisplayLabelConf, int Cnt); -bool CheckSelectRects(cv::Mat input, std::vector > >& VecRects, int VecCnt, DisplayLabelConf& t_DisplayLabelConf, int LabelCnt); +void DrawSelectRects(cv::Mat input, DisplayLabelConf &t_DisplayLabelConf, int Cnt); +bool CheckSelectRects(cv::Mat input, std::vector > > &VecRects,int VecCnt, DisplayLabelConf &t_DisplayLabelConf, int LabelCnt); \ No newline at end of file diff --git a/Cigarette/dialogsetup.cpp b/Cigarette/dialogsetup.cpp index 4c5312b..3264be4 100644 --- a/Cigarette/dialogsetup.cpp +++ b/Cigarette/dialogsetup.cpp @@ -28,7 +28,7 @@ void task_osk() DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) { ui.setupUi(this); InitPtrMat(); - this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动 + //this->setWindowFlags(Qt::FramelessWindowHint);//窗口可移动 for(int i=0;isetVisible(false); - ui.pushButton_testimgs->setVisible(false); -#endif } DialogSetup::~DialogSetup() { @@ -261,7 +257,7 @@ void DialogSetup::on_toolButton_choose_path_released() { else { if (ui.comboBox->findText(WeightsPath) == -1) { ui.comboBox->addItem(WeightsPath); // 在comboBox中显示文件路径 - g_sys_conf.path_model = WeightsPath; // 将选择的路径写入conf配置文件中 + g_sys_conf.path = WeightsPath; // 将选择的路径写入conf配置文件中 } } } @@ -282,7 +278,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() { void DialogSetup::write_pswd() { std::fstream cfg_file; - cfg_file.open("pswd.txt", std::ios::out | std::ios::trunc); + cfg_file.open("D:/Release/pswd.txt", std::ios::out | std::ios::trunc); if (cfg_file.good()) { char buf[256]; @@ -295,7 +291,7 @@ void DialogSetup::write_pswd() void DialogSetup::write_pswd_op() { std::fstream cfg_file; - cfg_file.open("pswd_op.txt", std::ios::out | std::ios::trunc); + cfg_file.open("D:/Release/pswd_op.txt", std::ios::out | std::ios::trunc); if (cfg_file.good()) { char buf[256]; @@ -308,7 +304,7 @@ void DialogSetup::write_pswd_op() void DialogSetup::write_config() { std::fstream cfg_file; - cfg_file.open("../conf/conf.txt", std::ios::out | std::ios::trunc); + cfg_file.open("D:/conf/conf.txt", std::ios::out | std::ios::trunc); if (cfg_file.good()) { char buf[256]; @@ -324,6 +320,12 @@ void DialogSetup::write_config() memset(buf, 0, 256);/// sprintf(buf, "FREESIZE=%d\n", g_sys_conf.freesize); cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256);/// + sprintf(buf, "ComPort=%s\n", g_sys_conf.ComPort); + cfg_file.write(buf, strlen(buf)); + memset(buf, 0, 256);/// + sprintf(buf, "CONFTHRESHOLD=%d\n", g_sys_conf.ConfThreshold); + cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); sprintf(buf, "AUTO_OPEN=%d\n", g_sys_conf.auto_open); cfg_file.write(buf, strlen(buf)); @@ -352,7 +354,7 @@ void DialogSetup::write_config() sprintf(buf, "LOCATION=%s\n", g_sys_conf.location.toStdString().c_str()); cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); - sprintf(buf, "MODELPATH=%s\n", g_sys_conf.path_model.toStdString().c_str()); + sprintf(buf, "MODELPATH=%s\n", g_sys_conf.path.toStdString().c_str()); cfg_file.write(buf, strlen(buf)); memset(buf, 0, 256); sprintf(buf, "JPGPATH=%s\n", g_sys_conf.path_jpg.toStdString().c_str()); @@ -621,13 +623,3 @@ void DialogSetup::recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC) g_sys_conf.shiftB.setHMS(timeB.hour(), timeB.minute(), 0); g_sys_conf.shiftC.setHMS(timeC.hour(), timeC.minute(), 0); } -#ifdef __DEBUG -void DialogSetup::on_pushButton_testimg_released() -{ - emit _testimg(); -} -void DialogSetup::on_pushButton_testimgs_released() -{ - emit _testimgs(); -} -#endif \ No newline at end of file diff --git a/Cigarette/dialogsetup.hpp b/Cigarette/dialogsetup.hpp index 9e39c27..2095575 100644 --- a/Cigarette/dialogsetup.hpp +++ b/Cigarette/dialogsetup.hpp @@ -2,7 +2,7 @@ #include #include "ui_dialogsetup.h" #include "basecamera.h" -#include + #include #include #include @@ -14,10 +14,7 @@ signals : void sendMsgToShift(QTime timeA, QTime timeB, QTime timeC); void sendMsgToOutput(); void sendMsgToConfig(int ptr[][3]); -#ifdef __DEBUG - void _testimg(); - void _testimgs(); -#endif + private slots : void on_toolButton_keyboard_released(); void on_pushButton_exit_released(); @@ -42,10 +39,6 @@ private slots : void recMsgFromDialogConfig(int ptr[][3]); void recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC); -#ifdef __DEBUG - void on_pushButton_testimg_released(); - void on_pushButton_testimgs_released(); -#endif public: DialogSetup(QWidget * parent = Q_NULLPTR); ~DialogSetup(); diff --git a/Cigarette/dialogsetup.ui b/Cigarette/dialogsetup.ui index b29c2d2..a196ed4 100644 --- a/Cigarette/dialogsetup.ui +++ b/Cigarette/dialogsetup.ui @@ -6,8 +6,8 @@ 0 0 - 690 - 830 + 679 + 800 @@ -28,17 +28,11 @@ 0 - 0 - 690 - 830 + -10 + 681 + 831 - - - 0 - 0 - - 0 @@ -52,21 +46,15 @@ 0 - -72 - 675 - 900 + 0 + 670 + 880 - - - 0 - 0 - - 670 - 900 + 880 @@ -2003,46 +1991,6 @@ 清理图片 - - - - 530 - 820 - 131 - 21 - - - - - 微软雅黑 - 75 - true - - - - 测试单张图片 - - - - - - 530 - 850 - 131 - 21 - - - - - 微软雅黑 - 75 - true - - - - 测试多张图片 - - diff --git a/Cigarette/main.cpp b/Cigarette/main.cpp index e4b551d..05627df 100644 --- a/Cigarette/main.cpp +++ b/Cigarette/main.cpp @@ -9,14 +9,14 @@ int main(int argc, char *argv[]) { #if defined LICENSE_VERIFY - if(!VerifyLicense(addtime)) + if(!VerifyLicense()) { exit(0); } #endif qRegisterMetaType("cv::Mat"); QApplication a(argc, argv); - QPixmap pixmap("splash.jpg"); + QPixmap pixmap("D:/Release/splash.jpg"); QSplashScreen splash(pixmap); splash.show(); a.processEvents(); diff --git a/Cigarette/workthread.cpp b/Cigarette/workthread.cpp index 580c6be..7f0ff85 100644 --- a/Cigarette/workthread.cpp +++ b/Cigarette/workthread.cpp @@ -53,6 +53,7 @@ void WorkThread::run() local_SysConf.save = g_sys_conf.save; local_SysConf.shoot[local_camera_number] = g_sys_conf.shoot[local_camera_number]; local_SysConf.MisMatchAct = g_sys_conf.MisMatchAct; + local_SysConf.ConfThreshold = g_sys_conf.ConfThreshold;// for (int i = 0; i < 3; i++)local_SysConf.no[local_camera_number][i] = g_sys_conf.no[local_camera_number][i]; std::lock_guard locker2(g_display_label_conf[local_camera_number].lock); @@ -132,8 +133,9 @@ void WorkThread::run() bool IsNG = false; for(int index=0;indexput(std::make_pair(file_name.toStdString(), m)); + cv::Mat m = vec_in[index].clone(); + QString file_name = "D:/image/" + + now_ts.toString("yyyy-MM-dd") + + "/" + QString::number(local_camera_number + 1) + + "/ng/" + QString::number(index) + "/" + + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp"; + g_save_queue->put(std::make_pair(file_name.toStdString(), m)); - m = vec_out[index].clone(); - file_name = "D:/image/" + - now_ts.toString("yyyy-MM-dd") + - "/" + QString::number(local_camera_number + 1) + - "/ng_result/" + QString::number(index)+ "/" + - now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp"; - g_save_queue->put(std::make_pair(file_name.toStdString(), m)); - } + m = vec_out[index].clone(); + file_name = "D:/image/" + + now_ts.toString("yyyy-MM-dd") + + "/" + QString::number(local_camera_number + 1) + + "/ng_result/" + QString::number(index) + "/" + + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp"; + g_save_queue->put(std::make_pair(file_name.toStdString(), m)); } } } diff --git a/conf/conf.txt b/conf/conf.txt index eb21086..ede4121 100644 --- a/conf/conf.txt +++ b/conf/conf.txt @@ -1,75 +1,76 @@ SAVE=0 MISMATCHACT=1 -SAVE_DAYS=1 +SAVE_DAYS=7 FREESIZE=10 -ComPort=COM2 +ComPort=COM1 +CONFTHRESHOLD=1 AUTO_OPEN=1 AUTO_WORK=1 AUTO_SHIFT=0 -TIMING_SHIFT=0 +TIMING_SHIFT=1 SHIFT_BYHAND=1 -SHIFT_A=1|0 -SHIFT_B=2|0 -SHIFT_C=3|0 -LOCATION=CDTHV1.0 -MODELPATH=D:/model/jd.weights -JPGPATH=D:/Release455/alg_jd.jpg +SHIFT_A=10|19 +SHIFT_B=10|21 +SHIFT_C=10|23 +LOCATION=CDTHV1.0.1 +MODELPATH= +JPGPATH= ***************************************** -EXPO1=500 +EXPO1=1000 GAIN1=0 FILTER1=500 -USERID1=0 -NO1=3|0|0 -SHOOT1=1 +USERID1=1 +NO1=1|1|1 +SHOOT1=3 ***************************************** EXPO2=500 GAIN2=0 FILTER2=500 -USERID2=1 -NO2=2|1|0 -SHOOT2=1 +USERID2=4 +NO2=0|0|0 +SHOOT2=3 ***************************************** EXPO3=500 GAIN3=0 FILTER3=500 -USERID3=2 -NO3=2|1|0 -SHOOT3=1 +USERID3=255 +NO3=0|0|0 +SHOOT3=3 ***************************************** EXPO4=500 GAIN4=0 FILTER4=500 -USERID4=3 +USERID4=2 NO4=0|0|0 -SHOOT4=1 +SHOOT4=3 ***************************************** -EXPO5=555 +EXPO5=2000 GAIN5=0 FILTER5=500 -USERID5=4 +USERID5=255 NO5=0|0|0 -SHOOT5=1 +SHOOT5=3 ***************************************** -EXPO6=555 +EXPO6=2000 GAIN6=0 FILTER6=500 -USERID6=5 +USERID6=255 NO6=0|0|0 -SHOOT6=1 +SHOOT6=3 ***************************************** -EXPO7=555 +EXPO7=2000 GAIN7=0 FILTER7=500 -USERID7=6 +USERID7=255 NO7=0|0|0 -SHOOT7=1 +SHOOT7=3 ***************************************** -EXPO8=555 -GAIN8=2 -FILTER8=666 -USERID8=7 +EXPO8=2000 +GAIN8=0 +FILTER8=500 +USERID8=255 NO8=0|0|0 -SHOOT8=1 +SHOOT8=3 ***************************************** -MonitorIP=192.168.1.118 +MonitorIP=192.168.1.144 MonitorPort=1234 diff --git a/conf/modbus.txt b/conf/modbus.txt index 2085fa2..48ea3a0 100644 --- a/conf/modbus.txt +++ b/conf/modbus.txt @@ -1,7 +1,7 @@ -KICK1=46112 +KICK1=46118 KICK2=46114 KICK3=46116 -KICK4=46118 +KICK4=46112 KICK5=46120 KICK6=46122 KICK7=46124 @@ -9,6 +9,7 @@ KICK8=46126 QUANTITY=46008 SHIFT=30100 WORK=30101 +SEND_MESSAGE=30200 NO_KICK=37102 DEBUG=30103 RESET=30104 diff --git a/conf/plc.txt b/conf/plc.txt index 72a2925..2179e4c 100644 --- a/conf/plc.txt +++ b/conf/plc.txt @@ -1,13 +1,13 @@ ʵʹ|0|0|******************** -ٶ|46712|6000|Χ0Hz~200KHz +ٶ|46712|1600|Χ0Hz~200KHz УON|47000|450| УOFF|47002|900|½ 1#1ON|47004|500| 1#1OFF|47006|520|½ -1#2ON|47008|1650| -1#2OFF|47010|1670|½ -1#3ON|47012|1800| -1#3OFF|47014|1820|½ +1#2ON|47008|600| +1#2OFF|47010|620|½ +1#3ON|47012|700| +1#3OFF|47014|720|½ ֳ޸|0|0|******************** ʼ/ͣ|30101|0|1ʼ0ͣ |46018|0|0ޱο @@ -24,4 +24,3 @@ 2ͨ|46610|80|Χ0~255 3ͨ|46620|111|Χ0~255 4ͨ|46630|111|Χ0~255 - diff --git a/conf/rotate.txt b/conf/rotate.txt index ac242eb..ee1035c 100644 --- a/conf/rotate.txt +++ b/conf/rotate.txt @@ -1 +1 @@ -1,2,1,3,1,2,1,0,1,3,1,3,1,3,1,3, \ No newline at end of file +0,3,0,3,0,3,0,3,0,3,0,3,0,3,0,3, \ No newline at end of file