本文整理汇总了Java中org.openimaj.image.MBFImage.drawShape方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.drawShape方法的具体用法?Java MBFImage.drawShape怎么用?Java MBFImage.drawShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.image.MBFImage
的用法示例。
在下文中一共展示了MBFImage.drawShape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTutorial
import org.openimaj.image.MBFImage; //导入方法依赖的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);
}
}
示例2: drawPoints
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private static void drawPoints(Stream<IndependentPair<double[], PerceptronClass>> dataStream, Line2d line) {
final MBFImage img = new MBFImage(300, 300, ColourSpace.RGB);
img.drawLine(line, 3, RGBColour.BLUE);
for (final IndependentPair<double[], PerceptronClass> pointClass : dataStream) {
final double[] pc = pointClass.firstObject();
final Point2dImpl point = new Point2dImpl((float) pc[0], (float) pc[1]);
final PerceptronClass cls = pointClass.getSecondObject();
switch (cls) {
case TRUE:
img.drawShapeFilled(new Circle(point, 5), RGBColour.GREEN);
break;
case FALSE:
img.drawShape(new Circle(point, 5), 3, RGBColour.RED);
break;
case NONE:
throw new RuntimeException("NOPE");
}
}
DisplayUtilities.displayName(img, "random");
}
示例3: drawBoxes
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Draws the boxes to show movements.
* @param img The image to draw to
*/
protected void drawBoxes( final MBFImage img, final double[][] sim )
{
final int gw = img.getWidth() / this.nGridElements;
final int gh = img.getHeight() / this.nGridElements;
for( int y = 0; y < this.nGridElements; y++ )
{
for( int x = 0; x < this.nGridElements; x++ )
{
Float[] c = new Float[]{0f,0f,0f,0f};
if( sim[y][x] == this.boostFactor )
c = RGBColour.RED;
else
if( sim[y][x] == this.limitingFactor )
c = RGBColour.BLUE;
else c = RGBColour.BLACK;
img.drawShape( new Rectangle(x*gw,y*gh,gw,gh), c );
}
}
}
示例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;
}
示例5: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Testing
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
FImage image = ImageUtilities.readF(new File("/Users/jsh2/Desktop/image.png"));
FImage template = image.extractROI(100, 100, 100, 100);
image.fill(0f);
image.drawImage(template, 100, 100);
TemplateMatcher matcher = new TemplateMatcher(template, Mode.CORRELATION);
matcher.setSearchBounds(new Rectangle(100,100,200,200));
image.analyseWith(matcher);
DisplayUtilities.display(matcher.responseMap.normalise());
MBFImage cimg = image.toRGB();
for (FValuePixel p : matcher.getBestResponses(10)) {
System.out.println(p);
cimg.drawPoint(p, RGBColour.RED, 1);
}
cimg.drawShape(matcher.getSearchBounds(), RGBColour.BLUE);
cimg.drawShape(new Rectangle(100,100,100,100), RGBColour.GREEN);
DisplayUtilities.display(cimg);
}
示例6: displayEllipsesFull
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void displayEllipsesFull(Ellipse ellipse1, Ellipse ellipse2) {
final MBFImage debugDisplay = new MBFImage(this.imageWidth, this.imageHeight,
ColourSpace.RGB);
debugDisplay.drawShape(ellipse1, RGBColour.RED);
debugDisplay.drawShape(ellipse2, RGBColour.BLUE);
debugDisplay
.drawShape(
ellipse2.calculateRegularBoundingBox().union(
ellipse1.calculateRegularBoundingBox()),
RGBColour.BLUE);
DisplayUtilities.displayName(debugDisplay, "debug display full");
}
示例7: processFaces
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
private void processFaces(MBFImage frame, MBFImage outframe) {
try {
final List<DetectedFace> faces = faceDetector.detectFaces(frame.flatten());
if (faces == null || faces.size() == 0) {
// move back towards center
final int tiltPW = (TILT_CENTRE_PW - tilt.getPW()) / 5;
tilt.changePWRelative(tiltPW);
final int panPW = (PAN_CENTRE_PW - pan.getPW()) / 5;
pan.changePWRelative(panPW);
} else {
outframe.drawShape(faces.get(0).getBounds(), RGBColour.RED);
// move towards face
final Point2d pt = faces.get(0).getBounds().calculateCentroid();
final Point2d delta = pt.minus(frameCentre);
final double damp = 0.3;
pan.changePWRelative(-(int) (damp * delta.getX()));
tilt.changePWRelative((int) (damp * delta.getY()));
}
} catch (final Exception e) {
e.printStackTrace();
}
}
示例8: drawDetectedFace
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void drawDetectedFace(MBFImage image, int thickness, KEDetectedFace f) {
Rectangle bounds = f.getBounds();
image.drawShape(bounds,thickness, boundingBoxColour);
FacialKeypoint[] kp = f.getKeypoints();
for (FacialKeypoint facialKeypoint : kp) {
Point2dImpl position = facialKeypoint.position.clone();
position.translate(bounds.x, bounds.y);
image.drawPoint(position,pointColour,thickness);
}
}
示例9: doTutorial
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@Override
public void doTutorial(MBFImage toDraw) {
List<DetectedFace> faces = this.detector.detectFaces(toDraw.flatten());
for (DetectedFace detectedFace : faces) {
toDraw.drawShape(detectedFace.getBounds(), RGBColour.RED);
}
}
示例10: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
final MBFImage sourceC = ImageUtilities.readMBF(monaLisaSource);
final MBFImage targetC = ImageUtilities.readMBF(monaLisaTarget);
final FImage source = sourceC.flatten();
final FImage target = targetC.flatten();
final DoGSIFTEngine eng = new DoGSIFTEngine();
final LocalFeatureList<Keypoint> sourceFeats = eng.findFeatures(source);
final LocalFeatureList<Keypoint> targetFeats = eng.findFeatures(target);
final HomographyModel model = new HomographyModel();
final SingleImageTransferResidual2d<HomographyModel> errorModel = new SingleImageTransferResidual2d<HomographyModel>();
final RANSAC<Point2d, Point2d, HomographyModel> ransac = new RANSAC<Point2d, Point2d, HomographyModel>(model,
errorModel, 5f, 1500, new RANSAC.BestFitStoppingCondition(), true);
final ConsistentLocalFeatureMatcher2d<Keypoint> matcher = new ConsistentLocalFeatureMatcher2d<Keypoint>(
new FastBasicKeypointMatcher<Keypoint>(8));
matcher.setFittingModel(ransac);
matcher.setModelFeatures(sourceFeats);
matcher.findMatches(targetFeats);
final Matrix boundsToPoly = model.getTransform().inverse();
final Shape s = source.getBounds().transform(boundsToPoly);
targetC.drawShape(s, 10, RGBColour.BLUE);
final MBFImage matches = MatchingUtilities.drawMatches(sourceC, targetC, matcher.getMatches(), RGBColour.RED);
matches.processInplace(new ResizeProcessor(640, 480));
DisplayUtilities.display(matches);
ImageUtilities.write(matches, new File("/Users/ss/Desktop/keypoint-match-example.png"));
}
示例11: displayEllipsesZoomed
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static void displayEllipsesZoomed(Ellipse ellipse1, Ellipse ellipse2) {
final int zoomHeight = 400;
final int zoomWidth = 400;
final int midzoomx = zoomWidth / 2;
final int midzoomy = zoomHeight / 2;
final double e1Radius = getRadius(ellipse1, 1);
final double scale = (zoomWidth * 0.50) / e1Radius;
final Matrix scaleMatrix = TransformUtilities.scaleMatrixAboutPoint(
1 / scale, 1 / scale, 0, 0);
final MBFImage zoomed = new MBFImage(zoomWidth, zoomHeight, ColourSpace.RGB);
Matrix translateE1 = Matrix.identity(3, 3);
translateE1 = translateE1.times(TransformUtilities
.translateToPointMatrix(new Point2dImpl(0, 0), new Point2dImpl(
midzoomx, midzoomy)));
translateE1 = translateE1.times(scaleMatrix);
translateE1 = translateE1.times(TransformUtilities
.translateToPointMatrix(ellipse1.calculateCentroid(),
new Point2dImpl(0, 0)));
final Ellipse expandedTranslated1 = ellipse1.transformAffine(translateE1);
final Ellipse expandedTranslated2 = ellipse2.transformAffine(translateE1);
zoomed.drawShape(expandedTranslated1, RGBColour.RED);
zoomed.drawShape(expandedTranslated2, RGBColour.BLUE);
DisplayUtilities.displayName(zoomed, "zoomed image");
System.out.println();
}
示例12: drawRect
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public boolean drawRect(MBFImage frame) {
if(this.rectangleSelectMode){
frame.drawShape(this.currentRect, RGBColour.RED);
return true;
}
else{
return false;
}
}
示例13: main
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* Main method
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final MBFImage query = ImageUtilities.readMBF(new URL("http://static.openimaj.org/media/tutorial/query.jpg"));
final MBFImage target = ImageUtilities.readMBF(new URL("http://static.openimaj.org/media/tutorial/target.jpg"));
final DoGSIFTEngine engine = new DoGSIFTEngine();
final LocalFeatureList<Keypoint> queryKeypoints = engine.findFeatures(query.flatten());
final LocalFeatureList<Keypoint> targetKeypoints = engine.findFeatures(target.flatten());
LocalFeatureMatcher<Keypoint> matcher = new BasicMatcher<Keypoint>(80);
matcher.setModelFeatures(queryKeypoints);
matcher.findMatches(targetKeypoints);
final MBFImage basicMatches = MatchingUtilities.drawMatches(query, target, matcher.getMatches(), RGBColour.RED);
DisplayUtilities.display(basicMatches);
// final RobustAffineTransformEstimator modelFitter = new
// RobustAffineTransformEstimator(5.0, 1500,
// new RANSAC.PercentageInliersStoppingCondition(0.5));
final RobustHomographyEstimator modelFitter = new
RobustHomographyEstimator(5.0, 1500,
new RANSAC.PercentageInliersStoppingCondition(0.5),
HomographyRefinement.NONE);
matcher = new ConsistentLocalFeatureMatcher2d<Keypoint>(new FastBasicKeypointMatcher<Keypoint>(8), modelFitter);
matcher.setModelFeatures(queryKeypoints);
matcher.findMatches(targetKeypoints);
final MBFImage consistentMatches = MatchingUtilities.drawMatches(query, target,
matcher.getMatches(), RGBColour.RED);
DisplayUtilities.display(consistentMatches);
target.drawShape(query.getBounds().transform(modelFitter.getModel().getTransform().inverse()), 3, RGBColour.BLUE);
DisplayUtilities.display(target);
}
示例14: 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);
}
}
}
示例15: drawTriangles
import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
/**
* @return draw the triangles generated from the data
*/
public MBFImage drawTriangles() {
final MBFImage img = new MBFImage((int) width, (int) height, ColourSpace.RGB);
for (final Triangle tri : this.dataTriangles.triToData.keySet()) {
img.drawShape(tri.transform(TransformUtilities.scaleMatrix(width, height)), RGBColour.RED);
}
return img;
}