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

Method run

test/cv/ImageProcessTest.cpp:265–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263public:
264 virtual ~ImageProcessBGRToGrayTest() = default;
265 virtual bool run(int precision) {
266 int w = 15, h = 1, size = w * h;
267 auto bgr = genSourceData(h, w, 3);
268 std::vector<uint8_t> gray(size);
269 std::shared_ptr<MNN::Tensor> tensor(MNN::Tensor::create<uint8_t>(std::vector<int>{1, h, w, 1}, gray.data()));
270
271 ImageProcess::Config config;
272 config.sourceFormat = BGR;
273 config.destFormat = GRAY;
274 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
275 process->convert(bgr.data(), w, h, 0, tensor.get());
276 for (int i = 0; i < size; ++i) {
277 int s = gray[i];
278 int r = bgr[3 * i + 2];
279 int g = bgr[3 * i + 1];
280 int b = bgr[3 * i + 0];
281 int y = (19 * r + 38 * g + 7 * b) >> 6;
282 if (abs(y - s) >= 2) {
283 MNN_ERROR("Turn BGR to gray:%d, %d,%d,%d -> %d\n", i, r, g, b, s);
284 return false;
285 }
286 }
287 return true;
288 }
289};
290MNNTestSuiteRegister(ImageProcessBGRToGrayTest, "cv/image_process/bgr_to_gray");
291

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