当前位置: 首页>>代码示例>>Java>>正文


Java MBFImage.drawText方法代码示例

本文整理汇总了Java中org.openimaj.image.MBFImage.drawText方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.drawText方法的具体用法?Java MBFImage.drawText怎么用?Java MBFImage.drawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openimaj.image.MBFImage的用法示例。


在下文中一共展示了MBFImage.drawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	tracker.track(frame);

	frame.bands.get(1).fill(0f);
	frame.bands.get(2).fill(0f);

	final FontStyle<Float[]> gfs = new GeneralFont("Bank Gothic", Font.PLAIN).createStyle(frame
			.createRenderer(RenderHints.ANTI_ALIASED));
	gfs.setFontSize(40);
	gfs.setHorizontalAlignment(HorizontalAlignment.HORIZONTAL_CENTER);

	if (tracker.getTrackedFaces().size() > 0) {
		final TrackedFace tf = tracker.getTrackedFaces().get(0);
		drawFaceModel(frame, tf, tracker.triangles, tracker.connections);
		frame.drawText("TRACKING", frame.getWidth() / 2, frame.getHeight() - 10, gfs);
	} else {
		frame.drawText("SEARCHING", frame.getWidth() / 2, frame.getHeight() / 2, gfs);
	}
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:21,代码来源:CLMDemo.java

