I am quite comfortable with OpenCV in Python. I recently switched to the C++ version, and I keep having problems with the cv::Mat
indexing, since I'm too used to numpy
's arrays.
In particular, I am trying to find if there is a better way of acting on a restricted area of an array without iterating through it.
For example, let's say I have a 10x15
unitary matrix and I would like to put everything but the last row to zero (or to another random number); in Python, I would do something like this:
import numpy as np
a = np.ones([10,15])
a[:-1,:-1] = 0
How can I achieve that in C++, having defined cv::Mat a = cv::Mat::ones(10, 15, CV_32FC1);
?