Mat is some kind of smart pointer for the pixels

Mat a=b will have shared pixels for a and b. similar situation for push_back()

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

if you need a 'deep copy', use Mat::clone()

所以在初始化含Mat的容器时要用以下代码:

vector<cv::Mat> fims;
for (int numMat = 0; numMat < 6; numMat++) {
cv::Mat fim(m_hSample, m_wSample, CV_32FC3);
fims.push_back(fim);
}

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