opencv mat で動的な 2 次元配列を読み取る必要があります
int main()
{
Mat matrix;
double **theArray;
int numOfRows,numOfCols;
cin >> numOfRows ;
cin >> numOfCols ;
theArray = AllocateDynamicArray<double>(numOfRows,numOfCols);
matrix = Mat(numOfRows,numOfCols,CV_64FC1,&theArray);
string filename = "IN.xml";
FileStorage fs1(filename, FileStorage::WRITE);
fs1.open(filename, FileStorage::WRITE);
fs1 << "locsINMat" << matrix;
fs1 << "descriptorsINMat" << matrix;
fs1.release();
cout << "---------------------" << endl;
FreeDynamicArray(theArray);
}
template <typename T>
T **AllocateDynamicArray( int nRows, int nCols)
{
T **dynamicArray;
dynamicArray = new T*[nRows];
for( int i = 0 ; i < nRows ; i++ )
dynamicArray[i] = new T [nCols];
return dynamicArray;
}
template <typename T>
void FreeDynamicArray(T** dArray)
{
delete [] *dArray;
delete [] dArray;
}
この例外が発生します: GP.exe の 0x5d08f1aa で未処理の例外: 0xC0000005: 場所 0x003f4000 を読み取るアクセス違反。