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

Method run

test/cv/ImageProcessTest.cpp:386–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384public:
385 virtual ~ImageProcessRGBToGrayTest() = default;
386 virtual bool run(int precision) {
387 int w = 15, h = 1, size = w * h;
388 auto rgb = genSourceData(h, w, 3);
389 std::vector<uint8_t> gray(size);
390 std::shared_ptr<MNN::Tensor> tensor(MNN::Tensor::create<uint8_t>(std::vector<int>{1, h, w, 1}, gray.data()));
391 ImageProcess::Config config;
392 config.sourceFormat = RGB;
393 config.destFormat = GRAY;
394
395 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
396 process->convert(rgb.data(), w, h, 0, tensor.get());
397 for (int i = 0; i < size; ++i) {
398 int s = gray[i];
399 int r = rgb[3 * i + 0];
400 int g = rgb[3 * i + 1];
401 int b = rgb[3 * i + 2];
402 int y = (19 * r + 38 * g + 7 * b) >> 6;
403 if (abs(y - s) >= 2) {
404 MNN_ERROR("Error: Turn RGB to gray:%d, %d,%d,%d -> %d\n", i, r, g, b, s);
405 return false;
406 }
407 }
408 return true;
409 }
410};
411MNNTestSuiteRegister(ImageProcessRGBToGrayTest, "cv/image_process/rgb_to_gray");
412

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