小编Vad*_*sky的帖子

如何将 OpenCV Mat 设置为 Tensorflow Lite 输入和输出?

我正在尝试在 iOS 上的 Tensorflow Lite 中使用 GPU 委托。我的模型的输入和输出为 OpenCV BGR 图像 ([258, 540, 3])。如何在 C++ tensorflow lite 解释器中设置输入和输出?我尝试使用此代码

int input = interpreter->inputs()[0];
float* out = interpreter->typed_tensor<float>(input);
NSData* slicedData = [self inputDataFromCvMat:slicedImage];
uint8_t* in = (uint8_t*) slicedData.bytes; 
ProcessInputWithFloatModel(in, out, WIDTH, HEIGHT, CHANNELS);
Run Code Online (Sandbox Code Playgroud)
void ProcessInputWithFloatModel(uint8_t* input, float* buffer, int image_width, int image_height, int image_channels) {
  for (int y = 0; y < wanted_input_height; ++y) {
    float* out_row = buffer + (y * wanted_input_width * wanted_input_channels);
    for (int x = 0; x < …
Run Code Online (Sandbox Code Playgroud)

c++ opencv objective-c++ tensorflow tensorflow-lite

1
推荐指数
1
解决办法
1411
查看次数

标签 统计

c++ ×1

objective-c++ ×1

opencv ×1

tensorflow ×1

tensorflow-lite ×1