展开C+中OpenCV mat对象的尺寸+; 我的TysFooFrad模型期望图像有形状:(1512512, 1)并且我试图扩展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) 在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+中OpenCV mat对象的尺寸+; 我的TysFooFrad模型期望图像有形状:(1512512, 1)并且我试图扩展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) 在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),python,c++,opencv,Python,C++,Opencv,C++: std::coutstd::cout

C++:

std::cout
std::cout