Skip to content

Commit

Permalink
Fix calibration for 1280x720 capturing setting
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Sep 12, 2024
1 parent 96544ac commit 6c28e42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 6 additions & 5 deletions sources/lut-calibrator/BoardUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ namespace BoardUtils

CapturedColor readBlock(const Image<ColorRgb>& yuvImage, int2 position)
{
const int2 delta(yuvImage.width() / SCREEN_BLOCKS_X, yuvImage.height() / SCREEN_BLOCKS_Y);
const double2 delta(yuvImage.width() / (double)SCREEN_BLOCKS_X, yuvImage.height() / (double)SCREEN_BLOCKS_Y);
CapturedColor color;

const int2 start = position * delta;
const int2 end = ((position + int2(1, 1)) * delta) - int2(1, 1);
const int2 middle = (start + end) / 2;

const double2 positionF{ position };
const double2 startF = positionF * delta;
const double2 endF = ((positionF + double2(1, 1)) * delta) - double2(1, 1);
const int2 middle{ (startF + endF) / 2 };

if (middle.x + 1 >= static_cast<int>(yuvImage.width()) || middle.y + 1 >= static_cast<int>(yuvImage.height()))
throw std::runtime_error("Incorrect image size");

Expand Down
14 changes: 9 additions & 5 deletions sources/lut-calibrator/LutCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,10 @@ void LutCalibrator::tryHDR10()
// detect nits
const int SCALE = SCREEN_COLOR_DIMENSION - 1;
const auto white = _capturedColors->all[SCALE][SCALE][SCALE].Y();


auto totalTime = InternalClock::now();
fineTune();
totalTime = InternalClock::now() - totalTime;

double3x3 convert_bt2020_to_XYZ;
double3x3 convert_XYZ_to_sRgb;
Expand All @@ -801,18 +803,20 @@ void LutCalibrator::tryHDR10()


Debug(_log, "Score: %f", bestResult->minError / 1000.0);
Debug(_log, "Time: %f", totalTime / 1000.0);


Debug(_log, "Selected coef: %s", QSTRING_CSTR( _yuvConverter->coefToString(bestResult->coef)));
Debug(_log, "selected coef delta: %f %f", bestResult->coefDelta.x, bestResult->coefDelta.y);
Debug(_log, "Selected coef delta: %f %f", bestResult->coefDelta.x, bestResult->coefDelta.y);
Debug(_log, "Selected EOTF: %s", QSTRING_CSTR(ColorSpaceMath::gammaToString(bestResult->gamma)));
if (bestResult->gamma == HDR_GAMMA::HLG)
{
Debug(_log, "Selected HLG gamma: %f", bestResult->gammaHLG);
}
Debug(_log, "Selected nits: %f", (bestResult->gamma == HDR_GAMMA::HLG) ? 1000.0 * ( 1 / bestResult->nits) : bestResult->nits);
Debug(_log, "selected bt2020 range: %i", bestResult->bt2020Range);
Debug(_log, "selected alt convert: %i", bestResult->altConvert);
Debug(_log, "selected aspect: %f %f %f", bestResult->aspect.x, bestResult->aspect.y, bestResult->aspect.z);
Debug(_log, "Selected bt2020 range: %i", bestResult->bt2020Range);
Debug(_log, "Selected alt convert: %i", bestResult->altConvert);
Debug(_log, "Selected aspect: %f %f %f", bestResult->aspect.x, bestResult->aspect.y, bestResult->aspect.z);

// write report (captured raw colors)
QString fileLogName = QString("%1%2").arg(_rootPath).arg("/calibration_captured_yuv.txt");
Expand Down

0 comments on commit 6c28e42

Please sign in to comment.