| 447 | } |
| 448 | |
| 449 | bool DetectionAutomatic::checkSignal(Image<ColorRgb>& image) |
| 450 | { |
| 451 | int hdrMode = getHdrToneMappingEnabled(); |
| 452 | |
| 453 | if (checkData.width <= 0 || checkData.height <= 0 || checkData.quality <= 0 || checkData.sdrPoint.size() == 0 || checkData.hdrPoint.size() == 0) |
| 454 | { |
| 455 | QString oldStatus = checkData.status; |
| 456 | checkData.status = "Don't have a calibration data. Please run the calibration procedure in the panel grabber tab."; |
| 457 | if (oldStatus != checkData.status) |
| 458 | { |
| 459 | Error(_log, "%s", QSTRING_CSTR(checkData.status)); |
| 460 | resetStats(); |
| 461 | } |
| 462 | return true; |
| 463 | } |
| 464 | |
| 465 | if (checkData.width != (int)image.width() || checkData.height != (int)image.height()) |
| 466 | { |
| 467 | QString oldStatus = checkData.status; |
| 468 | checkData.status = "Calibration data is not meant for the current video stream (different dimensions). Please run the calibration procedure in the panel grabber tab."; |
| 469 | if (oldStatus != checkData.status) |
| 470 | { |
| 471 | Error(_log, "%s", QSTRING_CSTR(checkData.status)); |
| 472 | resetStats(); |
| 473 | } |
| 474 | return true; |
| 475 | } |
| 476 | |
| 477 | if (hdrMode > 1) |
| 478 | { |
| 479 | QString oldStatus = checkData.status; |
| 480 | checkData.status = "Automatic detection doesn't work for the HDR border mode"; |
| 481 | if (oldStatus != checkData.status) |
| 482 | { |
| 483 | Error(_log, "%s", QSTRING_CSTR(checkData.status)); |
| 484 | resetStats(); |
| 485 | } |
| 486 | return true; |
| 487 | } |
| 488 | |
| 489 | if (checkData.signature != getSignature()) |
| 490 | { |
| 491 | QString oldStatus = checkData.status; |
| 492 | checkData.status = "Calibration data signature is different from the current stream signature. Just a warning. Please run the calibration procedure in the panel grabber tab."; |
| 493 | if (oldStatus != checkData.status) |
| 494 | Warning(_log, "%s (have: '%s' <> current: '%s')", QSTRING_CSTR(checkData.status), QSTRING_CSTR(checkData.signature), QSTRING_CSTR(getSignature())); |
| 495 | } |
| 496 | |
| 497 | std::vector<DetectionAutomatic::calibrationPoint>& data = (hdrMode == 0) ? checkData.sdrPoint : checkData.hdrPoint; |
| 498 | int _on = 0, _off = 0; |
| 499 | |
| 500 | for (const auto& v : data) |
| 501 | { |
| 502 | if (!image.checkSignal(v.x, v.y, v.r, v.g, v.b, _errorTolerance)) |
| 503 | _off++; |
| 504 | else |
| 505 | _on++; |
| 506 | } |