May be you can try something like that :
bool MatVector(InputArray v)
{
if (!v.isVector())
return false;
int i= v.type();
if (v.type() == CV_32S && v.isContinuous())
{
Mat x= v.getMat();
cout<<"Mat = "<<x<<endl;
vector<int> myVector;
myVector.assign(x.begin<int>(), x.end<int>());
myVector[4]=245;
for (int i=0;i<myVector.size();i++)
cout<<myVector[i]<<"\t";
cout << "Mat = " << x << endl;
cout<<endl;
return true;
}
return false;
}
int main(int argc, char **argv)
{
Mat a = (Mat_<int>(4, 2) << 0, 1, 10, 11, 20, 21, 30, 31);
vector<int> va = { 0, 1, 10, 11, 20, 21, 30, 31 };
vector<double> vb = { 0, 1, 10, 11, 20, 21, 30, 31 };
if (MatVector(a))
cout << "vector \n";
else
cout << "It is not a vector \n";
if (MatVector(va))
{
cout << "vector \n";
for (int i = 0; i<va.size(); i++)
cout << va[i] << "\t";
}
if (MatVector(vb))
{
cout << "vector \n";
for (int i = 0; i<vb.size(); i++)
cout << vb[i] << "\t";
}
else
cout << "It is not a vector of int \n";
Do you want to use an existing function or write a new fucntion ?
@LBerger Obviously, I would like to use an existing one.