Mat转Tensor
img = cv::imread(img_path);
TensorShape shape({1, img.rows , img.cols, 3});
input_tensor = Tensor(tensorflow::DT_UINT8, shape);
uint8_t *p = input_tensor.flat<uint8_t>().data();
Mat fakeMat(img.rows, img.cols, cv::CV_8UC3, p);
img.convertTo(fakeMat, cv::CV_8UC3);
protobuf
原因:老版protobuf的头文件里找不到该定义,添加头文件路径tensorflow/contrib/makefile/downloads/protobuf/src/
本文介绍了如何在C++环境中将OpenCV的Mat对象转换为TensorFlow中的Tensor对象,包括创建Tensor、设置形状及数据类型等步骤,并解决了由于protobuf版本不一致导致的问题。
1634

被折叠的 条评论
为什么被折叠?



