Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Getting error in bowTrainer.cluster ( )

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687

Getting error in bowTrainer.cluster ( )

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687

Getting error in bowTrainer.cluster ( )

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);

Second loop for training data :

for (k = all_names.begin(); k != all_names.end(); ++k)
{
      Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

      Mat row_img_2 = cv::imread( Dir +*k, 0 );

      detector.detect( row_img_2, keypoints);

      RetainBestKeypoints(keypoints, 20);

      dextract.compute( row_img_2, keypoints, descriptors_1);

      descriptors_1.reshape(1,1);

      training_mat.push_back(descriptors_1);

      labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1; // 1 for car, -1 otherwise*/

      ++count_2;
}

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687

Getting error in bowTrainer.cluster ( )

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);

Second loop for training data :

for (k = all_names.begin(); k != all_names.end(); ++k)
{
      Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

      Mat row_img_2 = cv::imread( Dir +*k, 0 );

      detector.detect( row_img_2, keypoints);

      RetainBestKeypoints(keypoints, 20);

      dextract.compute( row_img_2, keypoints, descriptors_1);

      descriptors_1.reshape(1,1);

      // Getting Error Here
      training_mat.push_back(descriptors_1);

      labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1; // 1 for car, -1 otherwise*/

      ++count_2;
}

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687

Getting error in bowTrainer.cluster ( )

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);
Mat training_mat(num_img,dictionarySize,CV_32FC1);
Mat labels(0,1,CV_32FC1);

Second loop for training data :

for (k = all_names.begin(); k != all_names.end(); ++k)
{
      Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

      Mat row_img_2 = cv::imread( Dir +*k, 0 );

      detector.detect( row_img_2, keypoints);

      RetainBestKeypoints(keypoints, 20);

      dextract.compute( row_img_2, keypoints, descriptors_1);

      descriptors_1.reshape(1,1);

      // Getting Error Here
      training_mat.push_back(descriptors_1);

      labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1; // 1 for car, -1 otherwise*/

      ++count_2;
}

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687

Getting error in bowTrainer.cluster ( )

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);
//may getting error here
Mat training_mat(num_img,dictionarySize,CV_32FC1);
Mat labels(0,1,CV_32FC1);

Second loop for training data :

for (k = all_names.begin(); k != all_names.end(); ++k)
{
      Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

      Mat row_img_2 = cv::imread( Dir +*k, 0 );

      detector.detect( row_img_2, keypoints);

      RetainBestKeypoints(keypoints, 20);

      dextract.compute( row_img_2, keypoints, descriptors_1);

      descriptors_1.reshape(1,1);

      // Getting Error Here
      training_mat.push_back(descriptors_1);

      labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1; // 1 for car, -1 otherwise*/

      ++count_2;
}

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687

Getting error in bowTrainer.cluster ( )matrix.cpp while training data

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);
//may getting error here
Mat training_mat(num_img,dictionarySize,CV_32FC1);
Mat labels(0,1,CV_32FC1);

Second loop for training data :

for (k = all_names.begin(); k != all_names.end(); ++k)
{
      Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

      Mat row_img_2 = cv::imread( Dir +*k, 0 );

      detector.detect( row_img_2, keypoints);

      RetainBestKeypoints(keypoints, 20);

      dextract.compute( row_img_2, keypoints, descriptors_1);

      descriptors_1.reshape(1,1);

      // Getting Error Here
      training_mat.push_back(descriptors_1);

      labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1; // 1 for car, -1 otherwise*/

      ++count_2;
}

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

OpenCV Error: Assertion failed (N>=K) (dims<=2 && data data && (unsigned) i < (unsigned)size..p[0] && (unsigned) (i1*DataType<_Tp>::channels) < (unsigned) size.[p1] * channels()) && ((((sizeof(size_t)<<28)|0x8442211)>>((DataType<_Tp>::depth)&((1<<3)-1))*4)&15)==eleSize1()) in unknown function , function, file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , c:\opencv\2.4.4\build\include\opencv2\core\mat.hpp, line 2687
537

Getting error in matrix.cpp mat.hpp while training data

I am doing feature extraction using surf and bow , but after i add descriptors in loop

      for (i = all_names.begin(); i != all_names.end(); ++i)
      {
        Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
        Mat row_img = cv::imread( Dir +*i, 0 );
        detector.detect( img, keypoints);
        CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
        extractor->compute( img, keypoints, descriptors);
        descriptors.resize(1,1);
        bow.add(descriptors);
        ++count;
      }

than after loop this is my code and i am getting runtime error here :

Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);
//may getting error here
Mat training_mat(num_img,dictionarySize,CV_32FC1);
Mat labels(0,1,CV_32FC1);

Second loop for training data :

for (k = all_names.begin(); k != all_names.end(); ++k)
{
      Dir=( (count_2 < files.size() ) ? YourImagesDirectory : YourImagesDirectory_2);

      Mat row_img_2 = cv::imread( Dir +*k, 0 );

      detector.detect( row_img_2, keypoints);

      RetainBestKeypoints(keypoints, 20);

      dextract.compute( row_img_2, keypoints, descriptors_1);

      descriptors_1.reshape(1,1);

      // Getting Error Here
      training_mat.push_back(descriptors_1);

      labels.at< float >(count_2, 0) = (count_2<nb_cars)?1:-1; // 1 for car, -1 otherwise*/

      ++count_2;
}

here is initialization :

int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();

Error :

OpenCV Error: Assertion failed (dims<=2 && data data && (unsigned) i < (unsigned)size..p[0] && (unsigned) (i1*DataType<_Tp>::channels) < (unsigned) size.[p1] * channels()) && ((((sizeof(size_t)<<28)|0x8442211)>>((DataType<_Tp>::depth)&((1<<3)-1))*4)&15)==eleSize1()) in unknown function, file c:\opencv\2.4.4\build\include\opencv2\core\mat.hpp, line 537