Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

SVM xml file support vectors all 0

$
0
0
Hello. I am attempting to train a model using gradients from an HOG descriptor. In total, there are about 7000 images whose feature vectors I am writing to my trainingData matrix. My svm finishes training within a minute and outputs a file whose support vectors all take on the form 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. // our labels are all initialized to being -1, Negative Mat gLabels = new Mat(posGCount + negCount, 1, CvType.CV_32FC1, new Scalar(-1.0)); Mat aLabels = new Mat(posACount + negCount, 1, CvType.CV_32FC1, new Scalar(-1.0)); // we overwrite the positive portion of the matrix with 1, Positive gLabels.rowRange(0,posGCount).setTo(new Scalar(1.0)); aLabels.rowRange(0,posACount).setTo(new Scalar(1.0)); Mat trainingMatG = new Mat(posGCount + negCount, 23328, gLabels.type()); // Mat trainingMatA = new Mat(posACount + negCount, 23328, gLabels.type()); //creating arrays for our feature vectors Mat[] featuresG = new Mat[posGCount]; Mat[] featuresA = new Mat[posACount]; Mat[] featuresN = new Mat[negCount]; // TODO - add each feature vector to corresponding array // TODO - fix issue with insufficient memory for(File[] set : trainingSets){ int count = 0; for(File image : set){ // read in the image as a matrix Mat img = Highgui.imread(image.getAbsolutePath(), 0); // create a new descriptor HOGDescriptor descriptor = new HOGDescriptor(new Size(640,360),new Size(512,288), new Size(64,36), new Size(32,16), 9); // initialize a vector in which the features will be placed MatOfFloat descriptors = new MatOfFloat(); // compute the feature vector and store it in 'descriptors' descriptor.compute(img, descriptors); if(set.equals(trainingSetG)) featuresG[count] = descriptors; if(set.equals(negative)) featuresN[count] = descriptors; count++; System.out.println(count); } } System.out.println("Adding features to training matrix..."); for(int i=0;i

Viewing all articles
Browse latest Browse all 19555

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>