我目前正在使用ReadTensorFromImageFile()
函数读取图像。但我想使用 OpenCV 功能阅读。
张量流图像读取:
Status read_tensor_status =
ReadTensorFromImageFile(image_path, input_height, input_width, input_mean,
input_std, &resized_tensors);
if (!read_tensor_status.ok()) {
LOG(ERROR) << read_tensor_status;
return -1;
}
// @resized_tensor: the tensor storing the image
const Tensor &resized_tensor = resized_tensors[0];
auto resized_tensor_height = resized_tensor.shape().dim_sizes()[1];
auto resized_tensor_width = resized_tensor.shape().dim_sizes()[2];
std::cout << "resized_tensor_height:\t" << resized_tensor_height
<< "\nresized_tensor_width:\t" << resized_tensor_width << std::endl;
出去
resized_tensor_height: 416
resized_tensor_width: 416
相同的阅读想要使用 OpenCV 函数来完成。转换 OpenCV 格式后,想要传递resized_tensor
到这个会话中
Status run_status = session->Run({{input_layer, resized_tensor}},
output_layer, {}, &outputs);