使用python预处理后,C++(opencv)中的垫子类型数据与image_to_array相同

Mat type data in C++ (opencv) as same as the image_to_array after using python preprocessing?

本文关键字:数据 类型 image array to 相同 预处理 python C++ opencv 使用      更新时间:2023-10-16

我正在努力将python代码转换为C++,我遇到了有关OpenCV(C++版本(中的Mat和Python中image preprocessing的数据结构问题。

Python 代码如下:

img = image.load_img(img_path)
img = img.resize((d_widght, d_height), image.NEAREST).convert('RGB')
img = image.img_to_array(img)

而"image.img_to_array"之后的 IMG 结果是一个三维数组 3*384。

C++代码如下:

Mat img = imread('1.jpg');
Mat imgdst;
resize(img, imgdst,Size(384,384)); 
//because the image size after resize in python is (384*384), so here I just convert the image size using this line.

那么,'imgdst'和python中的'img'一样,哪个是3*384数组?

是的,imgdst与img相同,即使在C ++中,您也可以

Mat img = imread('1.jpg');
resize(img, img,Size(384,384));