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

Method run

test/cv/ImageProcessTest.cpp:324–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322public:
323 virtual ~ImageProcessRGBAToBGRATest() = default;
324 virtual bool run(int precision) {
325 int w = 27, h = 1, size = w * h;
326 auto integers = genSourceData(h, w, 4);
327 std::vector<uint8_t> floats(size * 4);
328 std::shared_ptr<MNN::Tensor> tensor(
329 MNN::Tensor::create<uint8_t>(std::vector<int>{1, h, w, 4}, floats.data(), Tensor::TENSORFLOW));
330 ImageProcess::Config config;
331 config.sourceFormat = RGBA;
332 config.destFormat = BGRA;
333
334 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
335 process->convert(integers.data(), w, h, 0, tensor.get());
336 for (int i = 0; i < floats.size() / 4; ++i) {
337 int r = floats[4 * i + 2];
338 int g = floats[4 * i + 1];
339 int b = floats[4 * i + 0];
340 if (r != integers[4 * i + 0] || g != integers[4 * i + 1] || b != integers[4 * i + 2]) {
341 MNN_ERROR("Error for turn rgba to bgra:\n %d,%d,%d->%d, %d, %d, %d\n", integers[4 * i + 0],
342 integers[4 * i + 1], integers[4 * i + 2], floats[4 * i + 0], floats[4 * i + 1],
343 floats[4 * i + 2], floats[4 * i + 3]);
344 return false;
345 }
346 }
347 return true;
348 }
349};
350MNNTestSuiteRegister(ImageProcessRGBAToBGRATest, "cv/image_process/rgba_to_bgra");
351

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected