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

Method run

test/cv/ImageProcessTest.cpp:355–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353public:
354 virtual ~ImageProcessBGRToBGRTest() = default;
355 virtual bool run(int precision) {
356 int w = 27, h = 1, size = w * h;
357 auto integers = genSourceData(h, w, 3);
358 std::vector<float> floats(size * 4);
359 std::shared_ptr<MNN::Tensor> tensor(
360 MNN::Tensor::create<float>(std::vector<int>{1, 1, h, w}, floats.data(), Tensor::CAFFE_C4));
361 ImageProcess::Config config;
362 config.sourceFormat = BGR;
363 config.destFormat = BGR;
364
365 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
366 process->convert(integers.data(), w, h, 0, tensor.get());
367 for (int i = 0; i < floats.size() / 4; ++i) {
368 int r = floats[4 * i + 0];
369 int g = floats[4 * i + 1];
370 int b = floats[4 * i + 2];
371 if (r != integers[3 * i + 0] || g != integers[3 * i + 1] || b != integers[3 * i + 2]) {
372 MNN_ERROR("Error for turn rgb to float:\n %d,%d,%d->%f, %f, %f, %f\n", integers[3 * i + 0],
373 integers[3 * i + 1], integers[3 * i + 2], floats[4 * i + 0], floats[4 * i + 1],
374 floats[4 * i + 2], floats[4 * i + 3]);
375 return false;
376 }
377 }
378 return true;
379 }
380};
381MNNTestSuiteRegister(ImageProcessBGRToBGRTest, "cv/image_process/bgr_to_bgr");
382

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