diff --git a/include/base/HyperHdrManager.h b/include/base/HyperHdrManager.h index 48deae2a1..1683dd071 100644 --- a/include/base/HyperHdrManager.h +++ b/include/base/HyperHdrManager.h @@ -44,6 +44,8 @@ class HyperHdrManager : public QObject bool areInstancesReady(); public slots: + void handleRequestComponent(hyperhdr::Components component, int hyperHdrInd, bool listen); + void setSmoothing(int time); void setSignalStateByCEC(bool enable); diff --git a/include/flatbuffers/server/FlatBuffersServer.h b/include/flatbuffers/server/FlatBuffersServer.h index d51c5684d..854c4e696 100644 --- a/include/flatbuffers/server/FlatBuffersServer.h +++ b/include/flatbuffers/server/FlatBuffersServer.h @@ -37,6 +37,7 @@ class FlatBuffersServer : public QObject, protected LutLoader void SignalImportFromProto(int priority, int duration, const Image& image, QString clientDescription); public slots: + void handleRequestComponent(hyperhdr::Components component, int hyperHdrInd, bool listen); void signalSetLutHandler(MemoryBuffer* lut); void handleSettingsUpdate(settings::type type, const QJsonDocument& config); void initServer(); @@ -72,4 +73,5 @@ private slots: PixelFormat _currentLutPixelFormat; int _flatbufferToneMappingMode; bool _quarterOfFrameMode; + bool _active; }; diff --git a/include/lut-calibrator/CalibrationWorker.h b/include/lut-calibrator/CalibrationWorker.h index 9e695fd1e..218004b66 100644 --- a/include/lut-calibrator/CalibrationWorker.h +++ b/include/lut-calibrator/CalibrationWorker.h @@ -54,12 +54,12 @@ class CalibrationWorker : public QObject, public QRunnable const double NITS; const double3x3& bt2020_to_sRgb; std::list> vertex; - std::atomic& weakBestScore; + std::atomic& weakBestScore; const bool lchCorrection; std::atomic& forcedExit; std::atomic& progress; public: - CalibrationWorker(BestResult* _bestResult, std::atomic& _weakBestScore, YuvConverter* _yuvConverter, const int _id, const int _krIndexStart, const int _krIndexEnd, const int _halfKDelta, const bool _precise, const int _coef, + CalibrationWorker(BestResult* _bestResult, std::atomic& _weakBestScore, YuvConverter* _yuvConverter, const int _id, const int _krIndexStart, const int _krIndexEnd, const int _halfKDelta, const bool _precise, const int _coef, const std::vector>& _sampleColors, const int _gamma, const double _gammaHLG, const double _NITS, const double3x3& _bt2020_to_sRgb, const std::list& _vertex, const bool _lchCorrection, std::atomic& _forcedExit, std::atomic& _progress) : yuvConverter(_yuvConverter), diff --git a/sources/base/HyperHdrManager.cpp b/sources/base/HyperHdrManager.cpp index 84d840e08..ac39e0dd9 100644 --- a/sources/base/HyperHdrManager.cpp +++ b/sources/base/HyperHdrManager.cpp @@ -56,6 +56,17 @@ HyperHdrManager::HyperHdrManager(const QString& rootPath) connect(&_videoBenchmark, &VideoBenchmark::SignalBenchmarkUpdate, this, &HyperHdrManager::SignalBenchmarkUpdate); connect(this, &HyperHdrManager::SignalBenchmarkCapture, &_videoBenchmark, &VideoBenchmark::benchmarkCapture); + + connect(GlobalSignals::getInstance(), &GlobalSignals::SignalRequestComponent, this, &HyperHdrManager::handleRequestComponent); +} + +void HyperHdrManager::handleRequestComponent(hyperhdr::Components component, int hyperHdrInd, bool listen) +{ + if (component == hyperhdr::Components::COMP_VIDEOGRABBER && hyperHdrInd == -1) + { + Warning(_log, "Global request to %s USB grabber", (listen) ? "resume" : "pause"); + toggleGrabbersAllInstances(listen); + } } HyperHdrManager::~HyperHdrManager() diff --git a/sources/flatbuffers/server/FlatBuffersServer.cpp b/sources/flatbuffers/server/FlatBuffersServer.cpp index 0276d01de..c58523d7d 100644 --- a/sources/flatbuffers/server/FlatBuffersServer.cpp +++ b/sources/flatbuffers/server/FlatBuffersServer.cpp @@ -34,8 +34,26 @@ FlatBuffersServer::FlatBuffersServer(std::shared_ptr netOrigin, const , _currentLutPixelFormat(PixelFormat::RGB24) , _flatbufferToneMappingMode(0) , _quarterOfFrameMode(false) + , _active(false) { connect(GlobalSignals::getInstance(), &GlobalSignals::SignalSetLut, this, &FlatBuffersServer::signalSetLutHandler, Qt::BlockingQueuedConnection); + connect(GlobalSignals::getInstance(), &GlobalSignals::SignalRequestComponent, this, &FlatBuffersServer::handleRequestComponent); +} + +void FlatBuffersServer::handleRequestComponent(hyperhdr::Components component, int hyperHdrInd, bool listen) +{ + if (component == hyperhdr::Components::COMP_FLATBUFSERVER && hyperHdrInd == -1 && _active) + { + Warning(_log, "Global request to %s FlatBuffersServer", (listen) ? "resume" : "pause"); + if (listen) + { + startServer(); + } + else + { + stopServer(); + } + } } FlatBuffersServer::~FlatBuffersServer() @@ -123,7 +141,15 @@ void FlatBuffersServer::handleSettingsUpdate(settings::type type, const QJsonDoc // new timeout just for new connections _timeout = obj["timeout"].toInt(5000); // enable check - obj["enable"].toBool(true) ? startServer() : stopServer(); + _active = obj["enable"].toBool(true); + if (_active) + { + startServer(); + } + else + { + stopServer(); + } _quarterOfFrameMode = obj["quarterOfFrameMode"].toBool(false); diff --git a/sources/lut-calibrator/LutCalibrator.cpp b/sources/lut-calibrator/LutCalibrator.cpp index 1bde02852..435de321f 100644 --- a/sources/lut-calibrator/LutCalibrator.cpp +++ b/sources/lut-calibrator/LutCalibrator.cpp @@ -335,13 +335,17 @@ void LutCalibrator::startHandler() Debug(_log, message); connect(GlobalSignals::getInstance(), &GlobalSignals::SignalNewSystemImage, this, &LutCalibrator::setSystemImage, Qt::ConnectionType::UniqueConnection); } - else + else if (_defaultComp == hyperhdr::COMP_FLATBUFSERVER) { auto message = "Using flatbuffers/protobuffers as a source
Waiting for first captured test board.."; notifyCalibrationMessage(message); Debug(_log, message); connect(GlobalSignals::getInstance(), &GlobalSignals::SignalSetGlobalImage, this, &LutCalibrator::signalSetGlobalImageHandler, Qt::ConnectionType::UniqueConnection); } + else + { + error(QString("Cannot use '%1' as a video source for calibration").arg(hyperhdr::componentToString(_defaultComp))); + } } void LutCalibrator::stopHandler() @@ -355,6 +359,15 @@ void LutCalibrator::stopHandler() { emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_HDR, -1, false); emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_HDR, -1, true); + + if (_defaultComp == hyperhdr::COMP_VIDEOGRABBER) + { + emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_VIDEOGRABBER, -1, true); + } + if (_defaultComp == hyperhdr::COMP_FLATBUFSERVER) + { + emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_FLATBUFSERVER, -1, true); + } } } @@ -946,7 +959,7 @@ void LutCalibrator::fineTune(bool precise) const auto white = _capturedColors->all[MAX_IND][MAX_IND][MAX_IND].Y(); double NITS = 0.0; double maxLevel = 0.0; - std::atomic weakBestScore = MAX_CALIBRATION_ERROR; + std::atomic weakBestScore = MAX_CALIBRATION_ERROR; // prepare vertexes std::list vertex, masterVertex; @@ -1228,6 +1241,15 @@ void LutCalibrator::calibration() // reload LUT emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_HDR, -1, false); emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_HDR, -1, true); + + if (_defaultComp == hyperhdr::COMP_VIDEOGRABBER) + { + emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_VIDEOGRABBER, -1, true); + } + if (_defaultComp == hyperhdr::COMP_FLATBUFSERVER) + { + emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_FLATBUFSERVER, -1, true); + } } @@ -1447,6 +1469,15 @@ void LutCalibrator::calibrate() sendReport(_log, _yuvConverter->toString()); #endif + if (_defaultComp == hyperhdr::COMP_VIDEOGRABBER) + { + emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_VIDEOGRABBER, -1, false); + } + if (_defaultComp == hyperhdr::COMP_FLATBUFSERVER) + { + emit GlobalSignals::getInstance()->SignalRequestComponent(hyperhdr::Components::COMP_FLATBUFSERVER, -1, false); + } + bestResult = std::make_shared(); _capturedColors->finilizeBoard(); diff --git a/www/content/grabber_calibration.html b/www/content/grabber_calibration.html index a862cec39..d962f44ec 100644 --- a/www/content/grabber_calibration.html +++ b/www/content/grabber_calibration.html @@ -63,10 +63,6 @@

-
- - -
@@ -80,6 +76,10 @@

+
+ + +