1 #include "colordetectorcontroller.h" 4 #include <QPluginLoader> 5 #include <imageprocessorpluginiface.h> 6 #include "circledetectorpluginmodel.h" 9 ColorDetectorController::ColorDetectorController(QObject *parent) : QObject(parent)
13 connect(
this , SIGNAL(dilationSizeChanged(
int)), processor->getDiler(), SLOT(setDilationSize(
int)));
14 connect(
this , SIGNAL(maxColorChanged(cv::Scalar)), processor->getColDetector(), SLOT(setMaxColor(cv::Scalar)));
15 connect(
this , SIGNAL(minColorChanged(cv::Scalar)), processor->getColDetector(), SLOT(setMinColor(cv::Scalar)));
16 connect(
this , SIGNAL(param1Changed(
int)), processor->getCirDetector(), SLOT(setParam1(
int)));
17 connect(
this , SIGNAL(param2Changed(
int)), processor->getCirDetector(), SLOT(setParam2(
int)));
18 connect(
this , SIGNAL(minDistChanged(
int)), processor->getCirDetector(), SLOT(setMinDist(
int)));
23 int ColorDetectorController::getMinDist()
const 28 void ColorDetectorController::setMinDist(
int value)
31 emit minDistChanged(value);
44 void ColorDetectorController::addFilter(PluginSharedPointer filter)
47 pro->addFilter(filter);
50 int ColorDetectorController::getThickness()
const 55 void ColorDetectorController::setThickness(
int value)
57 thickness = std::max(std::max(1, value), std::min(value, 20));
60 cv::Scalar ColorDetectorController::getCircleColor()
const 65 void ColorDetectorController::setCircleColor(
const cv::Scalar &value)
71 int ColorDetectorController::getParam2()
const 76 void ColorDetectorController::setParam2(
int value)
79 emit param2Changed(value);
83 int ColorDetectorController::getParam1()
const 88 void ColorDetectorController::setParam1(
int value)
91 emit param1Changed(value);
97 cv::Scalar ColorDetectorController::getMaxColor()
const 102 void ColorDetectorController::setMaxColor(
const cv::Scalar &value)
105 emit maxColorChanged(value);
109 QImage ColorDetectorController::detectObject(
const cv::Mat &t)
113 this->colored = v->getColDetector()->getDst();
114 this->dialted = v->getDiler()->getDst();
115 std::vector<cv::Vec3f> vec = v->processImage().value<std::vector<cv::Vec3f>>();
116 for(
const cv::Vec3f& i : vec){
117 emit xyrChanged(i[0], i[1], i[2]);
118 cv::Point center(round(i[0]), round(i[1]));
119 int radius = round(i[2]);
120 cv::circle(t, center, radius, circleColor, thickness, 8, 0 );
123 return Utilities::Utils::toImage(t);
126 cv::Scalar ColorDetectorController::getMinColor()
const 131 void ColorDetectorController::setMinColor(
const cv::Scalar &value)
134 emit minColorChanged(value);
138 int ColorDetectorController::getDilationSize()
const 143 void ColorDetectorController::setDilationSize(
int value)
145 dilationSize = value;
146 emit dilationSizeChanged(value);
this class is used to detect a a colored circle object(s)