【发布时间】:2020-09-27 03:57:19
【问题描述】:
我的 tensorflow 模型期望图像具有以下形状:[1,512,512, 1],我正在尝试在 C++ 中扩展图像帧的尺寸。
在 Python 中,我可以按照以下方式进行操作,但如何在 C++ 中进行相同操作。
img = cv.imread('lena.png')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
print('gray Image Dimension: ',dimensions)
#gray Image Dimension : (512, 512)
input_ = np.expand_dims(gray, axis=0)
print('input_ Image Dimension: ',dimensions)
#input_ Image Dimension : (1, 512, 512)
output_ = np.expand_dims(input_, axis=3)
print('output_ Image Dimension: ',dimensions)
#output_ Image Dimension : (1, 512, 512, 1)
C++:
Mat src;
src = imread( lena.png, 1 );
cv::cvtColor(src, gray, cv::COLOR_BGR2GRAY);
// How can I convert it in to dimension of [1,512,512, 1]
【问题讨论】: