本文整理汇总了Java中org.openimaj.math.geometry.shape.Rectangle类的典型用法代码示例。如果您正苦于以下问题:Java Rectangle类的具体用法?Java Rectangle怎么用?Java Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于org.openimaj.math.geometry.shape包,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: composite
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
private void composite(MBFImage back, MBFImage fore, Rectangle bounds) {
final float[][] rin = fore.bands.get(0).pixels;
final float[][] gin = fore.bands.get(1).pixels;
final float[][] bin = fore.bands.get(2).pixels;
final float[][] rout = back.bands.get(0).pixels;
final float[][] gout = back.bands.get(1).pixels;
final float[][] bout = back.bands.get(2).pixels;
final int xmin = (int) Math.max(0, bounds.x);
final int ymin = (int) Math.max(0, bounds.y);
final int ymax = (int) Math.min(Math.min(fore.getHeight(), back.getHeight()), bounds.y + bounds.height);
final int xmax = (int) Math.min(Math.min(fore.getWidth(), back.getWidth()), bounds.x + bounds.width);
for (int y = ymin; y < ymax; y++) {
for (int x = xmin; x < xmax; x++) {
if (rin[y][x] != 0 && gin[y][x] != 0 && bin[y][x] != 0) {
rout[y][x] = rin[y][x];
gout[y][x] = gin[y][x];
bout[y][x] = bin[y][x];
}
}
}
}
示例2: calculateRegularBoundingBox
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* Calculate the regular bounding box of the region by calculating the
* maximum and minimum x and y coordinates of the pixels contained within
* the region. The result is an integer array containing the (x,y)
* coordinate of the top-left of the bounding box, and the width and height
* of the bounding box.
*
* @return an {@link Rectangle} describing the bounds
*/
public Rectangle calculateRegularBoundingBox() {
int xmin = Integer.MAX_VALUE, xmax = 0, ymin = Integer.MAX_VALUE, ymax = 0;
for (final Pixel p : pixels) {
if (p.x < xmin)
xmin = p.x;
if (p.x > xmax)
xmax = p.x;
if (p.y < ymin)
ymin = p.y;
if (p.y > ymax)
ymax = p.y;
}
return new Rectangle(xmin, ymin, xmax - xmin, ymax - ymin);
}
示例3: extract
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
public Histogram extract(WindowedHistogramExtractor binnedData, Rectangle region, Histogram output) {
final Histogram[][] cells = computeCells(binnedData, region);
final Histogram[][] blocks = computeBlocks(cells);
final int blockSize = blocks[0][0].values.length;
final int blockArea = cellsPerBlockX * cellsPerBlockY;
if (output == null || output.values.length != blocks[0].length * blocks.length * blockSize)
output = new Histogram(blocks[0].length * blocks.length * blockSize);
for (int j = 0, k = 0; j < blocks.length; j++) {
for (int i = 0; i < blocks[0].length; i++, k++) {
norm.normalise(blocks[j][i], blockArea);
System.arraycopy(blocks[j][i].values, 0, output.values, k * blockSize, blockSize);
}
}
return output;
}
示例4: render
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
public void render(final MBFImageRenderer renderer, final Matrix transform, final Rectangle rectangle) {
if (this.toRender == null) {
try {
this.toRender = ImageUtilities.readMBF(VideoColourSIFT.class
.getResource("/org/openimaj/demos/OpenIMAJ.png"));
} catch (final IOException e) {
System.err.println("Can't load image to render");
}
this.renderToBounds = TransformUtilities.makeTransform(this.toRender.getBounds(), rectangle);
}
final MBFProjectionProcessor mbfPP = new MBFProjectionProcessor();
mbfPP.setMatrix(transform.times(this.renderToBounds));
mbfPP.accumulate(this.toRender);
mbfPP.performProjection(0, 0, renderer.getImage());
}
示例5: doTutorial
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
List<KEDetectedFace> faces = this.detector.detectFaces(toDraw.flatten());
for (KEDetectedFace detectedFace : faces) {
Rectangle b = detectedFace.getBounds();
Point2dImpl bp = new Point2dImpl(b.x,b.y);
toDraw.drawShape(b, RGBColour.RED);
FacialKeypoint[] kpts = detectedFace.getKeypoints();
List<Point2d> fpts = new ArrayList<Point2d>();
for(FacialKeypoint kpt : kpts){
Point2dImpl p = kpt.position;
p.translate(bp);
fpts.add(p);
}
toDraw.drawPoints(fpts, RGBColour.GREEN, 3);
}
}
示例6: consumeFrequency
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
public void consumeFrequency(final float[] fftReal, final float[] fftImag,final int low,final int high) {
final int blockWidth = 10;
final int blockHeight = 5;
if( this.spectra == null || this.spectra.getHeight() != (high-low) * blockHeight )
{
this.spectra = new FImage( this.mbfImage.getWidth(), (high-low)*blockHeight);
}
this.spectra.shiftLeftInplace(blockWidth);
// Draw the spectra
for( int i = low; i < high; i++ )
{
final float re = fftReal[i];
final float im = fftImag[i];
float mag = (float)Math.log(Math.sqrt( re*re + im*im )+1)/5;
if( mag > 1 ) mag = 1;
this.spectra.drawShapeFilled(new Rectangle(this.spectra.getWidth()-blockWidth, this.spectra.getHeight()-(i * blockHeight), blockWidth,blockHeight), mag );
}
final MBFImage toDraw = this.mbfImage.clone();
toDraw.drawImage(new MBFImage(this.spectra,this.spectra,this.spectra), (this.mbfImage.getWidth() - this.spectra.width)/2, this.mbfImage.getHeight() - this.spectra.height);
this.ic.setImage(this.buf = ImageUtilities.createBufferedImageForDisplay( toDraw, this.buf ));
}
示例7: partition
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
private int partition(List<Rectangle> rects, int[] classes) {
int numClasses = 0;
for (int i = 0; i < rects.size(); i++) {
boolean found = false;
for (int j = 0; j < i; j++) {
if (equals(rects.get(j), rects.get(i))) {
found = true;
classes[i] = classes[j];
}
}
if (!found) {
classes[i] = numClasses;
numClasses++;
}
}
return numClasses;
}
示例8: readASCII
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
public void readASCII(Scanner in) throws IOException {
this.gridWidth = in.nextInt();
this.gridHeight = in.nextInt();
this.visibleArea = new Rectangle(in.nextFloat(),in.nextFloat(),in.nextFloat(),in.nextFloat());
this.touchArray = new ArrayList<Point2d>();
while(in.hasNext()){
this.touchArray.add(
new Point2dImpl(in.nextFloat(),in.nextFloat())
);
}
this.createScreenArray();
this.createTriangles();
this.createNonLinearWarp();
}
示例9: Pong
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
public Pong(final int width, final int height) {
this.redText = new HashMap<Attribute, Object>();
this.redText.put(FontStyle.COLOUR, RGBColour.RED);
this.blueText = new HashMap<Attribute, Object>();
this.blueText.put(FontStyle.COLOUR, RGBColour.BLUE);
this.allFont = new HashMap<Attribute, Object>();
this.allFont.put(FontStyle.FONT, HersheyFont.ROMAN_SIMPLEX);
this.allFont.put(FontStyle.FONT_SIZE, 40);
this.frame_height = height;
this.frame_width = width;
this.lastFrame = new MBFImage(width, height, ColourSpace.RGB);
this.frame = new MBFImage(width, height, ColourSpace.RGB);
this.renderer = this.frame.createRenderer();
this.borderTop = new Rectangle(0, 0, width, height * Pong.BORDER_TOP);
this.borderBottom = new Rectangle(0, height * (1 - Pong.BORDER_BOTTOM), width, height * Pong.BORDER_BOTTOM);
this.initMatch();
this.getNextFrame();
}
示例10: getContentArea
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.openimaj.image.Image#getContentArea()
*/
@Override
public Rectangle getContentArea() {
int minx = this.getWidth(), maxx = 0, miny = this.getHeight(), maxy = 0;
for (int i = 0; i < this.numBands(); i++) {
final Rectangle box = this.getBand(i).getContentArea();
if (box.minX() < minx)
minx = (int) box.minX();
if (box.maxX() > maxx)
maxx = (int) box.maxX();
if (box.minY() < miny)
miny = (int) box.minY();
if (box.maxY() > maxy)
maxy = (int) box.maxY();
}
return new Rectangle(minx, miny, maxx - minx, maxy - miny);
}
示例11: analyseImage
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
public void analyseImage(FImage image, Rectangle bounds) {
if (data == null)
data = new WorkingData();
data.boundMinX = (int) bounds.x;
data.boundMaxX = (int) (bounds.width - 1);
data.boundMinY = (int) bounds.y;
data.boundMaxY = (int) (bounds.height - 1);
data.setupWorkingSpace(image, this);
FImageGradients.gradientMagnitudesAndQuantisedOrientations(image, data.gradientMagnitudes);
extractFeatures();
normaliseDescriptors();
}
示例12: extractFeatures
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
@Override
protected double[] extractFeatures(MBFImage image) {
double[][] patches = new double[rectangles.size()][];
final MBFImage tmpImage = new MBFImage(this.patchSize, this.patchSize);
for (int i = 0; i < patches.length; i++) {
final Rectangle r = rectangles.get(i);
patches[i] = image.extractROI((int) r.x, (int) r.y, tmpImage).getDoublePixelVector();
}
patches = whitening.whiten(patches);
patches = activation(patches);
// sum pooling
final double[] feature = pool(patches);
return feature;
}
示例13: selectObject
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* Set the current object being tracked. Initialilise the detector casecade
* using {@link DetectorCascade#init()}. The {@link #initialLearning()} is
* called
*
* @param img
* @param bb
* @throws Exception
*/
public void selectObject(FImage img, Rectangle bb) throws Exception {
// Delete old object
detectorCascade.release();
detectorCascade.setObjWidth((int) bb.width);
detectorCascade.setObjHeight((int) bb.height);
detectorCascade.setImgWidth(this.imgWidth);
detectorCascade.setImgHeight(this.imgHeight);
// Init detector cascade
detectorCascade.init();
currImg = img;
currBB = bb;
currConf = 1;
valid = true;
initialLearning();
}
示例14: getContentArea
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.openimaj.image.Image#getContentArea()
*/
@Override
public Rectangle getContentArea() {
int minc = this.width, maxc = 0, minr = this.height, maxr = 0;
for (int r = 0; r < this.height; r++) {
for (int c = 0; c < this.width; c++) {
if (this.pixels[r][c] > 0) {
if (c < minc)
minc = c;
if (c > maxc)
maxc = c;
if (r < minr)
minr = r;
if (r > maxr)
maxr = r;
}
}
}
return new Rectangle(minc, minr, maxc - minc + 1, maxr - minr + 1);
}
示例15: trackObject
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* Reset this tracker using the given image
* @return TRUE if the tracking continued ok; FALSE otherwise
*/
@Override
public List<Rectangle> trackObject( FImage img )
{
List<Rectangle> trackedObjects = new ArrayList<Rectangle>();
tracker.trackFeatures( previousFrame, img );
// If we're losing features left-right and centre then we say
// we've lost the object we're tracking
if( featureList.countRemainingFeatures() <= featuresFound * accuracy )
return trackedObjects;
trackedObjects.add( featureList.getBounds() );
previousFrame = img;
return trackedObjects;
}