| 701 | MNNTestSuiteRegister(ImageProcessYUVBlitterTest, "cv/image_process/yuv_blitter"); |
| 702 | |
| 703 | static bool funcToColorResize(int iw, int ih, int ic, int ow, int oh, int oc, Filter filtertype, ImageFormat srcFormat, ImageFormat dstFormat) { |
| 704 | auto srcImg = genSourceData(ih, iw, ic); |
| 705 | auto dstType = halide_type_of<float>(); |
| 706 | auto int8Type = halide_type_of<uint8_t>(); |
| 707 | |
| 708 | float fx = static_cast<float>(iw) / ow; |
| 709 | float fy = static_cast<float>(ih) / oh; |
| 710 | ImageProcess::Config config0, config1; |
| 711 | |
| 712 | // resize first |
| 713 | config0.sourceFormat = srcFormat; |
| 714 | config0.destFormat = srcFormat; |
| 715 | config0.filterType = filtertype; |
| 716 | std::unique_ptr<ImageProcess> process0(ImageProcess::create(config0)); |
| 717 | auto resizeTensor = Tensor::create({1, oh, ow, ic}, int8Type); |
| 718 | Matrix tr; |
| 719 | tr.postScale(fx, fy); |
| 720 | tr.postTranslate(0.5 * (fx - 1), 0.5 * (fy - 1)); |
| 721 | process0->setMatrix(tr); |
| 722 | process0->convert(srcImg.data(), iw, ih, 0, resizeTensor->host<uint8_t>(), ow, oh, ic, 0, int8Type); |
| 723 | |
| 724 | // then convert color |
| 725 | config1.sourceFormat = srcFormat; |
| 726 | config1.destFormat = dstFormat; |
| 727 | config1.filterType = filtertype; |
| 728 | config1.mean[0] = 127; |
| 729 | config1.mean[1] = 127; |
| 730 | config1.mean[2] = 127; |
| 731 | config1.normal[0] = 1.0/128; |
| 732 | config1.normal[1] = 1.0/128; |
| 733 | config1.normal[2] = 1.0/128; |
| 734 | std::unique_ptr<ImageProcess> process1(ImageProcess::create(config1)); |
| 735 | auto colorTensor = Tensor::create({1, oh, ow, oc}, dstType); |
| 736 | Matrix tr1; |
| 737 | tr1.postScale(1.f, 1.f); |
| 738 | tr1.postTranslate(0, 0); |
| 739 | process1->setMatrix(tr1); |
| 740 | process1->convert(resizeTensor->host<uint8_t>(), ow, oh, 0, colorTensor->host<uint8_t>(), ow, oh, oc, 0, dstType); |
| 741 | |
| 742 | // convert color first |
| 743 | ImageProcess::Config config2, config3; |
| 744 | config2.sourceFormat = srcFormat; |
| 745 | config2.destFormat = dstFormat; |
| 746 | config2.filterType = filtertype; |
| 747 | |
| 748 | std::unique_ptr<ImageProcess> process2(ImageProcess::create(config2)); |
| 749 | auto colorTensor2 = Tensor::create({1, ih, iw, oc}, int8Type); |
| 750 | Matrix tr2; |
| 751 | tr2.postScale(1.f, 1.f); |
| 752 | tr2.postTranslate(0.f, 0.f); |
| 753 | process2->setMatrix(tr2); |
| 754 | process2->convert(srcImg.data(), iw, ih, 0, colorTensor2->host<uint8_t>(), iw, ih, oc, 0, int8Type); |
| 755 | |
| 756 | // Second: resize |
| 757 | config3.sourceFormat = dstFormat; |
| 758 | config3.destFormat = dstFormat; |
| 759 | config3.filterType = filtertype; |
| 760 | config3.mean[0] = 127; |
no test coverage detected