diff --git a/runner17/Release/smokeBox.exe b/runner17/Release/smokeBox.exe index 41960c2..4e2fe41 100644 Binary files a/runner17/Release/smokeBox.exe and b/runner17/Release/smokeBox.exe differ diff --git a/runner17/Release/smokeBox.pdb b/runner17/Release/smokeBox.pdb index 62ca59b..202dba7 100644 Binary files a/runner17/Release/smokeBox.pdb and b/runner17/Release/smokeBox.pdb differ diff --git a/src/LXCamera.cpp b/src/LXCamera.cpp index 6867bbb..e724c01 100644 --- a/src/LXCamera.cpp +++ b/src/LXCamera.cpp @@ -58,9 +58,17 @@ bool LXCamera::openCamera() LxDeviceInfo device_info; DcHandle* handlePtr = new DcHandle(); LX_STATE lx_state = DcOpenDevice(LX_OPEN_MODE::OPEN_BY_SN, m_handle.c_str(), handlePtr, &device_info); + for(int i=0;i<10;i++){ + if (LX_SUCCESS == lx_state) { + break; + } + qDebug() << "TofCamera Open Failed重启次数="<Void()) { + QString filePath; //进行计算品规 if (m_pCategoryMatcher->smokeMatch(typeNum, imgInfo.imageFixed, stocket.id.toInt())) { @@ -500,7 +513,7 @@ void SmokeBoxIdentification::calculate(int stocketID) FileInfo fileInfo = imgInfo.saveImgInfo; QString fileName = QString("%1_%2_rlt%3").arg(fileInfo.strId) .arg(m_currtStockCheckInfo.smokeTypeNum).arg(".jpg"); - QString filePath = QString("%1\\%2").arg(dataSaveFolder).arg(fileName); + filePath = QString("%1\\%2").arg(dataSaveFolder).arg(fileName); m_pCategoryMatcher->saveResultsImage(filePath); bIsMatch = true; @@ -510,11 +523,31 @@ void SmokeBoxIdentification::calculate(int stocketID) { str = QString("[%1]:Camera %2 Match Failed!").arg(stocket.id).arg(imgInfo.cameraSn); qWarning() << str; - QString filePath = dataSaveFolder + QString("\\%1_error.jpg") + filePath = dataSaveFolder + QString("\\%1_error.jpg") .arg(stocket.smokeTypeNum); m_pCategoryMatcher->saveResultsImage(filePath); m_stocketList[stocketID].imagesPathList.append(filePath.right(filePath.length() - 1)); } + // 读取原始图像 + cv::Mat original_image = cv::imread(filePath.toStdString()); + if (original_image.empty()) { + std::cerr << "Failed to read image file!" << std::endl; + } + + // 设置压缩参数 + std::vector compression_params; + compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); + compression_params.push_back(8); // JPEG压缩质量,范围0-100 + + // 压缩图像 + bool result = cv::imwrite(filePath.toStdString(), original_image, compression_params); + + if (!result) { + std::cerr << "Failed to write compressed image file!" << std::endl; + } + + std::cout << "Image compression completed successfully." << std::endl; + } else