So, basically in python y have the following
img[np.array(coor[:, 1]), np.array(coor[:, 0])]
How can i do the same in C++?
coor is already a Mx2 Mat, img is a completely different Mat, i have been triying for a week or more and can't find a solution
M is the size Ok, so basically are the coordinates of my Mat so imagine 216 rows per 2 column which is the size a set of coor, basically iḿ triying to store the contours obtained from findcontours and retreive the same contours from a different mat.
this is the whole code in python
resized as it follows:
coor = cnts[ii].reshape((len(cnts[ii]), 2)) #cnts[ii] cnts[ii].reshape((len(cnts), 2))#cnts is the current contour contours
in C++ i have the folloing for the contours
vector<Point>cntst;//Retrieve the vector nested in the contours
and then due to lack of reshape as vector i move it to Mat
Mat reshap = Mat (cnts);
Mat coor = reshap.reshape(1);
Until this point it has the same size in C++ than in python, after that coor is employed to acces a compeltely different image in the coor coordinates as it follows
out = img[np.array(coor[:, 1]), np.array(coor[:, 0])]
it returns a 1D array with the gray values in the stored coordinates i cánt do the same in C++
First of all i have the contours in C++
vector<Point> cnts;//Retrieve the vector nested in the contours
Mat reshap = Mat (cntst); //cant reshape in a vector, so cast to Mat
Mat coor = reshap.reshape(1);// Until here have the same size that coor, and the same values
And then i dont know how to produce out equivalent in C++
i have img as Mat img = imread("my file",0);
generate the output from here img[np.array(coor[:, 1]), np.array(coor[:, 0])]