Initial Linux Qt OpenCV project
This commit is contained in:
35
app/src/ImageWorker.cpp
Normal file
35
app/src/ImageWorker.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "ImageWorker.h"
|
||||
|
||||
void ImageWorker::process(cv::Mat image, ImageWorker::Operation operation, double value, int dx, int dy)
|
||||
{
|
||||
if (image.empty()) {
|
||||
Q_EMIT failed(QStringLiteral("没有可处理的图片"));
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessResult result;
|
||||
switch (operation) {
|
||||
case Operation::Rotate:
|
||||
result = ImageProcessor::rotate(image, value);
|
||||
break;
|
||||
case Operation::Scale:
|
||||
result = ImageProcessor::scale(image, value);
|
||||
break;
|
||||
case Operation::Translate:
|
||||
result = ImageProcessor::translate(image, dx, dy);
|
||||
break;
|
||||
case Operation::ExtractTargets:
|
||||
result = ImageProcessor::extractTargets(image);
|
||||
break;
|
||||
case Operation::ClassifySimple:
|
||||
result = ImageProcessor::classifySimple(image);
|
||||
break;
|
||||
}
|
||||
|
||||
if (result.image.empty()) {
|
||||
Q_EMIT failed(QStringLiteral("图像处理失败"));
|
||||
return;
|
||||
}
|
||||
|
||||
Q_EMIT finished(result);
|
||||
}
|
||||
Reference in New Issue
Block a user