I am working on a project. I have here a vector<Mat> cache
. Somehow I am getting a weird error (I have already checked other solutions but its still occurring) when I run this module:
if(cache.size() == 10)
{
Mat sum_template = Mat::zeros(cache.at(1).size(), cache.at(1).type());
for(int i=0; i<cache.size(); i++)
{
sum_template += cache.at(i);
imshow("sum_template", sum_template); waitKey();
}
}
What I want to do is, add each of Mat
inside cache
to sum_template
. But, following error comes up on the line sum_template += cache.at(i);
:
The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op
I am simply adding Mat
s. I checked, the cache.at(i)
is properly displayed before crashing and also the cache size is 10 it shows. Any idea what is wrong here??
EDIT the cache is a vector of matrices similar to result matrix R as shown here