示例2: plot2d

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
MBFImage plot2d(double[][] data) {
	final MBFImage img = new MBFImage(500, 500, ColourSpace.RGB);

	img.drawLine(img.getWidth() / 2, img.getHeight() - 50, img.getWidth() / 2, 50, 3, RGBColour.RED);
	img.drawLine(img.getWidth() / 2 - 10, 70, img.getWidth() / 2, 50, 3, RGBColour.RED);
	img.drawLine(img.getWidth() / 2 + 10, 70, img.getWidth() / 2, 50, 3, RGBColour.RED);
	img.drawText("EV2", img.getWidth() / 2 - 80, 70, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);

	img.drawLine(50, img.getHeight() / 2, img.getWidth() - 50, img.getHeight() / 2, 3, RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 + 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 - 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawText("EV1", img.getWidth() - 70, img.getHeight() / 2 + 50, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);

	for (final double[] d : data) {
		img.drawPoint(new Point2dImpl(img.getWidth() / 2 - (float) d[0], img.getHeight() / 2 - (float) d[1]),
				RGBColour.GREEN, 3);
	}

	return img;
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:23,代码来源:PCADemo.java

示例3: plot1d

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
MBFImage plot1d(double[][] data) {
	final MBFImage img = new MBFImage(500, 500, ColourSpace.RGB);

	img.drawLine(50, img.getHeight() / 2, img.getWidth() - 50, img.getHeight() / 2, 3, RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 + 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawLine(img.getWidth() - 70, img.getHeight() / 2 - 10, img.getWidth() - 50, img.getHeight() / 2, 3,
			RGBColour.RED);
	img.drawText("EV1", img.getWidth() - 70, img.getHeight() / 2 + 50, HersheyFont.ROMAN_DUPLEX, 40, RGBColour.RED);

	for (final double[] d : data) {
		img.drawPoint(new Point2dImpl(img.getWidth() / 2 - (float) d[0], img.getHeight() / 2),
				RGBColour.GREEN, 3);
	}

	return img;
}
 
开发者ID:jonhare,项目名称:COMP6237,代码行数:18,代码来源:PCADemo.java

示例4: displayQueryResults

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * 
 * @param resource
 * @return The displayed image
 * @throws Exception
 */
public static MBFImage displayQueryResults(final URL resource) throws Exception
{
	System.out.println("----------- QUERYING ----------- ");
	final FImage fi = ImageUtilities.readF(resource);
	final PersonMatcher pm = new PersonMatcher(new File(PersonMatcher.RECOGNISER_FILE));
	final List<? extends IndependentPair<? extends DetectedFace, ScoredAnnotation<String>>> l = pm.query(fi);

	final MBFImage m = new MBFImage(fi.getWidth(), fi.getHeight(), 3);
	m.addInplace(fi);
	int count = 1;
	for (final IndependentPair<? extends DetectedFace, ScoredAnnotation<String>> i : l)
	{
		final Rectangle b = i.firstObject().getBounds();
		m.drawShape(b, RGBColour.RED);
		final String name = count + " : " +
				(i.secondObject() == null ? "Unknown" : i.secondObject().annotation);
		m.drawText(name, (int) b.x, (int) b.y,
				HersheyFont.TIMES_MEDIUM, 12, RGBColour.GREEN);
		count++;
	}
	DisplayUtilities.display(m);
	return m;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:PersonMatcher.java

示例5: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public synchronized void beforeUpdate(MBFImage frame) {
	this.currentFrame = frame.flatten();
	engine.track(frame);
	engine.drawModel(frame, true, true, true, true, true);

	if (recogniser != null && recogniser.listPeople().size() >= 1) {
		for (final CLMDetectedFace f : detectFaces()) {
			final List<ScoredAnnotation<String>> name = recogniser.annotate(f);

			if (name.size() > 0) {
				final Point2d r = f.getBounds().getTopLeft();
				frame.drawText(name.get(0).annotation, r, HersheyFont.ROMAN_SIMPLEX, 15, RGBColour.GREEN);
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:18,代码来源:VideoFaceRecognition.java

示例6: getCurrentImage

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private MBFImage getCurrentImage() {
	if(imageValues.length<1)return null;
	double[] imageDoubles = imageValues[this.currentImageIndex];
	int wh = (int) Math.sqrt(imageDoubles.length);
	int i = 0;
	if(this.currentImage == null)
		this.currentImage = new FImage(wh,wh);
	for (int x = 0; x < wh; x++) {
		for (int y = 0; y < wh; y++) {
			this.currentImage.pixels[y][x] = (float) imageDoubles[i++];
		}
	}
	MBFImage toDraw = this.currentImage.normalise().process(rp).toRGB();
	toDraw.drawText("Guess: " + this.numberValues[this.currentImageIndex],10, 30, HersheyFont.ASTROLOGY	, 20, RGBColour.RED);
	return toDraw;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:HandWritingInputDisplay.java

示例7: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Main method
 * 
 * @param args
 */
public static void main(String[] args) {
	// Create an image
	final MBFImage image = new MBFImage(320, 70, ColourSpace.RGB);

	// Fill the image with white
	image.fill(RGBColour.WHITE);

	// Render some test into the image
	image.drawText("Hello World", 10, 60, HersheyFont.CURSIVE, 50, RGBColour.BLACK);

	// Apply a Gaussian blur
	image.processInplace(new FGaussianConvolve(2f));

	// Display the image
	DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:App.java

示例8: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main( String[] args ) {
	//Create an image
    MBFImage image = new MBFImage(320,70, ColourSpace.RGB);

    //Fill the image with white
    image.fill(RGBColour.WHITE);
    		        
    //Render some test into the image
    image.drawText("Hello World", 10, 60, HersheyFont.CURSIVE, 50, RGBColour.BLACK);

    //Apply a Gaussian blur
    image.processInplace(new FGaussianConvolve(2f));
    
    //Display the image
    DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:App.java

示例9: renderOrtho

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void renderOrtho(Matrix transform, int tx, int ty, MBFImage image) {
	final Point2dImpl pt1 = projectOrtho(transform.times(pt));
	pt1.x += tx;
	pt1.y += ty;
	pt1.y = image.getHeight() - pt1.y;
	image.drawText(text, pt1, HersheyFont.ROMAN_DUPLEX, size, colour);
}
 
开发者ID:jonhare,项目名称:ecs-summer-school-vision-lecture,代码行数:9,代码来源:Simple3D.java

示例10: Fonts

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * 	Construct the fonts demo.
 */
public Fonts()
{
	final MBFImage img = new MBFImage( 800, 600, 3 );
	img.drawText( "OOpenIMAJ", 20, 100,
			new GeneralFont("Arial", Font.PLAIN ), 120, RGBColour.WHITE );
	img.drawText( "is Awesome!", 20, 220,
			new GeneralFont("Courier", Font.PLAIN ), 120, RGBColour.WHITE );
	img.drawText( "HHope you agree", 20, 400,
			new GeneralFont("Comic Sans MS", Font.PLAIN ), 50, RGBColour.WHITE );

	DisplayUtilities.display( img );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:16,代码来源:Fonts.java

示例11: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Main method
 * 
 * @param args
 *            ignored
 * @throws IOException
 *             if image can't be loaded
 */
public static void main(final String[] args) throws IOException
{
	final URL imgurl = new URL("http://www.sableandhogg-gallery.co.uk/shop/images/autumn%20landscape,%20beacons.jpg");

	// ------------------------------------------------------------------
	// FImage test
	// ------------------------------------------------------------------
	final FImage fi1 = ImageUtilities.readF(imgurl);
	final FImage fi2 = new FImage(300, 100);
	fi2.drawText("HELLO", 0, 35, new GeneralFont("Arial", Font.BOLD), 48);

	final FImage alpha = fi2.clone().multiplyInplace(0.5f);
	fi1.overlayInplace(fi2, alpha, 200, 200);

	DisplayUtilities.display(fi1, "Composite");

	// ------------------------------------------------------------------
	// MBFImage test
	// ------------------------------------------------------------------
	final MBFImage i1 = ImageUtilities.readMBF(imgurl);
	final MBFImage i2 = new MBFImage(300, 100, 3);
	i2.drawText("HELLO", 0, 35, new GeneralFont("Arial", Font.BOLD), 48);
	i2.addBand(alpha);
	i1.overlayInplace(i2, 200, 200);
	DisplayUtilities.display(i1, "Multiband Composite");

	final MBFImage i1b = ImageUtilities.readMBF(imgurl);
	i1b.drawImage(i2, 200, 200);
	DisplayUtilities.display(i1b, "Multiband Composite");
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:39,代码来源:AlphaCompositionExample.java

示例12: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Main method
 * 
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
	// Load the image
	final MBFImage image = ImageUtilities.readMBF(new URL("http://static.openimaj.org/media/tutorial/sinaface.jpg"));

	// Print colour space
	System.out.println(image.colourSpace);

	// Display the image
	DisplayUtilities.display(image);
	DisplayUtilities.display(image.getBand(0), "Red Channel");

	// Set blue and green pixels to black, and draw
	final MBFImage clone = image.clone();
	for (int y = 0; y < image.getHeight(); y++) {
		for (int x = 0; x < image.getWidth(); x++) {
			clone.getBand(1).pixels[y][x] = 0;
			clone.getBand(2).pixels[y][x] = 0;
		}
	}
	DisplayUtilities.display(clone);

	// Find edges
	image.processInplace(new CannyEdgeDetector());
	DisplayUtilities.display(image);

	// Draw some stuff
	image.drawShapeFilled(new Ellipse(700f, 450f, 20f, 10f, 0f), RGBColour.WHITE);
	image.drawShapeFilled(new Ellipse(650f, 425f, 25f, 12f, 0f), RGBColour.WHITE);
	image.drawShapeFilled(new Ellipse(600f, 380f, 30f, 15f, 0f), RGBColour.WHITE);
	image.drawShapeFilled(new Ellipse(500f, 300f, 100f, 70f, 0f), RGBColour.WHITE);
	image.drawText("OpenIMAJ is", 425, 300, HersheyFont.ASTROLOGY, 20, RGBColour.BLACK);
	image.drawText("Awesome", 425, 330, HersheyFont.ASTROLOGY, 20, RGBColour.BLACK);
	DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:41,代码来源:App.java

示例13: drawLabels

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void drawLabels(MBFImage ret, TernaryParams params) {
	final int padding = (Integer) params.getTyped(TernaryParams.PADDING);
	final List<IndependentPair<TernaryData, String>> labels = params.getTyped(TernaryParams.LABELS);
	final Map<? extends Attribute, Object> typed = params.getTyped(TernaryParams.LABEL_FONT);
	final FontStyle<Float[]> fs = FontStyle.parseAttributes(typed, ret.createRenderer());
	final Float[] labelBackground = params.getTyped(TernaryParams.LABEL_BACKGROUND);
	final Float[] labelBorder = params.getTyped(TernaryParams.LABEL_BORDER);
	final int labelPadding = (Integer) params.getTyped(TernaryParams.LABEL_PADDING);
	final FontRenderer<Float[], FontStyle<Float[]>> fontRenderer = fs.getRenderer(ret.createRenderer());
	if (labels != null) {
		for (final IndependentPair<TernaryData, String> labelPoint : labels) {
			final TernaryData ternaryData = labelPoint.firstObject();
			final Point2d point = ternaryData.asPoint();
			point.setX(point.getX() * width + padding);
			point.setY(height - (point.getY() * width) + padding);
			final Point2d p = point.copy();
			if (point.getY() < height / 2) {
				point.setY(point.getY() - 10);
			}
			else {
				point.setY(point.getY() + 35);
			}
			final Rectangle rect = fontRenderer.getBounds(labelPoint.getSecondObject(), (int) point.getX(),
					(int) point.getY(), fs);
			rect.x -= labelPadding;
			rect.y -= labelPadding;
			rect.width += labelPadding * 2;
			rect.height += labelPadding * 2;
			if (labelBackground != null) {
				ret.drawShapeFilled(rect, labelBackground);
			}
			if (labelBorder != null) {
				ret.drawShape(rect, labelBorder);
			}
			ret.drawText(labelPoint.getSecondObject(), point, fs);
			ret.drawPoint(p, RGBColour.RED, (int) ternaryData.value);
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:40,代码来源:TernaryPlot.java

示例14: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 *	{@inheritDoc}
 * 	@see org.openimaj.video.VideoDisplayListener#beforeUpdate(org.openimaj.image.Image)
 */
@Override
public void beforeUpdate( final MBFImage frame )
{
	if( frame == null ) return;

	// Process the frame.
	this.shotDetector.processFrame( frame );
	if( this.shotDetector.wasLastFrameBoundary() )
	{
		System.out.println( "Shot detected. Forcing redetect on face tracker.");
		this.tracker.reset();
	}

	// Track faces in the image
	this.tracker.track( frame );

	// Draw the tracked model to the image
	this.tracker.drawModel( frame, this.drawTriangles, this.drawConnections, this.drawPoints,
			this.drawSearchArea, this.drawBounds );

	// Whether to show FPS
	if( this.showFPS )
	{
		// Draw framerate on display image (average of 10 frames)
		if( this.fnum >= 9 )
		{
			this.t1 = System.currentTimeMillis();
			final double fps = 10 / ((this.t1 - this.t0) / 1000.0);
			this.t0 = this.t1;
			this.fnum = 0;
			this.fpsText = String.format( "%d frames/sec", (int)Math.round( fps ) );
		}
		else
		{
			this.fnum++;
		}

		frame.drawText( this.fpsText, 10, 20, HersheyFont.ROMAN_SIMPLEX, 20,
		        RGBColour.GREEN );
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:46,代码来源:VideoFaceTracker.java

示例15: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	if (this.tldMain.selector.drawRect(frame)) {
		return;
	}
	final long tic = System.currentTimeMillis();
	currentFrame++;
	FImage grey = null;
	if (!reuseFrameOnce) {
		grey = frame.flatten();
	}

	if (!skipProcessingOnce) {
		tldMain.tld.processImage(grey);
	} else {
		skipProcessingOnce = false;
	}

	if (tldMain.printResults != null) {
		if (tldMain.tld.currBB != null) {
			tldMain.resultsFile.printf("%d %.2f %.2f %.2f %.2f %f\n", currentFrame - 1, tldMain.tld.currBB.x,
					tldMain.tld.currBB.y, tldMain.tld.currBB.width, tldMain.tld.currBB.height, tldMain.tld.currConf);
		} else {
			tldMain.resultsFile.printf("%d NaN NaN NaN NaN NaN\n", currentFrame - 1);
		}
	}

	final float fps = 1 / ((System.currentTimeMillis() - tic) / 1000f);

	final boolean confident = (tldMain.tld.currConf >= tldMain.threshold) ? true : false;

	if (tldMain.showOutput || tldMain.saveDir != null) {
		String learningString = "";
		if (tldMain.tld.isLearning()) {
			learningString = "learning";
		}

		final String string = String.format("#%d,Posterior %.2f; fps: %.2f, #numwindows:%d, %s", currentFrame - 1,
				tldMain.tld.currConf, fps, tldMain.tld.detectorCascade.getNumWindows(), learningString);
		final Float[] yellow = RGBColour.YELLOW;
		final Float[] blue = RGBColour.BLUE;
		final Float[] red = RGBColour.RED;

		if (tldMain.tld.currBB != null) {
			final Float[] rectangleColor = confident ? blue : yellow;
			// cvRectangle(img, tld.currBB.tl(), tld.currBB.br(),
			// rectangleColor, 8, 8, 0);
			frame.drawShape(tldMain.tld.currBB, rectangleColor);
			if (tldMain.markerMode && this.tldMain.tld.medianFlowTracker.featuresTrackedToBfromA != null) {
				// Draw the tracked points
				final Feature[] from = this.tldMain.tld.medianFlowTracker.featuresTrackedToBfromA.features;
				final Feature[] to = this.tldMain.tld.medianFlowTracker.featuresTrackedToAviaB.features;
				for (int i = 0; i < from.length; i++) {
					frame.drawLine(from[i], to[i], 3, red);
				}
			}
		}

		drawPositivePatches();

		final HersheyFont font = HersheyFont.ROMAN_SIMPLEX;
		frame.drawText(string, 25, 25, font, 12);

	}

	if (reuseFrameOnce) {
		reuseFrameOnce = false;
	}

}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:71,代码来源:TLDVideoListener.java


注:本文中的org.openimaj.image.MBFImage.drawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。