| 444 | public: |
| 445 | virtual ~ImageProcessRGBAToGrayBilinearTransformTest() = default; |
| 446 | virtual bool run(int precision) { |
| 447 | ImageProcess::Config config; |
| 448 | config.sourceFormat = RGBA; |
| 449 | config.destFormat = GRAY; |
| 450 | config.filterType = MNN::CV::Filter::BILINEAR; |
| 451 | config.wrap = CLAMP_TO_EDGE; |
| 452 | std::shared_ptr<ImageProcess> process(ImageProcess::create(config)); |
| 453 | |
| 454 | int sw = 1280; |
| 455 | int sh = 720; |
| 456 | int dw = 360; |
| 457 | int dh = 640; |
| 458 | Matrix tr; |
| 459 | tr.setScale(1.0 / sw, 1.0 / sh); |
| 460 | tr.postRotate(30, 0.5f, 0.5f); |
| 461 | tr.postScale(dw, dh); |
| 462 | tr.invert(&tr); |
| 463 | process->setMatrix(tr); |
| 464 | |
| 465 | auto integers = genSourceData(sh, sw, 4); |
| 466 | std::shared_ptr<Tensor> tensor( |
| 467 | Tensor::create<float>(std::vector<int>{1, 1, dw, dh}, nullptr, Tensor::CAFFE_C4)); |
| 468 | process->convert(integers.data(), sw, sh, 0, tensor.get()); |
| 469 | auto floats = tensor->host<float>(); |
| 470 | int expect[] = {19, 37, 15, 37, 19, 45, 31, 61, 51, 25}; |
| 471 | for (int v = 0; v < 10; ++v) { |
| 472 | if (fabsf(floats[4 * v] - (float)expect[v]) >= 2) { |
| 473 | MNN_ERROR("Error for %d, %.f, correct=%d\n", v, floats[4 * v], expect[v]); |
| 474 | return false; |
| 475 | } |
| 476 | } |
| 477 | return true; |
| 478 | } |
| 479 | }; |
| 480 | MNNTestSuiteRegister(ImageProcessRGBAToGrayBilinearTransformTest, "cv/image_process/rgba_to_gray_bilinear_transorm"); |
| 481 |
nothing calls this directly
no test coverage detected