1 | initial version |
this is, because all the Mat's in your vector really point to the same data !
the vector constructor makes a "shallow" copy of the Mat argument only, so they all share the same data ptr.
the only remedy is to fill the vector with independant Mat's like:
// c++11
std::vector<cv::Mat> outfea_ = {
cv::Mat(5, 5, CV_32FC1, cv::Scalar(0)),
cv::Mat(5, 5, CV_32FC1, cv::Scalar(0)),
cv::Mat(5, 5, CV_32FC1, cv::Scalar(0))
};
// c++98
std::vector<cv::Mat> outfea_;
for (int i=0;i<3; i++) {
outfea_.push_back(cv::Mat(5, 5, CV_32FC1, cv::Scalar(0)));
}
2 | No.2 Revision |
this is, because all the Mat's in your vector really point to the same data !
the vector constructor makes a "shallow" copy of the Mat argument only, so they all share the same data ptr.
(this is not restricted to cv::Mat, you'll see that with anything, that contains a pointer, the vector makes shallow copies of the pointer, not whatever it points to)
the only remedy is to fill the vector with independant Mat's like:
// c++11
std::vector<cv::Mat> outfea_ = {
cv::Mat(5, 5, CV_32FC1, cv::Scalar(0)),
cv::Mat(5, 5, CV_32FC1, cv::Scalar(0)),
cv::Mat(5, 5, CV_32FC1, cv::Scalar(0))
};
// c++98
std::vector<cv::Mat> outfea_;
for (int i=0;i<3; i++) {
outfea_.push_back(cv::Mat(5, 5, CV_32FC1, cv::Scalar(0)));
}