1 | initial version |
In file opencv\sources\modules\flann\src\miniflann.cpp, go to line 319:
buildIndex_(void*& index, const Mat& data, const IndexParams& params, const Distance& dist = Distance())
{
typedef typename Distance::ElementType ElementType;
if(DataType<ElementType>::type != data.type())
CV_Error_(CV_StsUnsupportedFormat, ("type=%d\n", data.type()));
//This is what is **causing the error**
if(!data.isContinuous())
CV_Error(CV_StsBadArg, "Only continuous arrays are supported");
/*The **reason** for the above check was because OpenCv uses flann library. The flann library uses class Matrix<ElementType> for storing Matrix data, but Opencv uses Mat for storing matrix data. Thus we need a way to convert Mat data to Matrix as done below. Here Mat is changed by considering Mat a continuous array, but your Mat is not continuous. You can circumvent this problem by using FLANN library directly and writing your own function to copy Mat(continuous or discontinuous) to Matrix. You can also file for improvement of this feature*/
::cvflann::Matrix<ElementType> dataset((ElementType*)data.data, data.rows, data.cols);
IndexType* _index = new IndexType(dataset, get_params(params), dist);
_index->buildIndex();
index = _index;
}