本文整理汇总了Java中org.openimaj.math.geometry.shape.Rectangle类的典型用法代码示例。如果您正苦于以下问题:Java Rectangle类的具体用法?Java Rectangle怎么用?Java Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于org.openimaj.math.geometry.shape包,在下文中一共展示了Rectangle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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];
}
}
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:MultiPuppeteer.java
示例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);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:PixelSet.java
示例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;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:FixedHOGStrategy.java
示例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());
}
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:VideoColourSIFT.java
示例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);
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:FaceKETrackingTutorial.java
示例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 ));
}
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:AudioOutroSlide.java
示例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;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:OpenCVGrouping.java
示例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();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:TriangleCameraConfig.java
示例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();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:Pong.java
示例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);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:MultiBandImage.java
示例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();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:DenseSIFT.java
示例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;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:KMeansExp1.java
示例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();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:TLD.java
示例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);
}
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:FImage.java
示例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;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:BasicObjectTracker.java
示例16: drawModel
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* Draw the model onto the image
*
* @param image
* The image to draw onto
* @param drawTriangles
* Whether to draw the triangles
* @param drawConnections
* Whether to draw the connections
* @param drawPoints
* Whether to draw the points
* @param drawSearchArea
* Whether to draw the search area
* @param drawBounds
* Whether to draw the bounds
*/
public void drawModel(final MBFImage image, final boolean drawTriangles,
final boolean drawConnections, final boolean drawPoints,
final boolean drawSearchArea, final boolean drawBounds)
{
for (int fc = 0; fc < this.model.trackedFaces.size(); fc++) {
final MultiTracker.TrackedFace f = this.model.trackedFaces.get(fc);
if (drawSearchArea) {
// Draw the search area size
final Rectangle r = f.lastMatchBounds.clone();
r.scaleCentroid(this.searchAreaSize);
image.createRenderer().drawShape(r, RGBColour.YELLOW);
}
// Draw the face model
CLMFaceTracker.drawFaceModel(image, f, drawTriangles, drawConnections, drawPoints,
drawSearchArea, drawBounds, this.triangles, this.connections, this.scale,
this.boundingBoxColour, this.meshColour, this.connectionColour,
this.pointColour);
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:38,代码来源:CLMFaceTracker.java
示例17: read
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
static Tracker read(Scanner s, boolean readType) {
if (readType) {
int type = s.nextInt();
assert (type == IO.Types.TRACKER.ordinal());
}
Tracker tracker = new Tracker();
tracker._clm = CLM.read(s, true);
tracker._fdet = FDet.read(s, true);
tracker._fcheck = MFCheck.read(s, true);
tracker._rshape = IO.readMat(s);
tracker._simil = new double[] { s.nextDouble(), s.nextDouble(),
s.nextDouble(), s.nextDouble() };
tracker._shape = new Matrix(2 * tracker._clm._pdm.nPoints(), 1);
tracker._rect = new Rectangle();
tracker._rect.x = 0;
tracker._rect.y = 0;
tracker._rect.width = 0;
tracker._rect.height = 0;
tracker._frame = -1;
tracker._clm._pdm.identity(tracker._clm._plocal, tracker._clm._pglobl);
return tracker;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:Tracker.java
示例18: initShape
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
void initShape(Rectangle r, Matrix shape) {
assert ((shape.getRowDimension() == _rshape.getRowDimension()) && (shape
.getColumnDimension() == _rshape.getColumnDimension()));
int n = _rshape.getRowDimension() / 2;
double a = r.width * Math.cos(_simil[1]) * _simil[0] + 1;
double b = r.width * Math.sin(_simil[1]) * _simil[0];
double tx = r.x + (int) (r.width / 2) + r.width * _simil[2];
double ty = r.y + (int) (r.height / 2) + r.height * _simil[3];
double[][] s = _rshape.getArray();
double[][] d = shape.getArray();
for (int i = 0; i < n; i++) {
d[i][0] = a * s[i][0] - b * s[i + n][0] + tx;
d[i + n][0] = b * s[i][0] + a * s[i + n][0] + ty;
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:Tracker.java
示例19: detect
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* Detect faces in an image
*
* @param im
* the image
* @return the detected faces
*/
public List<Rectangle> detect(final FImage im) {
final int w = Math.round(im.width / this._img_scale);
final int h = Math.round(im.height / this._img_scale);
this.small_img_ = ResizeProcessor.resample(im, w, h).processInplace(
new EqualisationProcessor());
List<Rectangle> rects = this.detector.detect(this.small_img_);
rects = ObjectIntPair.getFirst(this.grouping.apply(rects));
for (final Rectangle r : rects) {
r.scale(this._img_scale);
}
return rects;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:FDet.java
示例20: getBounds
import org.openimaj.math.geometry.shape.Rectangle; //导入依赖的package包/类
/**
* Returns the bounding box of the features
* @return the bounding box of the features
*/
public Rectangle getBounds()
{
float minX = Float.MAX_VALUE;
float maxX = Float.MIN_VALUE;
float minY = Float.MAX_VALUE;
float maxY = Float.MIN_VALUE;
for( Feature f : features )
{
if( f.val >= 0 )
{
minX = Math.min( minX, f.x );
maxX = Math.max( maxX, f.x );
minY = Math.min( minY, f.y );
maxY = Math.max( maxY, f.y );
}
}
return new Rectangle( minX, minY, maxX-minX, maxY-minY );
}
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:FeatureList.java
注:本文中的org.openimaj.math.geometry.shape.Rectangle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论