MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / verifyTestBoards

Function verifyTestBoards

sources/lut-calibrator/BoardUtils.cpp:336–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334 }
335
336 bool verifyTestBoards(Logger* _log, const char* pattern)
337 {
338 int boardIndex = -1;
339 CapturedColors captured;
340
341 for (int i = 0; i <= SCREEN_LAST_BOARD_INDEX; i++)
342 {
343 QString file = QString(pattern).arg(QString::number(i));
344 Image<ColorRgb> image;
345
346 if (!QFile::exists(file))
347 {
348 Error(_log, "LUT test board: %i. File %s does not exists", i, QSTRING_CSTR(file));
349 return false;
350 }
351
352 image = loadTestBoardAsYuv(file.toStdString());
353
354 if (image.width() == 1 || image.height() == 1)
355 {
356 Error(_log, "LUT test board: %i. Could load PNG: %s", i, QSTRING_CSTR(file));
357 return false;
358 }
359
360 if (!parseBoard(_log, image, boardIndex, captured))
361 {
362 Error(_log, "LUT test board: %i. Could not parse: %s", i, QSTRING_CSTR(file));
363 return false;
364 }
365
366 if (boardIndex != i)
367 {
368 Error(_log, "LUT test board: %i. Could not parse: %s. Incorrect board index: %i", i, QSTRING_CSTR(file), boardIndex);
369 return false;
370 }
371 captured.setCaptured(boardIndex);
372 }
373
374 if (!captured.areAllCaptured())
375 {
376 Error(_log, "Not all test boards were loaded");
377 return false;
378 }
379
380 // verify colors
381 YuvConverter converter;
382 int maxError = 0, totalErrors = 0;
383 for (int r = 0; r < SCREEN_COLOR_DIMENSION; r++)
384 for (int g = 0; g < SCREEN_COLOR_DIMENSION; g++)
385 for (int b = 0; b < SCREEN_COLOR_DIMENSION; b++)
386 {
387 const auto& sample = captured.all[r][g][b];
388 int3 sourceRgb = sample.getSourceRGB();
389 auto result = converter.toRgb(YuvConverter::COLOR_RANGE::FULL, YuvConverter::YUV_COEFS::BT709, sample.yuv()) * 255.0;
390 int3 outputRgb = ColorSpaceMath::to_int3(ColorSpaceMath::to_byte3(result));
391 int distance = linalg::distance(sourceRgb, outputRgb);
392 if (distance > maxError)
393 {

Callers

nothing calls this directly

Calls 10

loadTestBoardAsYuvFunction · 0.85
parseBoardFunction · 0.85
to_int3Function · 0.85
to_byte3Function · 0.85
setCapturedMethod · 0.80
areAllCapturedMethod · 0.80
getSourceRGBMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
toRgbMethod · 0.45

Tested by

no test coverage detected