| 343 | } |
| 344 | |
| 345 | void BuildLargePyramidTemplateData( |
| 346 | std::vector<uchar> &source_bgra, |
| 347 | int &source_width, |
| 348 | int &source_height, |
| 349 | int &template_width, |
| 350 | int &template_height, |
| 351 | std::vector<cv::Point> hit_points, |
| 352 | std::wstring &template_path, |
| 353 | const std::wstring &template_file_name) { |
| 354 | source_width = 960; |
| 355 | source_height = 540; |
| 356 | template_width = 32; |
| 357 | template_height = 32; |
| 358 | source_bgra.assign(static_cast<size_t>(source_width * source_height * 4), 0); |
| 359 | |
| 360 | for (int y = 0; y < source_height; ++y) { |
| 361 | for (int x = 0; x < source_width; ++x) { |
| 362 | SetBgraPixel( |
| 363 | source_bgra, |
| 364 | source_width, |
| 365 | x, |
| 366 | y, |
| 367 | static_cast<uchar>((x * 3 + y * 5 + 17) % 97), |
| 368 | static_cast<uchar>((x * 7 + y * 2 + 29) % 89), |
| 369 | static_cast<uchar>((x * 5 + y * 11 + 43) % 83)); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | std::vector<uchar> template_bgra(static_cast<size_t>(template_width * template_height * 4), 0); |
| 374 | for (int y = 0; y < template_height; ++y) { |
| 375 | for (int x = 0; x < template_width; ++x) { |
| 376 | uchar b = static_cast<uchar>((x * 17 + y * 31 + x * y * 7 + 53) % 251); |
| 377 | uchar g = static_cast<uchar>((x * x * 11 + y * 13 + x * y * 5 + 89) % 253); |
| 378 | uchar r = static_cast<uchar>((x * 23 + y * y * 17 + (x ^ y) * 29 + 131) % 255); |
| 379 | if ((x + y) % 7 == 0) { |
| 380 | b = static_cast<uchar>(240 - (x * 3) % 41); |
| 381 | g = static_cast<uchar>(30 + (y * 5) % 61); |
| 382 | r = static_cast<uchar>(180 + (x * y) % 53); |
| 383 | } |
| 384 | SetBgraPixel(template_bgra, template_width, x, y, b, g, r); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | for (const auto &point : hit_points) { |
| 389 | ASSERT_GE(point.x, 0); |
| 390 | ASSERT_GE(point.y, 0); |
| 391 | ASSERT_LE(point.x + template_width, source_width); |
| 392 | ASSERT_LE(point.y + template_height, source_height); |
| 393 | for (int y = 0; y < template_height; ++y) { |
| 394 | for (int x = 0; x < template_width; ++x) { |
| 395 | const size_t src_index = static_cast<size_t>((y * template_width + x) * 4); |
| 396 | SetBgraPixel( |
| 397 | source_bgra, |
| 398 | source_width, |
| 399 | point.x + x, |
| 400 | point.y + y, |
| 401 | template_bgra[src_index + 0], |
| 402 | template_bgra[src_index + 1], |
no test coverage detected