Background substraction

Rozpoznání objektů v obraze

compile files("/usr/share/OpenCV/java/opencv-320.jar")

System.load("/usr/share/OpenCV/java/libopencv_java320.so");

public List<ClusterInfo> clusters(Mat sourceImg, int k) {

Mat samples32f = new Mat();
Mat allPixelsInOneRow = sourceImg.reshape(1, sourceImg.cols() * sourceImg.rows());

allPixelsInOneRow.convertTo(samples32f, CvType.CV_32F, 1.0 / 255.0);
allPixelsInOneRow.release();

TermCriteria criteria = new TermCriteria(TermCriteria.COUNT, 100, 1);
Mat labels = new Mat(sourceImg.width()*sourceImg.height(), 1, CvType.CV_32SC1);
labels.setTo(new Scalar(0));
Mat centers = new Mat();
/*kmeans (Mat data, int K, Mat bestLabels, TermCriteria criteria, int attempts, int flags, Mat centers) {*/
Core.kmeans(samples32f, k, labels, criteria, 1, Core.KMEANS_PP_CENTERS + Core.KMEANS_USE_INITIAL_LABELS, centers);
}

private List<ClusterInfo> createClustersBinaryImages(Mat sourceImg, Mat pixelLabels, Mat clusterCenters, int k) {
clusterCenters.convertTo(clusterCenters, CvType.CV_8UC1, 255.0);
clusterCenters.reshape(k);

int clusterCentersSize = clusterCenters.rows();
for (int i = 0; i < clusterCentersSize; i++) {
double[] centerL = clusterCenters.get(i, 0);
double[] centerA = clusterCenters.get(i, 1);
double[] centerB = clusterCenters.get(i, 2);

double[] centerLab = {centerL[0], centerA[0], centerB[0]};
...
}

nejsou tam nutné zámky

když pro testy potřebujeme simulovat service třetích stran

generování článku o průběhu a výsledku fotbalového utkání