diff --git a/Src/Config.cpp b/Src/Config.cpp index d06efff9ec5c57bdc073c6d120e6e381f51fca83..4946b5e243ad65f7e1aa088aeae904ea6a09e8d7 100644 --- a/Src/Config.cpp +++ b/Src/Config.cpp @@ -56,9 +56,7 @@ void Config::load(QString dir, QString file) config->SizeDilate = tree.get<int>(globalPrefix+"SizeDilate",config->SizeDilate); config->MinBlobSize = tree.get<int>(globalPrefix+"MinBlobSize",config->MinBlobSize); config->MaxBlobSize = tree.get<int>(globalPrefix+"MaxBlobSize",config->MaxBlobSize); - config->Mog2History = tree.get<int>(globalPrefix+"Mog2History",config->Mog2History); - config->Mog2VarThresh = tree.get<int>(globalPrefix+"Mog2VarThresh",config->Mog2VarThresh); - config->Mog2BackgroundRatio = tree.get<double>(globalPrefix+"Mog2BackgroundRatio",config->Mog2BackgroundRatio); + config->BackgroundRatio = tree.get<double>(globalPrefix+"BackgroundRatio",config->BackgroundRatio); config->DoNetwork = tree.get<int>(globalPrefix+"DoNetwork",config->DoNetwork); config->NetworkPort = tree.get<int>(globalPrefix+"NetworkPort",config->NetworkPort); config->DoBackground = tree.get<int>(globalPrefix+"DoBackground",config->DoBackground); @@ -84,9 +82,7 @@ void Config::save(QString dir, QString file) tree.put(globalPrefix+"SizeDilate", config->SizeDilate); tree.put(globalPrefix+"MinBlobSize", config->MinBlobSize); tree.put(globalPrefix+"MaxBlobSize", config->MaxBlobSize); - tree.put(globalPrefix+"Mog2History", config->Mog2History); - tree.put(globalPrefix+"Mog2VarThresh", config->Mog2VarThresh); - tree.put(globalPrefix+"Mog2BackgroundRatio", config->Mog2BackgroundRatio); + tree.put(globalPrefix+"BackgroundRatio", config->BackgroundRatio); tree.put(globalPrefix+"DoNetwork", config->DoNetwork); tree.put(globalPrefix+"NetworkPort", config->NetworkPort); tree.put(globalPrefix+"DoBackground", config->DoBackground); diff --git a/Src/Config.h b/Src/Config.h index 06543eafb59e6045d2ba133a1491150f54e6da91..db181caf418a7c0d903a295f79f74a805f22ac73 100644 --- a/Src/Config.h +++ b/Src/Config.h @@ -13,9 +13,7 @@ public: int MinBlobSize = 40; int MaxBlobSize = 999999; - int Mog2History = 200; - int Mog2VarThresh = 64; - double Mog2BackgroundRatio = 0.05; + double BackgroundRatio = 0.05; int DoNetwork = false; int NetworkPort = 54444; diff --git a/Src/Model/BioTrackerTrackingAlgorithm.cpp b/Src/Model/BioTrackerTrackingAlgorithm.cpp index 7d99a09cd271bebb95e0c232ca9736110af3a7e4..36dd0769d7738b65f6be0003a02067d3f82bbf7c 100644 --- a/Src/Model/BioTrackerTrackingAlgorithm.cpp +++ b/Src/Model/BioTrackerTrackingAlgorithm.cpp @@ -69,35 +69,33 @@ void BioTrackerTrackingAlgorithm::sendSelectedImage(std::map<std::string, std::s //Send forth whatever the user selected switch (_TrackingParameter->getSendImage()) { case 0: //Send none - //sendImage = images.find(std::string("Original"))->second; - //Q_EMIT emitCvMatA(sendImage, QString("Original")); Q_EMIT emitChangeDisplayImage("Original"); break; case 1: + sendImage = images->find(std::string("Background"))->second; + Q_EMIT emitCvMatA(sendImage, QString("Background")); + Q_EMIT emitChangeDisplayImage(QString("Background")); + break; + case 2: + sendImage = images->find(std::string("Foreground"))->second; + Q_EMIT emitCvMatA(sendImage, QString("Foreground")); + Q_EMIT emitChangeDisplayImage(QString("Foreground")); + break; + case 3: sendImage = images->find(std::string("Binarized"))->second; Q_EMIT emitCvMatA(sendImage, QString("Binarized")); Q_EMIT emitChangeDisplayImage(QString("Binarized")); break; - case 2: + case 4: sendImage = images->find(std::string("Eroded"))->second; Q_EMIT emitCvMatA(sendImage, QString("Eroded")); Q_EMIT emitChangeDisplayImage(QString("Eroded")); break; - case 3: + case 5: sendImage = images->find(std::string("Dilated"))->second; Q_EMIT emitCvMatA(sendImage, QString("Dilated")); Q_EMIT emitChangeDisplayImage(QString("Dilated")); break; - case 4: - sendImage = images->find(std::string("Difference"))->second; - Q_EMIT emitCvMatA(sendImage, QString("Difference")); - Q_EMIT emitChangeDisplayImage(QString("Difference")); - break; - case 5: - sendImage = images->find(std::string("Background"))->second; - Q_EMIT emitCvMatA(sendImage, QString("Background")); - Q_EMIT emitChangeDisplayImage(QString("Background")); - break; } } @@ -134,17 +132,8 @@ std::vector<BlobPose> BioTrackerTrackingAlgorithm::getContourCentroids(cv::Mat& return centroids; } -#define EEE duration = std::chrono::duration_cast< std::chrono::milliseconds> (std::chrono::steady_clock::now() - startt); block++; std::cout << "Block " << block << ": " << duration.count() << std::endl; -#define SSS startt = std::chrono::steady_clock::now(); - void BioTrackerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> p_image, uint framenumber) { - //Q_EMIT emitCvMatA(p_image, QString("Original")); - //Q_EMIT emitChangeDisplayImage("Original"); - //Q_EMIT emitTrackingDone(framenumber); - //return; - int block = 0; - _ipp.m_TrackingParameter = _TrackingParameter; _lastImage = p_image; _lastFramenumber = framenumber; @@ -172,7 +161,6 @@ void BioTrackerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> p_image, u //The user changed the # of fish. Reset the history and start over! if (_noFish != _TrackedTrajectoryMajor->validCount()) { _noFish = _TrackedTrajectoryMajor->validCount(); - //resetFishHistory(_noFish); _nn2d = std::make_shared<NN2dMapper>(_TrackedTrajectoryMajor); } diff --git a/Src/Model/BioTrackerTrackingAlgorithm.h b/Src/Model/BioTrackerTrackingAlgorithm.h index e9562c6cd14f29272251df4de5521aaf02d04f50..8518aa0117221f3b5623ece8e51e9553f424b4ef 100644 --- a/Src/Model/BioTrackerTrackingAlgorithm.h +++ b/Src/Model/BioTrackerTrackingAlgorithm.h @@ -56,9 +56,6 @@ std::vector<BlobPose> getContourCentroids(cv::Mat& image, int minSize); BlobsDetector _bd; std::shared_ptr<NN2dMapper> _nn2d; - // background subtraction - cv::Ptr<cv::BackgroundSubtractorMOG2> _pMOG; - int _noFish; //std::ofstream _ofs; diff --git a/Src/Model/TrackerParameter.cpp b/Src/Model/TrackerParameter.cpp index 7ce5891341484c5f19fa37fe96e58e1985012746..97fe16026e433c0265941a2f65a25444821289ab 100644 --- a/Src/Model/TrackerParameter.cpp +++ b/Src/Model/TrackerParameter.cpp @@ -14,15 +14,11 @@ TrackerParameter::TrackerParameter(QObject *parent) : _MinBlobSize = _cfg->MinBlobSize; _MaxBlobSize = _cfg->MaxBlobSize; - _mog2History = _cfg->Mog2History; - _mog2VarThresh = _cfg->Mog2VarThresh; - _mog2BackgroundRatio = _cfg->Mog2BackgroundRatio; + _BackgroundRatio = _cfg->BackgroundRatio; _doNetwork = _cfg->DoNetwork; _networkPort = _cfg->NetworkPort; - _Threshold = 12345; - _doBackground = true; _sendImage = 0; //Send no image _resetBackground = false; @@ -30,18 +26,6 @@ TrackerParameter::TrackerParameter(QObject *parent) : Q_EMIT notifyView(); } -void TrackerParameter::setThreshold(int x) -{ - _Threshold = x; - - Q_EMIT notifyView(); -} - -int TrackerParameter::getThreshold() -{ - return _Threshold; -} - void TrackerParameter::setBinarizationThreshold(int x) { _BinarizationThreshold = x; diff --git a/Src/Model/TrackerParameter.h b/Src/Model/TrackerParameter.h index 5bc97360cb54a254863c57209627dfff1c0f5ad8..0e4faf01f82cd5a9fd3372cde4b6b63e2fde688b 100644 --- a/Src/Model/TrackerParameter.h +++ b/Src/Model/TrackerParameter.h @@ -4,7 +4,6 @@ #include "Interfaces/IModel/IModel.h" #include "../Config.h" -#include "TrackingAlgorithm/ParamNames.h" class TrackerParameter : public IModel { @@ -12,9 +11,7 @@ class TrackerParameter : public IModel public: TrackerParameter(QObject *parent = 0); - void setThreshold(int x); - - int getThreshold(); +public slots: void setBinarizationThreshold(int x); int getBinarizationThreshold(); @@ -31,21 +28,9 @@ public: Q_EMIT notifyView(); }; - int getmog2History() { return _mog2History; }; - void setmog2History(int x) { - _mog2History = x; - Q_EMIT notifyView(); - }; - - int getmog2VarThresh() { return _mog2VarThresh; }; - void setmog2VarThresh(int x) { - _mog2VarThresh = x; - Q_EMIT notifyView(); - }; - - double getmog2BackgroundRatio() { return _mog2BackgroundRatio; }; - void setmog2BackgroundRatio(double x) { - _mog2BackgroundRatio = x; + double getBackgroundRatio() { return _BackgroundRatio; }; + void setBackgroundRatio(double x) { + _BackgroundRatio = x; Q_EMIT notifyView(); }; @@ -99,23 +84,17 @@ public: void setAll( - int Threshold, int BinarizationThreshold, int SizeErode, int SizeDilate, - int mog2History, - int mog2VarThresh, - double mog2BackgroundRatio, + double BackgroundRatio, int minBlobSize, int maxBlobSize) { - _Threshold = Threshold; _BinarizationThreshold = BinarizationThreshold; _SizeErode = SizeErode; _SizeDilate = SizeDilate; - _mog2History = mog2History; - _mog2VarThresh = mog2VarThresh; - _mog2BackgroundRatio = mog2BackgroundRatio; + _BackgroundRatio = BackgroundRatio; _MinBlobSize = minBlobSize; _MaxBlobSize = maxBlobSize; _cfg->BinarizationThreshold = BinarizationThreshold; @@ -123,9 +102,7 @@ public: _cfg->SizeDilate = SizeDilate; _cfg->MinBlobSize = minBlobSize; _cfg->MaxBlobSize = maxBlobSize; - _cfg->Mog2History = mog2History; - _cfg->Mog2VarThresh = mog2VarThresh; - _cfg->Mog2BackgroundRatio = mog2BackgroundRatio; + _cfg->BackgroundRatio = BackgroundRatio; Q_EMIT notifyView(); }; @@ -133,13 +110,10 @@ public: private: - int _Threshold; int _BinarizationThreshold; int _SizeErode; int _SizeDilate; - int _mog2History; - int _mog2VarThresh; - double _mog2BackgroundRatio; + double _BackgroundRatio; int _MinBlobSize; int _MaxBlobSize; diff --git a/Src/Model/TrackingAlgorithm/ParamNames.h b/Src/Model/TrackingAlgorithm/ParamNames.h deleted file mode 100644 index 7e7a5879981c181b44500b9c0d4894884c769b31..0000000000000000000000000000000000000000 --- a/Src/Model/TrackingAlgorithm/ParamNames.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once - -#include <iostream> -#include <vector> - - -namespace CONFIGPARAM -{ - // System config - const std::string CONFIG_INI_FILE = "./BSTrackerConfig.ini"; -} - -namespace APPLICATIONPARAM -{ - // System config - const std::string APP_VERSION = "APPLICATIONPARAM/APP_VERSION"; -} - -namespace TRACKERPARAM -{ - - // Parameter for the opencv BackgroundSubtractorMOG2 class - const std::string BG_MOG2_HISTORY = "TRACKERPARAM/BG_MOG2_HISTORY"; - const std::string BG_MOG2_VAR_THRESHOLD = "TRACKERPARAM/BG_MOG2_VAR_THRESHOLD"; - const std::string BG_MOG2_BACKGROUND_RATIO = "TRACKERPARAM/BG_MOG2_BACKGROUND_RATIO"; - - // Blob dectection issue - const std::string MAX_BLOB_SIZE = "TRACKERPARAM/MAX_BLOB_SIZE"; - const std::string MIN_BLOB_SIZE = "TRACKERPARAM/MIN_BLOB_SIZE"; - - // Parameters for image pre-processing step - const std::string SIZE_ERODE = "TRACKERPARAM/SIZE_ERODE"; - const std::string SIZE_DILATE = "TRACKERPARAM/SIZE_DILATE"; - const std::string THRESHOLD_BINARIZING = "TRACKERPARAM/THRESHOLD_BINARIZING"; - //const std::string GAUSSIAN_BLUR_SIZE = "TRACKERPARAM/GAUSSIAN_BLUR_SIZE"; -} - -namespace GUIPARAM -{ - // FPS label - const std::string ENABLE_LABEL_FPS = "GUIPARAM/ENABLE_LABEL_FPS"; - // Fish id label - const std::string ENABLE_LABEL_FISH_ID = "GUIPARAM/ENABLE_LABEL_FISH_ID"; - // Replica marker - const std::string ENABLE_LABEL_REPLICA = "GUIPARAM/ENABLE_LABEL_REPLICA"; - // Fish position - const std::string ENABLE_LABEL_FISH_POS = "GUIPARAM/ENABLE_LABEL_FISH_POS"; - // Fish orientation - const std::string ENABLE_LABEL_FISH_ORI = "GUIPARAM/ENABLE_LABEL_FISH_ORI"; - // Fish history - const std::string ENABLE_LABEL_FISH_HISTORY = "GUIPARAM/ENABLE_LABEL_FISH_HISTORY"; - // Blobs - const std::string ENABLE_SHOW_BLOBS = "GUIPARAM/ENABLE_SHOW_BLOBS"; - // Swap fish id - const std::string ENABLE_SWAP_FISH_ID = "GUIPARAM/ENABLE_SWAP_FISH_ID"; - - - - // Core view of tracked components - const std::string ENABLE_CORE_COMPONENT_VIEW = "GUIPARAM/ENABLE_CORE_COMPONENT_VIEW"; - // Move components in core view - const std::string ENABLE_CORE_COMPONENT_MOVE = "GUIPARAM/ENABLE_CORE_COMPONENT_MOVE"; - // Remove components in core view - const std::string ENABLE_CORE_COMPONENT_REMOVE = "GUIPARAM/ENABLE_CORE_COMPONENT_REMOVE"; - // Swap component id in core view - const std::string ENABLE_CORE_COMPONENT_ID_SWAP = "GUIPARAM/ENABLE_CORE_COMPONENT_ID_SWAP"; - // Add component in core view - const std::string ENABLE_CORE_COMPONENT_ADD = "GUIPARAM/ENABLE_CORE_COMPONENT_ADD"; - // Rotate component in core view - const std::string ENABLE_CORE_COMPONENT_ROTATE = "GUIPARAM/ENABLE_CORE_COMPONENT_ROTATE"; -} - -namespace FISHTANKPARAM -{ - // Tank area - const std::string FISHTANK_AREA_WIDTH = "FISHTANKPARAM/FISHTANK_AREA_WIDTH"; - const std::string FISHTANK_AREA_HEIGHT = "FISHTANKPARAM/FISHTANK_AREA_HEIGHT"; - const std::string FISHTANK_FISH_AMOUNT = "FISHTANKPARAM/FISHTANK_FISH_AMOUNT"; - const std::string FISHTANK_AREA_CORNER1 = "FISHTANKPARAM/FISHTANK_AREA_CORNER1"; - const std::string FISHTANK_AREA_CORNER2 = "FISHTANKPARAM/FISHTANK_AREA_CORNER2"; - const std::string FISHTANK_AREA_CORNER3 = "FISHTANKPARAM/FISHTANK_AREA_CORNER3"; - const std::string FISHTANK_AREA_CORNER4 = "FISHTANKPARAM/FISHTANK_AREA_CORNER4"; - const std::string FISHTANK_ENABLE_NETWORKING = "FISHTANKPARAM/FISHTANK_ENABLE_NETWORKING"; - const std::string FISHTANK_NETWORKING_PORT = "FISHTANKPARAM/FISHTANK_NETWORKING_PORT"; -} - diff --git a/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.cpp b/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.cpp index e0ae07b2bd63311b7e8af12d411a7cb399a279e8..b44a2536da158ed36126510e8bc210c764cfb303 100644 --- a/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.cpp +++ b/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.cpp @@ -8,11 +8,9 @@ QMutex bgsMutex; QMutex oriImageMutex; QMutex initBgkFrameNumMutex; -QMutex mog2Mutex; ImagePreProcessor::ImagePreProcessor(TrackerParameter* p_TrackingParameter) : - _maxBackgroundImageInitTime(0), //BG_MOG2_INIT_FRAME_NUMBER TODO - _bkgSubMethodMog2(false) + _maxBackgroundImageInitTime(0) { _TrackingParameter = p_TrackingParameter; init(); @@ -41,11 +39,6 @@ void ImagePreProcessor::init() m_backgroundImage = std::make_shared<cv::Mat>(); m_foregroundImage = std::make_shared<cv::Mat>(); - - _pMOG = cv::createBackgroundSubtractorMOG2( - _TrackingParameter->getmog2History(), - _TrackingParameter->getmog2VarThresh(), - true); //Shadow detection _backgroundSubtractionEnabled = true; _backgroundEnabled = true; @@ -107,24 +100,11 @@ cv::Mat ImagePreProcessor::dilate(cv::Mat& image) cv::Mat ImagePreProcessor::backgroundSubtraction(cv::Mat& image) { - if (false)//(isEnabledMog2()) - { - //QMutexLocker locker(&bgsMutex); - cv::Mat fgMaskMOG; - _pMOG->setBackgroundRatio(m_TrackingParameter->getmog2BackgroundRatio()); - - _pMOG->apply(image, fgMaskMOG); //fg mask generated by MOG method - _pMOG->getBackgroundImage(*m_backgroundImage); - return fgMaskMOG; - } - - // otherwise, custom background subtraction - if (!m_backgroundImage->data) image.copyTo(*m_backgroundImage); // calculate the image difference - const double alpha = m_TrackingParameter->getmog2BackgroundRatio(); + const double alpha = m_TrackingParameter->getBackgroundRatio(); const int &imageWidth = m_backgroundImage->cols; const int &imageHeight = m_backgroundImage->rows; @@ -171,7 +151,6 @@ std::map<std::string, std::shared_ptr<cv::Mat>> ImagePreProcessor::preProcess(st std::shared_ptr<cv::Mat> binarizedImage = std::make_shared<cv::Mat>(); std::shared_ptr<cv::Mat> erodedImage = std::make_shared<cv::Mat>(); std::shared_ptr<cv::Mat> dilatedImage = std::make_shared<cv::Mat>(); - //cv::Mat test; cv::cvtColor(*p_image, *greyMat, cv::COLOR_BGR2GRAY); @@ -190,7 +169,7 @@ std::map<std::string, std::shared_ptr<cv::Mat>> ImagePreProcessor::preProcess(st std::map<std::string, std::shared_ptr<cv::Mat>> all; all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Greyscale"), greyMat)); all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Background"), m_backgroundImage)); - all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Difference"), m_foregroundImage)); + all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Foreground"), m_foregroundImage)); all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Binarized"), binarizedImage)); all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Eroded"), erodedImage)); all.insert(std::pair<std::string, std::shared_ptr<cv::Mat>>(std::string("Dilated"), dilatedImage)); @@ -203,14 +182,3 @@ void ImagePreProcessor::resetBackgroundImage() // this will reset the background at the next opportunity init(); } - -bool ImagePreProcessor::isEnabledMog2() -{ - return _bkgSubMethodMog2; -} - -void ImagePreProcessor::setEnabledMog2(bool enable) -{ - QMutexLocker locker(&mog2Mutex); - _bkgSubMethodMog2 = enable; -} diff --git a/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.h b/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.h index 7a8d55eae4e7cbe78ad3f192a96031c7ad1098f1..70b6709c7d5a22066eaf90cc65fab6d883cc0ec3 100644 --- a/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.h +++ b/Src/Model/TrackingAlgorithm/imageProcessor/preprocessor/ImagePreProcessor.h @@ -81,13 +81,9 @@ private: cv::Mat _outputImage; - int m_Mog2ShadowDetection = true; std::shared_ptr<cv::Mat> m_backgroundImage; std::shared_ptr<cv::Mat> m_foregroundImage; - // background subtraction - cv::Ptr<cv::BackgroundSubtractorMOG2> _pMOG; - //parameters for image pre-processing bool _backgroundSubtractionEnabled; bool _backgroundEnabled; @@ -98,14 +94,10 @@ private: bool _resetBackgroundImageEnabled; int _maxBackgroundImageInitTime; - bool _bkgSubMethodMog2; TrackerParameter* _TrackingParameter; // functions void setBkgFrameNum(int); int getBkgFrameNum(); - - void setEnabledMog2(bool); - bool isEnabledMog2(); }; diff --git a/Src/View/TrackedElementView.cpp b/Src/View/TrackedElementView.cpp index f9cdea1e16702abba5da7927cabc7c5e45b2f6b2..8b29f6afa260ed716aa0c8cb1a9b9bedea71f2dd 100644 --- a/Src/View/TrackedElementView.cpp +++ b/Src/View/TrackedElementView.cpp @@ -1,7 +1,6 @@ #include "TrackedElementView.h" #include "../Model/TrackedComponents/TrackedElement.h" #include "../Model/TrackedComponents/TrackedTrajectory.h" -#include "../Model/TrackingAlgorithm/ParamNames.h" #include "QBrush" #include "QPainter" #include "QGraphicsScene" diff --git a/Src/View/TrackerParameterView.cpp b/Src/View/TrackerParameterView.cpp index c1d9a43ef89a9772a37825e960087597f0c36159..e366d4940dcc61f190de50e8d5b96fc3b9f80750 100644 --- a/Src/View/TrackerParameterView.cpp +++ b/Src/View/TrackerParameterView.cpp @@ -3,62 +3,54 @@ #include <iostream> -TrackerParameterView::TrackerParameterView(QWidget *parent, IController *controller, IModel *model) : - IViewWidget(parent, controller, model), - _ui(new Ui::TrackerParameterView) +TrackerParameterView::TrackerParameterView(QWidget *parent, IController *controller, IModel *model) : IViewWidget(parent, controller, model), + _ui(new Ui::TrackerParameterView) { - _ui->setupUi(this); - getNotified(); + _ui->setupUi(this); + getNotified(); + auto parameter = qobject_cast<TrackerParameter *>(getModel()); - QObject::connect(_ui->lineEdit_2_binThresh, SIGNAL(valueChanged(int)), this, SLOT(on_pushButton_clicked())); - QObject::connect(_ui->lineEdit_3_SizeErode, SIGNAL(valueChanged(int)), this, SLOT(on_pushButton_clicked())); - QObject::connect(_ui->lineEdit_4_SizeDilate, SIGNAL(valueChanged(int)), this, SLOT(on_pushButton_clicked())); - QObject::connect(_ui->lineEdit_8_MinBlob, SIGNAL(valueChanged(int)), this, SLOT(on_pushButton_clicked())); - QObject::connect(_ui->lineEdit_9MaxBlob, SIGNAL(valueChanged(int)), this, SLOT(on_pushButton_clicked())); - QObject::connect(_ui->lineEdit_7_MogBack, SIGNAL(valueChanged(double)), this, SLOT(on_pushButton_clicked())); + connect(_ui->lineEdit_2_binThresh, qOverload<int>(&QSpinBox::valueChanged), parameter, &TrackerParameter::setBinarizationThreshold); + connect(_ui->lineEdit_2_binThresh, qOverload<int>(&QSpinBox::valueChanged), this, &TrackerParameterView::parametersChanged); - _ui->pushButton->setVisible(false); + connect(_ui->lineEdit_3_SizeErode, qOverload<int>(&QSpinBox::valueChanged), parameter, &TrackerParameter::setSizeErode); + connect(_ui->lineEdit_3_SizeErode, qOverload<int>(&QSpinBox::valueChanged), this, &TrackerParameterView::parametersChanged); + + connect(_ui->lineEdit_4_SizeDilate, qOverload<int>(&QSpinBox::valueChanged), parameter, &TrackerParameter::setSizeDilate); + connect(_ui->lineEdit_4_SizeDilate, qOverload<int>(&QSpinBox::valueChanged), this, &TrackerParameterView::parametersChanged); + + connect(_ui->lineEdit_8_MinBlob, qOverload<int>(&QSpinBox::valueChanged), parameter, &TrackerParameter::setMinBlobSize); + connect(_ui->lineEdit_8_MinBlob, qOverload<int>(&QSpinBox::valueChanged), this, &TrackerParameterView::parametersChanged); + + connect(_ui->lineEdit_9MaxBlob, qOverload<int>(&QSpinBox::valueChanged), parameter, &TrackerParameter::setMaxBlobSize); + connect(_ui->lineEdit_9MaxBlob, qOverload<int>(&QSpinBox::valueChanged), this, &TrackerParameterView::parametersChanged); + + connect(_ui->lineEdit_7_bgRatio, qOverload<double>(&QDoubleSpinBox::valueChanged), parameter, &TrackerParameter::setBackgroundRatio); + connect(_ui->lineEdit_7_bgRatio, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &TrackerParameterView::parametersChanged); } TrackerParameterView::~TrackerParameterView() { - delete _ui; + delete _ui; } -void TrackerParameterView::on_pushButtonResetBackground_clicked() { +void TrackerParameterView::on_pushButtonResetBackground_clicked() +{ TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); parameter->setResetBackground(true); } -void TrackerParameterView::on_comboBoxSendImage_currentIndexChanged(int v) { +void TrackerParameterView::on_comboBoxSendImage_currentIndexChanged(int v) +{ TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); parameter->setSendImage(v); parameter->setNewSelection(_ui->comboBoxSendImage->currentText().toStdString()); } - -void TrackerParameterView::on_pushButton_clicked() -{ - TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); - - int setBinarizationThreshold = _ui->lineEdit_2_binThresh->text().toInt(); - int setSizeErode = _ui->lineEdit_3_SizeErode->text().toInt(); - int setSizeDilate = _ui->lineEdit_4_SizeDilate->text().toInt(); - int setMinBlobSize = _ui->lineEdit_8_MinBlob->text().toInt(); - int setMaxBlobSize = _ui->lineEdit_9MaxBlob->text().toInt(); - - double setmog2BackgroundRatio = _ui->lineEdit_7_MogBack->value(); - - parameter->setAll(0, setBinarizationThreshold, setSizeErode, setSizeDilate, 0, 0, - setmog2BackgroundRatio, setMinBlobSize, setMaxBlobSize); - - Q_EMIT parametersChanged(); -} - void TrackerParameterView::getNotified() { - TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); + TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); int val = parameter->getBinarizationThreshold(); _ui->lineEdit_2_binThresh->setValue(val); @@ -69,8 +61,8 @@ void TrackerParameterView::getNotified() val = parameter->getSizeDilate(); _ui->lineEdit_4_SizeDilate->setValue(val); - double dval = parameter->getmog2BackgroundRatio(); - _ui->lineEdit_7_MogBack->setValue(dval); + double dval = parameter->getBackgroundRatio(); + _ui->lineEdit_7_bgRatio->setValue(dval); val = parameter->getMinBlobSize(); _ui->lineEdit_8_MinBlob->setValue(val); diff --git a/Src/View/TrackerParameterView.h b/Src/View/TrackerParameterView.h index 7362e1b5e330b75ca269a5578a11b2da34f56edb..cc3b97cd301d90334d9170631ffa61cd1391b2a1 100644 --- a/Src/View/TrackerParameterView.h +++ b/Src/View/TrackerParameterView.h @@ -17,7 +17,6 @@ public: ~TrackerParameterView(); private slots: - void on_pushButton_clicked(); void on_pushButtonResetBackground_clicked(); void on_comboBoxSendImage_currentIndexChanged(int v); diff --git a/Src/View/TrackerParameterView.ui b/Src/View/TrackerParameterView.ui index 5fc284f23ae23b44c8ae05d39ae60924b908761e..71b703d1d15e6808dd71860da89422e6a6391a0c 100644 --- a/Src/View/TrackerParameterView.ui +++ b/Src/View/TrackerParameterView.ui @@ -6,10 +6,22 @@ <rect> <x>0</x> <y>0</y> - <width>304</width> - <height>481</height> + <width>583</width> + <height>782</height> </rect> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>320</width> + <height>0</height> + </size> + </property> <property name="windowTitle"> <string>Form</string> </property> @@ -54,8 +66,8 @@ <rect> <x>0</x> <y>0</y> - <width>304</width> - <height>472</height> + <width>583</width> + <height>773</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout_4"> @@ -68,333 +80,315 @@ <item> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QFrame" name="frame"> - <property name="styleSheet"> - <string notr="true">#frame{color: #e5e5e5;}</string> - </property> - <property name="frameShape"> - <enum>QFrame::Box</enum> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Background Subtraction</string> </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <property name="bottomMargin"> - <number>5</number> - </property> - <item> - <widget class="QWidget" name="widgetBinThr" native="true"> - <property name="toolTip"> - <string>Set the binarization threshold</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Binarization Threshold</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="lineEdit_2_binThresh"> - <property name="toolTip"> - <string>Set the binarization threshold</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> + <layout class="QVBoxLayout" name="verticalLayout_4"> <item> - <widget class="Line" name="line_2"> - <property name="styleSheet"> - <string notr="true">color: #e5e5e5;</string> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <property name="formAlignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <property name="horizontalSpacing"> + <number>44</number> </property> - </widget> + <item row="0" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Background Ratio:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDoubleSpinBox" name="lineEdit_7_bgRatio"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Set the background ratio</string> + </property> + <property name="decimals"> + <number>6</number> + </property> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.001000000000000</double> + </property> + <property name="value"> + <double>0.001000000000000</double> + </property> + </widget> + </item> + </layout> </item> <item> - <widget class="QWidget" name="widgetSizeErode" native="true"> - <property name="toolTip"> - <string>Set the erosion size</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Size Erode</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="lineEdit_3_SizeErode"> - <property name="toolTip"> - <string>Set the erosion size</string> - </property> - </widget> - </item> - </layout> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>78</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushButtonResetBackground"> + <property name="toolTip"> + <string>Reset the current background</string> + </property> + <property name="text"> + <string>Reset Background</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Morphology</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_6"> <item> - <widget class="Line" name="line_3"> - <property name="styleSheet"> - <string notr="true">color: #e5e5e5;</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <layout class="QFormLayout" name="formLayout_6"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> - </widget> - </item> - <item> - <widget class="QWidget" name="widgetSizeDil" native="true"> - <property name="toolTip"> - <string>Set the dilation size</string> + <property name="horizontalSpacing"> + <number>16</number> </property> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Size Dilate</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="lineEdit_4_SizeDilate"> - <property name="toolTip"> - <string>Set the dilation size</string> - </property> - </widget> - </item> - </layout> - </widget> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Binarization Threshold:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="lineEdit_2_binThresh"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Set the binarization threshold</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Size Erosion:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="lineEdit_3_SizeErode"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Set the erosion size</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Size Dilation:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="lineEdit_4_SizeDilate"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Set the dilation size</string> + </property> + </widget> + </item> + </layout> </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>Blob Detection</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> <item> - <widget class="Line" name="line_4"> - <property name="styleSheet"> - <string notr="true">color: #e5e5e5;</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <property name="horizontalSpacing"> + <number>66</number> </property> - </widget> + <item row="0" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Min Blob Size:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="lineEdit_8_MinBlob"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Set the minimal blob size</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Max Blob Size:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QSpinBox" name="lineEdit_9MaxBlob"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Sets the maximum blob size</string> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + </layout> </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>Display</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <widget class="QWidget" name="widgetBackgroundRatio" native="true"> - <property name="toolTip"> - <string>Set the background ratio</string> + <layout class="QFormLayout" name="formLayout_4"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label_7"> + <property name="horizontalSpacing"> + <number>108</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Image:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="comboBoxSendImage"> + <property name="minimumSize"> + <size> + <width>132</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Choose which image to display for the next frames. Tracking must be actived.</string> + </property> + <property name="currentText"> + <string>Original</string> + </property> + <item> <property name="text"> - <string>Background Ratio</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="lineEdit_7_MogBack"> - <property name="toolTip"> - <string>Set the background ratio</string> - </property> - <property name="decimals"> - <number>6</number> - </property> - <property name="maximum"> - <double>1.000000000000000</double> - </property> - <property name="singleStep"> - <double>0.001000000000000</double> + <string>Original</string> </property> - <property name="value"> - <double>0.001000000000000</double> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="Line" name="line_5"> - <property name="styleSheet"> - <string notr="true">color: #e5e5e5;</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="widgetMinBlob" native="true"> - <property name="toolTip"> - <string>Set the minimal blob size</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <item> - <widget class="QLabel" name="label_8"> + </item> + <item> <property name="text"> - <string>Min Blob Size</string> + <string>Background</string> </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="lineEdit_8_MinBlob"> - <property name="toolTip"> - <string>Set the minimal blob size</string> + </item> + <item> + <property name="text"> + <string>Foreground</string> </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="Line" name="line_6"> - <property name="styleSheet"> - <string notr="true">color: #e5e5e5;</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="widgetMaxBlob" native="true"> - <property name="toolTip"> - <string>Sets the maximum blob size</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label_9"> + </item> + <item> <property name="text"> - <string>Max Blob Size</string> + <string>Binarized</string> </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="lineEdit_9MaxBlob"> - <property name="toolTip"> - <string>Sets the maximum blob size</string> + </item> + <item> + <property name="text"> + <string>Eroded</string> </property> - <property name="maximum"> - <number>10000</number> + </item> + <item> + <property name="text"> + <string>Dilated</string> </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="toolTip"> - <string>Set the parameters for the tracking plugin</string> - </property> - <property name="text"> - <string>Set Values</string> - </property> - </widget> + </item> + </widget> + </item> + </layout> </item> </layout> </widget> </item> - <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Send Image:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBoxSendImage"> - <property name="toolTip"> - <string>Choose which image to display for the next frames. Tracking must be actived.</string> - </property> - <property name="currentText"> - <string>Original</string> - </property> - <item> - <property name="text"> - <string>Original</string> - </property> - </item> - <item> - <property name="text"> - <string>Binarized</string> - </property> - </item> - <item> - <property name="text"> - <string>Eroded</string> - </property> - </item> - <item> - <property name="text"> - <string>Dilated</string> - </property> - </item> - <item> - <property name="text"> - <string>Difference</string> - </property> - </item> - <item> - <property name="text"> - <string>Background</string> - </property> - </item> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButtonResetBackground"> - <property name="toolTip"> - <string>Reset the current background</string> - </property> - <property name="text"> - <string>Reset Background</string> - </property> - </widget> - </item> <item> <spacer name="verticalSpacer"> <property name="orientation">