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

Function parseBoard

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

Source from the content-addressed store, hash-verified

157 }
158
159 bool parseBoard(Logger* _log, const Image<ColorRgb>& yuvImage, int& boardIndex, CapturedColors& allColors, bool multiFrame)
160 {
161 bool exit = (multiFrame) ? false : true;
162
163 int line = 0;
164 CapturedColor white, black;
165
166 try
167 {
168 getWhiteBlackColorLevels(yuvImage, white, black, line);
169 }
170 catch (std::exception& ex)
171 {
172 Error(_log, "Too much noice or too low resolution");
173 return false;
174 }
175
176 if (!verifyBlackColorPattern(yuvImage, (line == 0), black))
177 {
178 Error(_log, "The black color pattern failed, too much noice or too low resolution");
179 return false;
180 }
181
182 try
183 {
184 boardIndex = readCrc(yuvImage, line, white);
185 if (boardIndex > SCREEN_LAST_BOARD_INDEX)
186 throw std::runtime_error("Unexpected board");
187
188 }
189 catch (std::exception& ex)
190 {
191 Error(_log, "Too much noice or too low resolution");
192 return false;
193 }
194
195 if (allColors.isCaptured(boardIndex))
196 {
197 return true;
198 }
199
200 int max1 = (boardIndex + 1) * SCREEN_SAMPLES_PER_BOARD;
201 int max2 = std::pow(SCREEN_COLOR_DIMENSION, 3);
202 for (int currentIndex = boardIndex * SCREEN_SAMPLES_PER_BOARD; currentIndex < max1 && currentIndex < max2; currentIndex++)
203 {
204 byte3 color;
205 int2 position;
206 indexToColorAndPos(currentIndex, color, position);
207
208 int B = (currentIndex % SCREEN_COLOR_DIMENSION);
209 int G = ((currentIndex / (SCREEN_COLOR_DIMENSION)) % SCREEN_COLOR_DIMENSION);
210 int R = (currentIndex / (SCREEN_COLOR_DIMENSION * SCREEN_COLOR_DIMENSION));
211
212 try
213 {
214 auto capturedColor = readBlock(yuvImage, position, &color);
215 if (allColors.all[R][G][B].hasAnySample())
216 {

Callers 2

verifyTestBoardsFunction · 0.85
handleImageMethod · 0.85

Calls 12

getWhiteBlackColorLevelsFunction · 0.85
verifyBlackColorPatternFunction · 0.85
readCrcFunction · 0.85
readBlockFunction · 0.85
isCapturedMethod · 0.80
hasAnySampleMethod · 0.80
importColorsMethod · 0.80
hasAllSamplesMethod · 0.80
setSourceRGBMethod · 0.80
getRangeMethod · 0.80
setRangeMethod · 0.80
indexToColorAndPosFunction · 0.70

Tested by

no test coverage detected