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


Java MBFImage.createRenderer方法代码示例

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


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

示例1: MSEREllipseFinder

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Construct demo
 */
public MSEREllipseFinder() {
	final MBFImage image = new MBFImage(400, 400, ColourSpace.RGB);
	final MBFImageRenderer renderer = image.createRenderer();

	image.fill(RGBColour.WHITE);
	final List<Ellipse> ellipses = new ArrayList<Ellipse>();
	ellipses.add(new Ellipse(200, 100, 100, 80, Math.PI / 4));
	ellipses.add(new Ellipse(200, 300, 50, 30, -Math.PI / 4));
	ellipses.add(new Ellipse(100, 300, 30, 50, -Math.PI / 3));

	for (final Ellipse ellipse : ellipses) {
		renderer.drawShapeFilled(ellipse, RGBColour.BLACK);
	}

	final MSERFeatureGenerator mser = new MSERFeatureGenerator(MomentFeature.class);
	final List<Component> features = mser.generateMSERs(Transforms
			.calculateIntensityNTSC(image));
	for (final Component c : features) {
		final MomentFeature feature = c.getFeature(MomentFeature.class);
		renderer.drawShape(feature.getEllipse(2), RGBColour.RED);
		renderer.drawShape(feature.getEllipse(2)
				.calculateOrientedBoundingBox(), RGBColour.GREEN);
	}
	DisplayUtilities.display(image);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:MSEREllipseFinder.java

示例2: redrawCircles

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void redrawCircles(MBFImage output) {
	long now = System.currentTimeMillis();
	output.fill(RGBColour.WHITE);
	MBFImageRenderer rend = output.createRenderer(RenderHints.ANTI_ALIASED);
	for (String hash: this.hashCircles.keySet()) {
		Circle circle = this.hashCircles.get(hash);
		Float[] col = this.hashColours.get(hash);
		float level = 2;
		long lastSeen = this.hashAggregations.get(hash).lastSeen;
		if(lastSeen!=0){				
			long diff = Math.abs(lastSeen - now);
			if(diff < BLIP_TIME){
				level -= (1 - ( diff / (float)BLIP_TIME));
			}
		}
		Float[] offCircleColour = dark(col,level);
		
		drawHashCircle(rend , hash, circle, offCircleColour);
	}
	for (IndependentPair<Point2dImpl, MBFImage> pTextLayer : this.textLayers) {
		
		MBFImage textLayer = pTextLayer.getSecondObject();
		Point2d p = pTextLayer.firstObject();
		output.drawImage(textLayer , (int)p.getX(), (int)p.getY());
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:PrettyTagRenderer.java

示例3: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void beforeUpdate(MBFImage frame) {
	DisplayUtilities.displayName(frame, "video");
	if (renderer == null) {
		this.renderer = frame.createRenderer();

	}
	// this.renderer.drawShapeFilled(targetArea, RGBColour.RED);
	updatePolygon();
	final ProjectionProcessor<Float[], MBFImage> proc = new MBFProjectionProcessor();
	proc.setMatrix(captureToVideo);

	proc.accumulate(nextCaptureFrame);
	if (this.targetArea != null) {
		final Matrix transform = TransformUtilities.homographyMatrixNorm(pointList);
		proc.setMatrix(transform);
		proc.accumulate(frame.clone());
	}
	synchronized (this) {
		proc.performProjection(0, 0, frame);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:VideoWithinVideo.java

示例4: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	MathMLFontRenderer<Float[]> rend = new MathMLFontRenderer<Float[]>();
	
	String mathML = "x = 2\\mathrm{wang}wang" ;
	
	MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);
	img.fill(RGBColour.WHITE);
	MBFImageRenderer renderer = img.createRenderer();
	MathMLFontStyle<Float[]> style = new MathMLFontStyle<Float[]>(new MathMLFont(), RGBColour.WHITE);
	style.setColour(RGBColour.RED);
	style.setFontSize(30);
	rend.renderText(renderer, mathML, 0, 100, style);
	DisplayUtilities.display(img);
	
	MathMLFontRenderer<Float> rendf = new MathMLFontRenderer<Float>();
	
	FImage imgf = new FImage(300, 300);
	imgf.fill(0f);
	FImageRenderer rendererf = imgf.createRenderer();
	MathMLFontStyle<Float> stylef = new MathMLFontStyle<Float>(new MathMLFont(), 0.5f);
	stylef.setFontSize(30);
	rendf.renderText(rendererf, mathML, 0, 100, stylef);
	DisplayUtilities.display(imgf);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:28,代码来源:MathMLFontRenderer.java

示例5: drawDebug

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void drawDebug(MBFImage image, FImage greyFrame) {
	this.polygonListener.drawPoints(image);

	final MBFImageRenderer renderer = image.createRenderer();

	if (this.initialShape != null) {
		renderer.drawPolygon(initialShape, RGBColour.RED);
	}
	if (this.initialFeatures != null) {
		image.internalAssign(MatchingUtilities.drawMatches(image, this.findAllMatchedPairs(), RGBColour.WHITE));
		final Matrix esitmatedModel = this.estimateModel();
		if (esitmatedModel != null)
		{
			final Polygon newPolygon = initialShape.transform(esitmatedModel);
			renderer.drawPolygon(newPolygon, RGBColour.GREEN);
			if (fl.countRemainingFeatures() < nOriginalFoundFeatures * 0.5) {
				reinitTracker();
				initTracking(greyFrame, newPolygon);
			}
		}
		estimateMovement();
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:VideoKLTSIFT.java

示例6: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) {
	final MBFImage image = new MBFImage(400, 400, ColourSpace.RGB);
	final MBFImageRenderer renderer = image.createRenderer();

	image.fill(RGBColour.BLACK);
	final List<Ellipse> ellipses = new ArrayList<Ellipse>();
	ellipses.add(new Ellipse(200, 100, 10, 8, Math.PI / 4));
	ellipses.add(new Ellipse(200, 300, 5, 3, -Math.PI / 4));
	ellipses.add(new Ellipse(100, 300, 3, 5, -Math.PI / 3));

	for (final Ellipse ellipse : ellipses) {
		renderer.drawShapeFilled(ellipse, RGBColour.WHITE);
	}

	final LOCKY locky = new LOCKY();
	locky.findInterestPoints(image.flatten());
	final List<EllipticInterestPointData> pts = locky.getInterestPoints();
	for (final EllipticInterestPointData pt : pts) {
		image.drawShape(pt.getEllipse(), RGBColour.RED);
	}

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

示例7: KinectDemo

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Default constructor
 * 
 * @param id
 *            of kinect controller
 * @throws KinectException
 */
public KinectDemo(int id) throws KinectException {
	controller = new KinectController(id, irmode, rdepth);
	currentFrame = new MBFImage(640 * 2, 480, ColourSpace.RGB);
	renderer = currentFrame.createRenderer(RenderHints.ANTI_ALIASED);

	videoFrame = VideoDisplay.createVideoDisplay(this);
	((JFrame) SwingUtilities.getRoot(videoFrame.getScreen())).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	SwingUtilities.getRoot(videoFrame.getScreen()).addKeyListener(this);

	v3d = new MBFImage(640, 480);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:KinectDemo.java

示例8: addMustaches

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Detect faces in the image and render mustaches.
 * 
 * @param image
 * @return image with rendered mustaches
 */
public MBFImage addMustaches(MBFImage image) {
	MBFImage cimg;

	if (image.getWidth() > image.getHeight() && image.getWidth() > 640) {
		cimg = image.process(new ResizeProcessor(640, 480));
	} else if (image.getHeight() > image.getWidth() && image.getHeight() > 640) {
		cimg = image.process(new ResizeProcessor(480, 640));
	} else {
		cimg = image.clone();
	}

	final FImage img = Transforms.calculateIntensityNTSC(cimg);

	final List<KEDetectedFace> faces = detector.detectFaces(img);
	final MBFImageRenderer renderer = cimg.createRenderer();

	for (final KEDetectedFace face : faces) {
		final Matrix tf = AffineAligner.estimateAffineTransform(face);
		final Shape bounds = face.getBounds();

		final MBFImage m = mustache.transform(tf.times(TransformUtilities.scaleMatrix(1f / 4f, 1f / 4f)));

		renderer.drawImage(m, (int) bounds.minX(), (int) bounds.minY());
	}

	return cimg;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:Mustache.java

示例9: afterUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public synchronized void afterUpdate(final VideoDisplay<MBFImage> display) {
	if (this.matcher != null && !this.videoFrame.isPaused()) {
		final MBFImage capImg = this.currentFrame;
		final LocalFeatureList<Keypoint> kpl = this.engine.findFeatures(Transforms.calculateIntensityNTSC(capImg));

		final MBFImageRenderer renderer = capImg.createRenderer();
		renderer.drawPoints(kpl, RGBColour.MAGENTA, 3);

		MBFImage matches;
		if (this.matcher.findMatches(kpl)
				&& ((MatrixTransformProvider) this.matcher.getModel()).getTransform().cond() < 1e6)
		{
			try {
				final Matrix boundsToPoly = ((MatrixTransformProvider) this.matcher.getModel()).getTransform()
						.inverse();

				if (modelImage.getBounds().transform(boundsToPoly).isConvex()) {
					this.renderMode.render(renderer, boundsToPoly, this.modelImage.getBounds());
				}
			} catch (final RuntimeException e) {
			}

			matches = MatchingUtilities
					.drawMatches(this.modelImage, capImg, this.matcher.getMatches(), RGBColour.RED);
		} else {
			matches = MatchingUtilities
					.drawMatches(this.modelImage, capImg, this.matcher.getMatches(), RGBColour.RED);
		}

		this.matchPanel.setPreferredSize(this.matchPanel.getSize());
		this.matchFrame.setImage(ImageUtilities.createBufferedImageForDisplay(matches));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:VideoSIFT.java

示例10: drawPoints

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Draw the polygon onto an image.
 * @param image the image to draw on.
 */
public void drawPoints(MBFImage image) {
	Polygon p = getPolygon();
	MBFImageRenderer renderer = image.createRenderer();

	if(p.getVertices().size() > 2) {
		renderer.drawPolygon(p, 3,RGBColour.RED);
	}

	for(Point2d point : p.getVertices()) {
		renderer.drawPoint(point, RGBColour.BLUE, 5);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:17,代码来源:PolygonDrawingListener.java

示例11: afterUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public synchronized void afterUpdate(final VideoDisplay<MBFImage> display) {
	if (this.matcher != null && !this.videoFrame.isPaused()) {
		final MBFImage capImg = this.videoFrame.getVideo().getCurrentFrame();
		final LocalFeatureList<Keypoint> kpl = this.engine.findFeatures(capImg);

		final MBFImageRenderer renderer = capImg.createRenderer();
		renderer.drawPoints(kpl, RGBColour.MAGENTA, 3);

		MBFImage matches;
		if (this.matcher.findMatches(kpl)) {
			try {
				// Shape sh =
				// modelImage.getBounds().transform(((MatrixTransformProvider)
				// matcher.getModel()).getTransform().inverse());
				// renderer.drawShape(sh, 3, RGBColour.BLUE);
				final Matrix boundsToPoly = ((MatrixTransformProvider) this.matcher.getModel()).getTransform()
						.inverse();
				this.renderMode.render(renderer, boundsToPoly, this.modelImage.getBounds());
			} catch (final RuntimeException e) {
			}

			matches = MatchingUtilities
					.drawMatches(this.modelImage, capImg, this.matcher.getMatches(), RGBColour.RED);
		} else {
			matches = MatchingUtilities
					.drawMatches(this.modelImage, capImg, this.matcher.getMatches(), RGBColour.RED);
		}

		this.matchPanel.setPreferredSize(this.matchPanel.getSize());
		this.matchFrame.setImage(ImageUtilities.createBufferedImageForDisplay(matches));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:34,代码来源:VideoColourSIFT.java

示例12: doTutorial

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
	MBFImageRenderer image = toDraw.createRenderer();
	
	List<DetectedFace> faces = this.detector.detectFaces(toDraw.flatten());
	for (DetectedFace detectedFace : faces) {
		float x = detectedFace.getBounds().x;
		float y = detectedFace.getBounds().y;
		float w = detectedFace.getBounds().width;
		float h = detectedFace.getBounds().height;
		renderBubbles(image,x-w/2,y,w,h);
	}
	
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:15,代码来源:ShapeRenderingTutorial.java

示例13: beforeUpdate

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public synchronized void beforeUpdate(MBFImage frame) {
	List<? extends DetectedFace> faces = null;
	if (findKeypoints) {
		faces = engine
				.detectFaces(Transforms.calculateIntensityNTSC(frame));
	} else {
		faces = innerEngine.detectFaces(Transforms
				.calculateIntensityNTSC(frame));
	}

	if (faces.size() > 0) {
		Rectangle r = faces.get(0).getBounds();
		((HaarCascadeDetector) innerEngine)
				.setMinSize((int) (r.width * 0.9));
	} else {
		((HaarCascadeDetector) innerEngine).setMinSize(1);
	}

	for (DetectedFace face : faces) {
		final Shape bounds = face.getBounds();

		MBFImageRenderer renderer = frame.createRenderer();
		renderer.drawPolygon(bounds.asPolygon(), RGBColour.RED);

		if (findKeypoints) {
			for (FacialKeypoint kp : ((KEDetectedFace) face).getKeypoints()) {
				Point2d pt = kp.position.clone();
				pt.translate((float) bounds.minX(), (float) bounds.minY());

				renderer.drawPoint(pt, RGBColour.GREEN, 3);
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:VideoFace.java

示例14: getComponent

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	image = new MBFImage(width, height - 50, ColourSpace.RGB);
	renderer = image.createRenderer(RenderHints.ANTI_ALIASED);
	resetImage();

	ic = new DisplayUtilities.ImageComponent(true, false);
	ic.setShowPixelColours(false);
	ic.setShowXYPosition(false);
	ic.setAllowPanning(false);
	ic.setAllowZoom(false);
	ic.addMouseListener(this);
	ic.addMouseMotionListener(this);
	base.add(ic);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	clearBtn = new JButton("Clear");
	clearBtn.setActionCommand("button.clear");
	clearBtn.addActionListener(this);
	controls.add(clearBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	controls.add(new JLabel("K:"));

	kSpn = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
	controls.add(kSpn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run KMeans");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	updateImage();

	return base;
}
 
开发者ID:jonhare,项目名称:COMP6208,代码行数:58,代码来源:KMeansDemo.java

示例15: testRandomSquareTransform

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
 * Transform the square by a random transform and see if you can find the
 * square again by using a RANSAC model and a homography model. Apply some
 * error the points once transformed to make things a bit more interesting
 */
@Test
public void testRandomSquareTransform()
{

	Matrix trans = Matrix.identity(3, 3);
	trans = TransformUtilities.centeredRotationMatrix(Math.PI / 3.0, 2 * (squareX + squareWidth / 2),
			2 * (squareY + squareHeight / 2)).times(trans);
	trans = TransformUtilities.translateMatrix(200, 200).times(trans);
	// trans = TransformUtilities.rotationMatrix(Math.PI/3.0);

	final ArrayList<Point2d> transformedPoints = new ArrayList<Point2d>();
	final List<IndependentPair<Point2d, Point2d>> pairs = new ArrayList<IndependentPair<Point2d, Point2d>>();
	final Random r = new Random();
	final int error = 3;
	final float stoppingCondition = 0.8f;
	for (final Point2d randomPoint : randomPoints) {
		final Point2dImpl pointTrans = ((Point2dImpl) randomPoint).transform(trans);

		pointTrans.setX(pointTrans.getX() + (r.nextFloat()) * error * (r.nextBoolean() ? -1 : 1));
		pointTrans.setY(pointTrans.getY() + (r.nextFloat()) * error * (r.nextBoolean() ? -1 : 1));

		transformedPoints.add(pointTrans);
		pairs.add(new IndependentPair<Point2d, Point2d>(randomPoint, pointTrans));
	}

	int i = 0;
	while (i++ < 10) {
		pallet = new MBFImage(new FImage[] { new FImage(500, 500), new FImage(500, 500), new FImage(500, 500) });
		final MBFImageRenderer renderer = pallet.createRenderer();

		final HomographyModel model = new HomographyModel();
		final SingleImageTransferResidual2d<HomographyModel> errorModel = new SingleImageTransferResidual2d<HomographyModel>();
		final float errorThresh = ((float) Math.sqrt(2 * error * error) * 2) + 1;

		model.estimate(pairs);
		renderer.drawPolygon(this.square.asPolygon().transform(model.getTransform()), 1, RGBColour.ORANGE);
		final RANSAC<Point2d, Point2d, HomographyModel> fitterNormal = new RANSAC<Point2d, Point2d, HomographyModel>(
				model, errorModel, errorThresh,
				1500, new RANSAC.PercentageInliersStoppingCondition(stoppingCondition), false);
		Matrix fitterNormalTransform = null;
		renderer.drawPolygon(this.square.asPolygon(), 1, RGBColour.RED);
		renderer.drawPolygon(this.square.asPolygon().transform(trans), 1, RGBColour.RED);
		renderer.drawPoints(randomPoints, RGBColour.GREEN, 3);
		renderer.drawPoints(transformedPoints, RGBColour.GREEN, 3);
		if (fitterNormal.fitData(pairs))
		{
			fitterNormalTransform = model.getTransform().copy();
			renderer.drawPolygon(this.square.asPolygon().transform(fitterNormalTransform), 1, RGBColour.YELLOW);

			final List<? extends IndependentPair<Point2d, Point2d>> inlierPairs = fitterNormal.getInliers();
			System.out.println("Number of best inliers for recalculation: " + inlierPairs.size());
			model.estimate(inlierPairs);
			final Matrix fitterRefitTransform = model.getTransform().copy();
			renderer.drawPolygon(this.square.asPolygon().transform(fitterRefitTransform), 1, RGBColour.CYAN);
			assertTrue(inlierPairs.size() >= nPoints * stoppingCondition);

		}
		else {
			fitterNormalTransform = model.getTransform().copy();
			final List<? extends IndependentPair<Point2d, Point2d>> mData = fitterNormal.getModelConstructionData();
			for (final IndependentPair<Point2d, Point2d> independentPair : mData) {
				// Point2d a = independentPair.firstObject();
				final Point2d b = independentPair.secondObject();
				renderer.drawPoint(b, RGBColour.PINK, 4);
			}
			renderer.drawPolygon(this.square.asPolygon().transform(fitterNormalTransform), 1, RGBColour.GREEN);
		}
	}

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


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