c++ - Computing codebooks in OpenCV -


there questions referring same incomprehensible exception, ask minimal example.

i have following code:

  • load sift descriptors files;
  • normalize descriptors such cv_32f;

then:

  • initialize bowtrainer (code based on example found on-line):

    termcriteria tc(cv_termcrit_iter,100,0.001); int retries=1; int flags=kmeans_pp_centers; bowkmeanstrainer bow_trainer(dictionary_size, tc, retries, flags); 

and finally:

   vocabulary = bow_trainer.cluster(training_descriptors);  

where training_descriptors 1218772 * 128 cv_32f matrix containing 0,1 normalized sift descriptors.

unfortunately cluster generates exception saying:

opencv error: assertion failed (data.dims <= 2 && type == cv_32f && k > 0) in kmeans, file /users/u/downloads/opencv-2.4.4/modules/core/src/matrix.cpp, line 2686

the type of matrix correct, i.e., cv_32f , not understand data.dims should <=2 , why looks k <= 0.

by coincidence got same error. in case because descriptors mat had 0 elements in it. suspect data.dims <= 2 refers to.

opencv error: assertion failed (data.dims <= 2 && type == cv_32f && k > 0) in kmeans, file /home/ubuntu/opencv-2.4.5/modules/core/src/matrix.cpp, line 2686 

did check array of descriptors not empty?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -