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

Method run

test/cv/ImageProcessTest.cpp:416–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414public:
415 virtual ~ImageProcessRGBAToGrayTest() = default;
416 virtual bool run(int precision) {
417 int w = 15, h = 1, size = w * h;
418 auto rgba = genSourceData(h, w, 4);
419 std::vector<uint8_t> gray(size);
420 std::shared_ptr<MNN::Tensor> tensor(MNN::Tensor::create<uint8_t>(std::vector<int>{1, h, w, 1}, gray.data()));
421
422 ImageProcess::Config config;
423 config.sourceFormat = RGBA;
424 config.destFormat = GRAY;
425 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
426 process->convert(rgba.data(), w, h, 0, tensor.get());
427 for (int i = 0; i < size; ++i) {
428 int s = gray[i];
429 int r = rgba[4 * i + 0];
430 int g = rgba[4 * i + 1];
431 int b = rgba[4 * i + 2];
432 int y = (19 * r + 38 * g + 7 * b) >> 6;
433 if (abs(y - s) >= 2) {
434 MNN_ERROR("Turn RGBA to gray:%d, %d,%d,%d -> %d\n", i, r, g, b, s);
435 return false;
436 }
437 }
438 return true;
439 }
440};
441MNNTestSuiteRegister(ImageProcessRGBAToGrayTest, "cv/image_process/rgba_to_gray");
442

Callers

nothing calls this directly

Calls 6

genSourceDataFunction · 0.85
createFunction · 0.50
absFunction · 0.50
dataMethod · 0.45
convertMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected