-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New LUT calibration based on mp4 test videos (part I) (#896)
* to revert * LUT rework * Test images creator * Test video * Use vectors * Extract classes & namespaces * Add CapturedColor * Optimize board creator * Make board verifier work * Read CRC from the test board * Parse and verify colors of all test boards * Print error stats * Correction * Calibration for new boards. 17*17*17 YUV samples. * Parse text HDR LUT to binary format * Add save raw image * Const correction * Add detection of bt.2020 gamma in the input data * Add more colorspace math * More math * Update LutCalibrator.cpp * Verify source: only NV12/YUYV/MJPEG source are supported for the calibration process * Add precise scanner * Testing more conditions and deviation of YUV coefs * Optimize matrix multiplication * Extract methods * Optimize YUV coef matrix creation * Implemented LUT saving * Add support for Flatbuffers NV12 calibration * Save captured YUV colors in HyperHDR home folder * HDR10 calibration is working again also using video test files * Fix errors (1) * Test C++17 * Fix errors (2) * HDR10 calibrator: fix errors * HDR10 calibration is working again also using video test files * HDR10 calibration is working again also using video test files * Added a new nice web wizard for LUT calibration * Added BT.2100 HLG support * Added BT.2100 HLG support (2) * Added BT.2100 HLG support (3) * Added BT.2100 HLG support (4) * Verify if BT.2100 HLG OOTF is present * More detailed scan * Faster HLG OOTF when disabled * More precise calculation * Fix calibration for 1280x720 capturing setting * Support for SDR calibration * More precise color capture saving/loading New calibration_captured_yuv.txt format * Add support for SDR (BT2020 in SRGB) calibration * Grabber benchmark support for flatbuffers * Add quarter of frame mode for flatbuffers * Improvements * Fix * Important calibration fix and stronger noise resistance * Wider search * Two stage calibration * Refactoring * Improvements * Focus on yellow,scan more vertexes,error may go up * Improvements * Improvements * Multi-threading support for LUT calibration * Multi-threading support for LUT creator * Add 'detailed calibration' option * Add LCH color correction * Run calibrator on separate thread (nonblocking UI) * Add PQ in sRGB linear signal detection * Pause grabber/flatbuffers while calibrating LUT * Change rounding for backlight * Fix serial port discovery in UI * Added 3'th LCH layer, increased number of vertices, more CPU needed * Add more test vertexes (959), change to square errors * Add more brown color vertexes
- Loading branch information
Showing
61 changed files
with
4,617 additions
and
1,567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#pragma once | ||
|
||
/* BestResult.h | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020-2024 awawa-dev | ||
* | ||
* Project homesite: https://github.com/awawa-dev/HyperHDR | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#ifndef PCH_ENABLED | ||
#include <QJsonArray> | ||
#include <QJsonObject> | ||
#include <QFile> | ||
#include <QDateTime> | ||
#include <QThread> | ||
|
||
#include <cmath> | ||
#include <cfloat> | ||
#include <climits> | ||
#endif | ||
|
||
#include <linalg.h> | ||
#include <lut-calibrator/ColorSpace.h> | ||
#include <lut-calibrator/BoardUtils.h> | ||
#include <lut-calibrator/YuvConverter.h> | ||
|
||
using namespace linalg; | ||
using namespace aliases; | ||
using namespace ColorSpaceMath; | ||
using namespace BoardUtils; | ||
|
||
struct LchLists | ||
{ | ||
std::list<double4> low; | ||
std::list<double4> mid; | ||
std::list<double4> high; | ||
}; | ||
|
||
struct BestResult | ||
{ | ||
YuvConverter::YUV_COEFS coef = YuvConverter::YUV_COEFS::BT601; | ||
double4x4 coefMatrix; | ||
double2 coefDelta; | ||
int coloredAspectMode = 0; | ||
std::pair<double3, double3> colorAspect; | ||
double3 aspect; | ||
int bt2020Range = 0; | ||
int altConvert = 0; | ||
double3x3 altPrimariesToSrgb; | ||
ColorSpaceMath::HDR_GAMMA gamma = ColorSpaceMath::HDR_GAMMA::PQ; | ||
double gammaHLG = 0; | ||
double nits = 0; | ||
bool lchEnabled = false; | ||
LchLists lchPrimaries; | ||
|
||
struct Signal | ||
{ | ||
YuvConverter::COLOR_RANGE range = YuvConverter::COLOR_RANGE::FULL; | ||
double yRange = 0; | ||
double upYLimit = 0; | ||
double downYLimit = 0; | ||
double yShift = 0; | ||
} signal; | ||
|
||
long long int minError = MAX_CALIBRATION_ERROR; | ||
|
||
void serializePrimaries(std::stringstream& out) const | ||
{ | ||
for (const auto& p : { lchPrimaries.low, lchPrimaries.mid, lchPrimaries.high }) | ||
{ | ||
out << std::endl << "\t\t\tstd::list<double4>{" << std::endl << "\t\t\t\t"; | ||
for (const auto& v : p) | ||
{ | ||
out << "double4"; ColorSpaceMath::serialize(out, v); out << ", "; | ||
} | ||
out << std::endl << "\t\t\t}," << std::endl; | ||
} | ||
} | ||
|
||
void serialize(std::stringstream& out) const | ||
{ | ||
out.precision(12); | ||
out << "/*" << std::endl; | ||
out << "BestResult bestResult;" << std::endl; | ||
out << "bestResult.coef = YuvConverter::YUV_COEFS(" << std::to_string(coef) << ");" << std::endl; | ||
out << "bestResult.coefMatrix = double4x4"; ColorSpaceMath::serialize(out, coefMatrix); out << ";" << std::endl; | ||
out << "bestResult.coefDelta = double2"; ColorSpaceMath::serialize(out, coefDelta); out << ";" << std::endl; | ||
out << "bestResult.coloredAspectMode = " << std::to_string(coloredAspectMode) << ";" << std::endl; | ||
out << "bestResult.colorAspect = std::pair<double3, double3>(double3"; ColorSpaceMath::serialize(out, colorAspect.first); out << ", double3"; ColorSpaceMath::serialize(out, colorAspect.second); out << ");" << std::endl; | ||
out << "bestResult.aspect = double3"; ColorSpaceMath::serialize(out, aspect); out << ";" << std::endl; | ||
out << "bestResult.bt2020Range = " << std::to_string(bt2020Range) << ";" << std::endl; | ||
out << "bestResult.altConvert = " << std::to_string(altConvert) << ";" << std::endl; | ||
out << "bestResult.altPrimariesToSrgb = double3x3"; ColorSpaceMath::serialize(out, altPrimariesToSrgb); out << ";" << std::endl; | ||
out << "bestResult.gamma = ColorSpaceMath::HDR_GAMMA(" << std::to_string(gamma) << ");" << std::endl; | ||
out << "bestResult.gammaHLG = " << std::to_string(gammaHLG) << ";" << std::endl; | ||
out << "bestResult.lchEnabled = " << std::to_string(lchEnabled) << ";" << std::endl; | ||
out << "bestResult.lchPrimaries = LchLists{"; serializePrimaries(out); out << "\t\t};" << std::endl; | ||
out << "bestResult.nits = " << std::to_string(nits) << ";" << std::endl; | ||
out << "bestResult.signal.range = YuvConverter::COLOR_RANGE(" << std::to_string(signal.range) << ");" << std::endl; | ||
out << "bestResult.signal.yRange = " << std::to_string(signal.yRange) << ";" << std::endl; | ||
out << "bestResult.signal.upYLimit = " << std::to_string(signal.upYLimit) << ";" << std::endl; | ||
out << "bestResult.signal.downYLimit = " << std::to_string(signal.downYLimit) << ";" << std::endl; | ||
out << "bestResult.signal.yShift = " << std::to_string(signal.yShift) << ";" << std::endl; | ||
out << "bestResult.minError = " << std::to_string(std::round(minError * 100.0) / 30000.0) << ";" << std::endl; | ||
out << "*/" << std::endl; | ||
} | ||
}; |
Oops, something went wrong.