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

Method run

test/cv/ImageProcessTest.cpp:485–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483public:
484 virtual ~ImageProcessRGBAToGrayNearestTransformTest() = default;
485 virtual bool run(int precision) {
486 ImageProcess::Config config;
487 config.sourceFormat = RGBA;
488 config.destFormat = GRAY;
489 config.filterType = MNN::CV::Filter::NEAREST;
490 config.wrap = CLAMP_TO_EDGE;
491 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
492
493 int sw = 1280;
494 int sh = 720;
495 int dw = 360;
496 int dh = 640;
497 Matrix tr;
498 tr.setScale(1.0 / sw, 1.0 / sh);
499 tr.postRotate(60, 0.5f, 0.5f);
500 tr.postScale(dw, dh);
501 tr.invert(&tr);
502 process->setMatrix(tr);
503
504 auto integers = genSourceData(sh, sw, 4);
505 std::shared_ptr<Tensor> tensor(
506 Tensor::create<float>(std::vector<int>{1, 1, dw, dh}, nullptr, Tensor::CAFFE_C4));
507 for (int i = 0; i < 10; ++i) {
508 process->convert(integers.data(), sw, sh, 0, tensor.get());
509 }
510 auto floats = tensor->host<float>();
511 int expect[] = {3, 50, 26, 17, 5, 1, 5, 10, 26, 50};
512 for (int v = 0; v < 10; ++v) {
513 if ((int)(floats[4 * v]) != expect[v]) {
514 MNN_ERROR("Error for %d, %.f, correct=%d\n", v, floats[4 * v], expect[v]);
515 return false;
516 }
517 }
518 return true;
519 }
520};
521MNNTestSuiteRegister(ImageProcessRGBAToGrayNearestTransformTest, "cv/image_process/rgba_to_gray_nearest_transorm");
522

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