我正在尝试使用以下代码缝合 5 个具有 ROI 的图像。length_error
即使vImg
向量和rois
大小相同,我也会不断收到未处理的内存异常。另外,为什么rois
应该是向量的向量Rect
?内部向量的大小为 1。
int main()
{
std::ostringstream filepath;
vector<Mat> vImg;
vImg.resize(5);
vector <Rect> tmpRect;
vector<vector<Rect>> rois;
rois.resize(5);
vector<Mat> channels;
for (int idx = 0; idx < 5; idx++)
{
filepath << "C:\\stch3" << idx+1 << ".jpg";
Mat tmpImg = imread(filepath.str());
vImg[idx] = tmpImg;
Rect rect(0, 50, vImg[idx].cols , vImg[idx].rows-70);
tmpRect.push_back(rect);
rois[idx] = (tmpRect);
tmpRect.clear();
filepath.str("");
}
Stitcher stitcher = Stitcher::createDefault(true);
Mat rImg;
Stitcher::Status status = stitcher.stitch(vImg, rois, rImg);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << "Estimate Transform :" << int(status) << endl;
}
imshow("Stitching Result", rImg);
waitKey(0);
return 0;
}