| 148 | public: |
| 149 | virtual ~ImageProcessGrayToGrayBilinearTransformTest() = default; |
| 150 | virtual bool run(int precision) { |
| 151 | ImageProcess::Config config; |
| 152 | config.sourceFormat = GRAY; |
| 153 | config.destFormat = GRAY; |
| 154 | config.filterType = MNN::CV::Filter::BILINEAR; |
| 155 | config.wrap = CLAMP_TO_EDGE; |
| 156 | std::shared_ptr<ImageProcess> process(ImageProcess::create(config)); |
| 157 | |
| 158 | int sw = 1280; |
| 159 | int sh = 720; |
| 160 | int dw = 360; |
| 161 | int dh = 640; |
| 162 | Matrix tr; |
| 163 | tr.setScale(1.0 / sw, 1.0 / sh); |
| 164 | tr.postRotate(30, 0.5f, 0.5f); |
| 165 | tr.postScale(dw, dh); |
| 166 | tr.invert(&tr); |
| 167 | process->setMatrix(tr); |
| 168 | |
| 169 | auto integers = genSourceData(sh, sw, 1); |
| 170 | std::shared_ptr<Tensor> tensor( |
| 171 | Tensor::create<float>(std::vector<int>{1, 1, dw, dh}, nullptr, Tensor::CAFFE_C4)); |
| 172 | for (int i = 0; i < 10; ++i) { |
| 173 | process->convert(integers.data(), sw, sh, 0, tensor.get()); |
| 174 | } |
| 175 | auto floats = tensor->host<float>(); |
| 176 | int expects[] = {18, 36, 14, 36, 18, 44, 30, 60, 50, 24}; |
| 177 | for (int v = 0; v < 10; ++v) { |
| 178 | if (fabsf(floats[4 * v] - (float)expects[v]) >= 2) { |
| 179 | MNN_ERROR("Error for %d, %.f, correct=%d\n", v, floats[4 * v], expects[v]); |
| 180 | return false; |
| 181 | } |
| 182 | } |
| 183 | return true; |
| 184 | } |
| 185 | }; |
| 186 | MNNTestSuiteRegister(ImageProcessGrayToGrayBilinearTransformTest, "cv/image_process/gray_to_gray_bilinear_transorm"); |
| 187 |
nothing calls this directly
no test coverage detected