|
|
|
|
@ -166,7 +166,19 @@ QString SmokeBoxIdentification::saveImage(ILImagePtr image, const cv::Mat& imgMa
|
|
|
|
|
std::wstring path = filePath.toStdWString();
|
|
|
|
|
if (!imgMat3D.empty())// 3DÏà»úÊý¾Ý
|
|
|
|
|
{
|
|
|
|
|
cv::imwrite(filePath.toStdString(), imgMat3D);
|
|
|
|
|
|
|
|
|
|
// 设置旋转中心和旋转角度
|
|
|
|
|
cv::Point2f center(imgMat3D.cols / 2.0, imgMat3D.rows / 2.0);
|
|
|
|
|
double angle = 0.0; // 旋转角度,单位为度
|
|
|
|
|
|
|
|
|
|
// 计算旋转矩阵
|
|
|
|
|
cv::Mat rotation_matrix = cv::getRotationMatrix2D(center, angle, 1.0); // 最后一个参数为缩放比例,这里不缩放
|
|
|
|
|
|
|
|
|
|
// 应用旋转矩阵进行仿射变换
|
|
|
|
|
cv::Mat rotated_image;
|
|
|
|
|
cv::warpAffine(imgMat3D, rotated_image, rotation_matrix, imgMat3D.size());
|
|
|
|
|
|
|
|
|
|
cv::imwrite(filePath.toStdString(), rotated_image);
|
|
|
|
|
int lastPos = filePath.lastIndexOf('.');
|
|
|
|
|
QString prePath = filePath.left(lastPos);
|
|
|
|
|
QString pclPath = prePath + ".pcd";
|
|
|
|
|
@ -490,6 +502,7 @@ void SmokeBoxIdentification::calculate(int stocketID)
|
|
|
|
|
|
|
|
|
|
if (!imgInfo.imageFixed->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<int> 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
|
|
|
|
|
|