i am trying to construct the training matrix before applying it to the SVM i read in this post (http://stackoverflow.com/questions/14694810/using-opencv-and-svm-with-images) that the matrix should be the number of images(rows) and their size(size) in one matrix so my question is what if i have different sized images but same width and height and what to do about it and is the result correct to be used for SVM (as an output not logic) and here is my code and output
File file = new File("/home/tomna/NetBeansProjects/main/src/main/plates");
Mat training_mat= new Mat();
String[] images = new String[13];
Mat raw_img = new Mat();
for (int filenumber = 1; filenumber < 13; filenumber++) {
String stream;
stream = "/home/tomna/NetBeansProjects/main/src/main/cars" + "/" + filenumber + ".jpg";
String fullfile = stream;
images[filenumber] = fullfile;
}
for (int files = 1; files < 13; files++) {
raw_img = Imgcodecs.imread(images[files]);
if (!raw_img.empty()) {
int Area = raw_img.width() * raw_img.height();
System.out.println("succesfully loaded" + images[files] + "With size" + Area);
int num_files = 12;
training_mat = new Mat(files, Area, CvType.CV_32F);
} else {
System.out.println("Sorry error loading " + images[files]);
}
}
Mat vec = training_mat.reshape(0,1);
System.out.println(vec.clone());
output
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/1.jpg With size83166
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/2.jpg With size76800
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/3.jpg With size607500
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/4.jpg With size1920000
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/5.jpg With size50246
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/6.jpg With size513980
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/7.jpg With size2359296
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/8.jpg With size230400
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/9.jpg With size406272
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/10.jpg With size590848
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/11.jpg With size5992704
succesfully loaded/home/tomna/NetBeansProjects/main/src/main/cars/12.jpg With size5992704
Mat [ 1*71912448*CV_32FC1, isCont=true, isSubmat=false, nativeObj=0x7f5a38702220, dataAddr=0x7f595ddbc020 ]