public void trackTemplate(IplImage object, IplImage image){
ObjectFinder.Settings settings = new ObjectFinder.Settings();
settings.setObjectImage(object);
settings.setUseFLANN(true);
settings.setDescriptorChannels(3);
settings.setRansacReprojThreshold(4);
ObjectFinder finder = new ObjectFinder(settings);
long start = System.currentTimeMillis();
double[] dst_corners = finder.find(image);
System.out.println(dst_corners.length);
System.out.println("Finding time = " + (System.currentTimeMillis() - start) + " ms");
if (dst_corners != null) {
for (int i = 0; i < 4; i++) {
int j = (i+1)%4;
int x1 = (int)Math.round(dst_corners[2*i ]);
int y1 = (int)Math.round(dst_corners[2*i + 1]);
int x2 = (int)Math.round(dst_corners[2*j ]);
int y2 = (int)Math.round(dst_corners[2*j + 1]);
line(cvarrToMat(image), new opencv_core.Point(x1, y1),
new opencv_core.Point(x2, y2),
Scalar.RED, 3, 8, 0);
}
}
}
Понравилась статья? Поделиться с друзьями: