本文整理汇总了Java中org.openimaj.math.geometry.shape.Rectangle.overlapping方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.overlapping方法的具体用法?Java Rectangle.overlapping怎么用?Java Rectangle.overlapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.math.geometry.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.overlapping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tldOverlapNorm
import org.openimaj.math.geometry.shape.Rectangle; //导入方法依赖的package包/类
/**
* {@link Rectangle#overlapping(Rectangle)} called and normalised by:
*
* @param A
* @param B
* @return intersect / (areaA + areaB - intersect)
*/
public static float tldOverlapNorm(Rectangle A, Rectangle B) {
Rectangle overlap = A.overlapping(B);
double intersect = overlap == null ? 0 : overlap.calculateArea();
double areaA = A.calculateArea();
double areaB = B.calculateArea();
return (float) (intersect / (areaA + areaB - intersect));
}
示例2: trackRedetect
import org.openimaj.math.geometry.shape.Rectangle; //导入方法依赖的package包/类
/**
* Redetect the faces in the new frame.
*
* @param im
* The new frame.
* @param searchAreaSize
* The search area size
*/
private void trackRedetect(final FImage im, final float searchAreaSize) {
final int ww = im.width;
final int hh = im.height;
// Resize the frame so processing is quicker.
this.small_ = ResizeProcessor.resample(im, (int) (MultiTracker.TSCALE * ww),
(int) (MultiTracker.TSCALE * hh));
for (final TrackedFace f : this.trackedFaces) {
f.gen = false;
// Get the new search area nearby to the last match
Rectangle searchAreaBounds = f.lastMatchBounds.clone();
searchAreaBounds.scale((float) MultiTracker.TSCALE);
searchAreaBounds.scaleCentroid(searchAreaSize);
if (searchAreaBounds.overlapping(this.small_.getBounds()) != null)
searchAreaBounds = searchAreaBounds.overlapping(this.small_.getBounds());
else
searchAreaBounds = this.small_.getBounds();
// Get the search image
final FImage searchArea = this.small_.extractROI(searchAreaBounds);
// Template match the template over the reduced size image.
final FourierTemplateMatcher matcher = new FourierTemplateMatcher(
f.templateImage,
FourierTemplateMatcher.Mode.NORM_CORRELATION_COEFFICIENT);
matcher.analyseImage(searchArea);
// Get the response map
final float[][] ncc_ = matcher.getResponseMap().pixels;
// DisplayUtilities.displayName( matcher.getResponseMap(),
// "responseMap" );
// DisplayUtilities.displayName( f.templateImage, "template" );
f.redetectedBounds = f.templateImage.getBounds();
// Find the maximum template match in the image
final int h = searchArea.height - f.templateImage.height + 1;
final int w = searchArea.width - f.templateImage.width + 1;
float vb = -2;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
final float v = ncc_[y][x];
if (v > vb) {
vb = v;
f.redetectedBounds.x = x + searchAreaBounds.x;
f.redetectedBounds.y = y + searchAreaBounds.y;
}
}
}
// Rescale the rectangle to full-size image coordinates.
f.redetectedBounds.scale((float) (1d / MultiTracker.TSCALE));
}
}