List of usage examples for org.opencv.imgproc Imgproc getRectSubPix
public static void getRectSubPix(Mat image, Size patchSize, Point center, Mat patch)
From source file:com.trandi.opentld.tld.LKTracker.java
License:Apache License
/** * @return real similarities errors//from w w w . jav a2 s . c o m */ private float[] normCrossCorrelation(final Mat lastImg, final Mat currentImg, final Point[] lastPoints, final Point[] currentPoints, final byte[] status) { final float[] similarity = new float[lastPoints.length]; final Mat lastPatch = new Mat(CROSS_CORR_PATCH_SIZE, CvType.CV_8U); final Mat currentPatch = new Mat(CROSS_CORR_PATCH_SIZE, CvType.CV_8U); final Mat res = new Mat(new Size(1, 1), CvType.CV_32F); for (int i = 0; i < lastPoints.length; i++) { if (status[i] == 1) { Imgproc.getRectSubPix(lastImg, CROSS_CORR_PATCH_SIZE, lastPoints[i], lastPatch); Imgproc.getRectSubPix(currentImg, CROSS_CORR_PATCH_SIZE, currentPoints[i], currentPatch); Imgproc.matchTemplate(lastPatch, currentPatch, res, Imgproc.TM_CCOEFF_NORMED); similarity[i] = Util.getFloat(0, 0, res); } else { similarity[i] = 0f; } } return similarity; }
From source file:syncleus.dann.data.video.LKTracker.java
License:Apache License
/** * @return real similarities errors// ww w .j av a 2 s .co m */ private float[] normCrossCorrelation(final Mat lastImg, final Mat currentImg, final Point[] lastPoints, final Point[] currentPoints, final byte[] status) { final float[] similarity = new float[lastPoints.length]; final Mat lastPatch = new Mat(CROSS_CORR_PATCH_SIZE, CvType.CV_8U); final Mat currentPatch = new Mat(CROSS_CORR_PATCH_SIZE, CvType.CV_8U); final Mat res = new Mat(new Size(1, 1), CvType.CV_32F); for (int i = 0; i < lastPoints.length; i++) { if (status[i] == 1) { Imgproc.getRectSubPix(lastImg, CROSS_CORR_PATCH_SIZE, lastPoints[i], lastPatch); Imgproc.getRectSubPix(currentImg, CROSS_CORR_PATCH_SIZE, currentPoints[i], currentPatch); Imgproc.matchTemplate(lastPatch, currentPatch, res, Imgproc.TM_CCOEFF_NORMED); similarity[i] = TLDUtil.getFloat(0, 0, res); } else { similarity[i] = 0f; } } return similarity; }