maybe something like this will work:
float trainingData[][] = new float[][]{ new float[]{501, 10}, new float[]{255, 10}, new float[]{501, 255}, new float[]{10, 501} };
Mat trainingDataMat = new Mat(4, 2, CvType.CV_32FC1);
for (int i=0;i<4;i++)
trainingDataMat.put(i,0, trainingData[i]);
The code itself explains: you have data in the TrainingData array, and you assign a new Mat object. Then you use the put method to push the lines in place.
source
share