部分代码如下,
IplImage *pImg = cvLoadImage("img.bmp"? 1);
IplImage *pImgF = cvCreateImage(cvGetSize(pImg),IPL_DEPTH_32F , 3);
cvConvert(pImg, pImgF);
tensorflow::Tensor input_tensor(tensorflow::DT_FLOAT,
tensorflow::TensorShape({ 1, input_height, input_width, 3 }));
auto input_tensor_mapped = input_tensor.tensor<float, 4>();
float *pSourceRow = (float *)pImgF->imageData;
int x, y, c;
int depth = 3;
for (int y = 0; y < height; ++y) {
const float* source_row = pSourceRow + (y * width * depth);
for (int x = 0; x < width; ++x) {
const float *source_pixel = source_row + (x * depth); …Run Code Online (Sandbox Code Playgroud)