Mat m = Mt.converterParaMat(Mt.imagemFinal);
m.convertTo(m, CvType.CV_32F);
Imgproc.resize(m, m, tamanho);//tamanho 120x120
m = m.reshape(1,200); //tamanho 200x216
trainDados.push_back(m);
trainLabs.add(1);
Mat xx = new Mat();
xx = Converters.vector_int_to_Mat(trainLabs);
xx.convertTo(xx, CvType.CV_32F);
Imgproc.resize(xx, xx, tamanho); //tamanho 120x120
xx.reshape(1,200); //tamanho 120x120 - não altera para 200x216?
kn.train(trainDados, Ml.ROW_SAMPLE , xx);
retorna o erro
OpenCV Error: Assertion failed ((layout == ROW_SAMPLE && responses.rows == nsamples) || (layout == COL_SAMPLE && responses.cols == nsamples)) in cv::ml::TrainDataImpl::setData, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\ml\src\data.cpp, line 290 Exception in thread "AWT-EventQueue-0" CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\ml\src\data.cpp:290: error: (-215) (layout == ROW_SAMPLE && responses.rows == nsamples) || (layout == COL_SAMPLE && responses.cols == nsamples) in function cv::ml::TrainDataImpl::setData ] at org.opencv.ml.StatModel.train_0(Native Method) at org.opencv.ml.StatModel.train(StatModel.java:74)
java 8, opencv 3.2, windows 10