I'm working on convert the python code to C++, I got a data structure problems about Mat
in OpenCV (C++ version) and image preprocessing
in Python.
Python code is following:
img = image.load_img(img_path)
img = img.resize((d_widght, d_height), image.NEAREST).convert('RGB')
img = image.img_to_array(img)
and the result of the img after 'image.img_to_array' is a three dimension array 3*384.
C++ code is following here:
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.
Then, the 'imgdst'
is same as the 'img'
in python, which is a 3*384
array?
yes imgdst is the same as img, even in c++ you may
Mat img = imread('1.jpg');
resize(img, img,Size(384,384));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.