MCPcopy Create free account
hub / github.com/alibaba/MNN / run

Method run

test/cv/ImageProcessTest.cpp:191–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189public:
190 virtual ~ImageProcessGrayToGrayNearestTransformTest() = default;
191 virtual bool run(int precision) {
192 ImageProcess::Config config;
193 config.sourceFormat = GRAY;
194 config.destFormat = GRAY;
195 config.filterType = MNN::CV::Filter::NEAREST;
196 config.wrap = ZERO;
197 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
198
199 int sw = 1280;
200 int sh = 720;
201 int dw = 360;
202 int dh = 640;
203 Matrix tr;
204 tr.setScale(1.0 / sw, 1.0 / sh);
205 tr.postRotate(90, 0.5f, 0.5f);
206 tr.postScale(dw, dh);
207 tr.invert(&tr);
208 process->setMatrix(tr);
209
210 auto integers = genSourceData(sh, sw, 1);
211 std::shared_ptr<Tensor> tensor(
212 Tensor::create<float>(std::vector<int>{1, 1, dw, dh}, nullptr, Tensor::CAFFE_C4));
213 for (int i = 0; i < 10; ++i) {
214 process->convert(integers.data(), sw, sh, 0, tensor.get());
215 }
216 auto floats = tensor->host<float>();
217 int expect[] = {0, 4, 16, 36, 64, 21, 65, 38, 19, 8};
218 for (int v = 0; v < 10; ++v) {
219 if ((int)(floats[4 * v]) != expect[v]) {
220 MNN_ERROR("Error for %d, %.f, correct=%d\n", v, floats[4 * v], expect[v]);
221 return false;
222 }
223 }
224 return true;
225 }
226};
227MNNTestSuiteRegister(ImageProcessGrayToGrayNearestTransformTest, "cv/image_process/gray_to_gray_nearest_transorm");
228

Callers

nothing calls this directly

Calls 10

genSourceDataFunction · 0.85
setScaleMethod · 0.80
postRotateMethod · 0.80
postScaleMethod · 0.80
createFunction · 0.50
invertMethod · 0.45
setMatrixMethod · 0.45
convertMethod · 0.45
dataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected