1 | initial version |
null
pointer: SVM s = Ml.SVM.create();
int[] labels= {-1,1};
Mat labelsmat = new Mat(2,1,CV_32SC1);
labelsmat.put(0,0,labels);
Mat traindata = new Mat();
Mat image0 = Imgcodecs.imread("/home/tomna/NetBeansProjects/main/src/main/PLATES/1.jpg", 0);
traindata.push_back(image0.reshape(0,1));
Mat image1 = Imgcodecs.imread("/home/tomna/NetBeansProjects/main/src/main/PLATES/2.jpg", 0);
traindata.push_back(image1.reshape(0,1));
traindata.convertTo(traindata, CvType.CV_32F);
// then, 50k features per row is probably a bit too much...
s.train(traindata, 0, labelsmat);
(since it it can return only 1 value):
Mat result = new Mat();
s.predict(img_mat, result);
System.out.println(result.dump());
good luck !
2 | No.2 Revision |
null
pointer: SVM s = Ml.SVM.create();
int[] labels= {-1,1};
Mat labelsmat = new Mat(2,1,CV_32SC1);
labelsmat.put(0,0,labels);
Mat traindata = new Mat();
Mat image0 = Imgcodecs.imread("/home/tomna/NetBeansProjects/main/src/main/PLATES/1.jpg", 0);
traindata.push_back(image0.reshape(0,1));
Mat image1 = Imgcodecs.imread("/home/tomna/NetBeansProjects/main/src/main/PLATES/2.jpg", 0);
traindata.push_back(image1.reshape(0,1));
traindata.convertTo(traindata, CvType.CV_32F);
// then, 50k features per row is probably a bit too much...
s.train(traindata, 0, labelsmat);
(since it it can return only 1 value):
Mat result = new Mat();
s.predict(img_mat, s.predict(traindata, result);
System.out.println(result.dump());