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

Method run

test/cv/ImageProcessTest.cpp:232–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230public:
231 virtual ~ImageProcessGrayToRGBATest() = default;
232 virtual bool run(int precision) {
233 int w = 15, h = 1, size = w * h;
234 auto gray = genSourceData(h, w, 1);
235 std::vector<uint8_t> rgba(size * 4);
236 std::shared_ptr<MNN::Tensor> tensor(MNN::Tensor::create<uint8_t>(std::vector<int>{1, h, w, 4}, rgba.data()));
237
238 ImageProcess::Config config;
239 config.sourceFormat = GRAY;
240 config.destFormat = RGBA;
241 std::shared_ptr<ImageProcess> process(ImageProcess::create(config));
242 process->convert(gray.data(), w, h, 0, tensor.get());
243 for (int i = 0; i < size; ++i) {
244 int s = gray[i];
245 int r = rgba[4 * i + 0];
246 int g = rgba[4 * i + 1];
247 int b = rgba[4 * i + 2];
248
249 int y = s;
250 int a = rgba[4 * i + 3];
251
252 if (y != r || y != g || y != b || a != 255) {
253 MNN_ERROR("Turn gray to RGBA:%d, %d -> %d,%d,%d,%d\n", i, s, r, g, b, a);
254 return false;
255 }
256 }
257 return true;
258 }
259};
260MNNTestSuiteRegister(ImageProcessGrayToRGBATest, "cv/image_process/gray_to_rgba");
261

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected