本文整理汇总了Java中org.openimaj.math.geometry.point.PointListConnections类的典型用法代码示例。如果您正苦于以下问题:Java PointListConnections类的具体用法?Java PointListConnections怎么用?Java PointListConnections使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PointListConnections类属于org.openimaj.math.geometry.point包,在下文中一共展示了PointListConnections类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
final List<PointList> pointData = loadData();
final PointListConnections plc = loadConnections();
final List<FImage> images = loadImages();
System.out.println(pointData.size());
System.out.println(images.size());
final Float[][] cols = new Float[pointData.get(0).size()][];
for (int i = 0; i < cols.length; i++)
cols[i] = RGBColour.randomColour();
for (int j = 0; j < pointData.size(); j++) {
final PointList pl = pointData.get(j);
final MBFImage img = images.get(j).toRGB();
final List<Line2d> lines = plc.getLines(pl);
img.drawLines(lines, 1, RGBColour.RED);
for (int i = 0; i < pl.size(); i++) {
final Point2d pt = pl.get(i);
img.drawPoint(pt, cols[i], 3);
}
DisplayUtilities.display(img);
}
}
示例2: createShapes
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
private ImageComponent createShapes(int width, int height, List<PointList> points, PointListConnections connections,
Float[][] colours)
{
final MBFImage image = new MBFImage(width, height - 20, ColourSpace.RGB).fill(RGBColour.BLACK);
int i = 0;
for (final PointList p : points) {
final PointList pts = p.clone();
pts.scale(1.5f);
final Float[] c = colours[i++];
image.drawPoints(pts, c, 5);
for (final Line2d line : pts.getLines(connections)) {
image.drawLine(line, 3, c);
}
}
final ImageComponent ic = new ImageComponent(true, true);
ic.setAllowPanning(false);
ic.setAllowZoom(false);
ic.setShowPixelColours(false);
ic.setShowXYPosition(false);
ic.setImage(ImageUtilities.createBufferedImageForDisplay(image));
return ic;
}
示例3: main
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
final ShapeModelDataset<FImage> dataset = IMMFaceDatabase.load(ImageUtilities.FIMAGE_READER);
final PointListConnections connections = dataset.getConnections();
final List<PointList> pointData = dataset.getPointLists();
final int width = 200, height = 200;
final PointDistributionModel pdm = new PointDistributionModel(pointData);
pdm.setNumComponents(15);
final FImage images = new FImage(4 * width, 4 * height);
for (int j = 0; j < 4; j++) {
for (int i = 0; i < 4; i++) {
final ValueAnimator<double[]> a = DoubleArrayValueAnimator.makeRandomLinear(0,
pdm.getStandardDeviations(3));
final FImage image = new FImage(width, height);
image.fill(1);
final PointList newShape = pdm.generateNewShape(a.nextValue());
final PointList tfShape = newShape.transform(TransformUtilities.translateMatrix(100, 100).times(
TransformUtilities.scaleMatrix(50, 50)));
final List<Line2d> lines = connections.getLines(tfShape);
image.drawLines(lines, 1, 0f);
images.drawImage(image, i * width, j * height);
}
}
DisplayUtilities.display(images);
ImageUtilities.write(images, new File("/Users/jsh2/Desktop/faces.png"));
}
示例4: main
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// final ShapeModelDataset<FImage> dataset =
// IMMFaceDatabase.load(ImageUtilities.FIMAGE_READER);
final ShapeModelDataset<FImage> dataset = AMToolsSampleDataset.load(ImageUtilities.FIMAGE_READER);
final PointListConnections connections = dataset.getConnections();
final List<PointList> pointData = dataset.getPointLists();
final PointDistributionModel pdm = new PointDistributionModel(pointData);
pdm.setNumComponents(4);
VideoDisplay.createVideoDisplay(new AnimatedVideo<FImage>(new FImage(600, 600)) {
ValueAnimator<double[]> a = DoubleArrayValueAnimator.makeRandomLinear(60, pdm.getStandardDeviations(3));
@Override
protected void updateNextFrame(FImage frame) {
frame.fill(0f);
final PointList newShape = pdm.generateNewShape(a.nextValue());
final PointList tfShape = newShape.transform(TransformUtilities.translateMatrix(300, 300).times(
TransformUtilities.scaleMatrix(150, 150)));
final List<Line2d> lines = connections.getLines(tfShape);
frame.drawLines(lines, 1, 1f);
for (final Point2d pt : tfShape) {
final Line2d normal = connections.calculateNormalLine(pt, tfShape, 10f);
if (normal != null) {
frame.drawLine(normal, 1, 0.5f);
}
}
}
});
}
示例5: main
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
public static void main(String[] args) {
final List<IndependentPair<PointList, FImage>> data = generateData(10);
final PointListConnections connections = new PointListConnections();
connections.addConnection(0, 1);
connections.addConnection(1, 2);
connections.addConnection(2, 0);
final float scale = 0.4f;
final FNormalLandmarkModel.Factory factory = new FNormalLandmarkModel.Factory(connections,
FLineSampler.INTERPOLATED_DERIVATIVE, 5, 13, scale);
final MultiResolutionActiveShapeModel<FImage> asm = MultiResolutionActiveShapeModel.trainModel(1,
new NumberComponentSelector(10), data, new PointDistributionModel.BoxConstraint(3), factory);
for (final IndependentPair<PointList, FImage> inst : generateData(10)) {
final MBFImage rgb = inst.secondObject().toRGB();
// Matrix pose = TransformUtilities.translateMatrix(50,
// 50).times(TransformUtilities.scaleMatrix(50, 50));
// PointList shape = asm.getPDM().getMean().transform(pose);
// Matrix pose = Matrix.identity(3, 3);
final Matrix pose = TransformUtilities.scaleMatrixAboutPoint(0.8, 0.8, 50, 50);
final PointList shape = inst.firstObject().transform(pose);
rgb.drawLines(connections.getLines(shape), 1, RGBColour.RED);
final IterationResult res = asm.fit(inst.secondObject(), shape);
rgb.drawLines(connections.getLines(res.shape), 1, RGBColour.GREEN);
DisplayUtilities.display(rgb);
}
}
示例6: readAMPTSConnections
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
private PointListConnections readAMPTSConnections(File connFile) throws IOException {
final BufferedReader br = new BufferedReader(new FileReader(connFile));
final PointListConnections plc = new PointListConnections();
String line;
while ((line = br.readLine()) != null) {
if (!line.trim().startsWith("indices"))
continue;
final String[] data = line.trim().replace("indices(", "").replace(")", "").split(",");
final boolean isOpen = (br.readLine().contains("open_boundary"));
int prev = Integer.parseInt(data[0]);
for (int i = 1; i < data.length; i++) {
final int next = Integer.parseInt(data[i]);
plc.addConnection(prev, next);
prev = next;
}
if (!isOpen) {
plc.addConnection(Integer.parseInt(data[data.length - 1]), Integer.parseInt(data[0]));
}
}
br.close();
return plc;
}
示例7: loadConnections
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
static PointListConnections loadConnections() {
final PointListConnections plc = new PointListConnections();
plc.addConnection(0, 1);
plc.addConnection(1, 2);
plc.addConnection(1, 4);
plc.addConnection(1, 9);
plc.addConnection(4, 3);
plc.addConnection(9, 10);
plc.addConnection(0, 5);
plc.addConnection(0, 8);
plc.addConnection(5, 6);
plc.addConnection(8, 7);
return plc;
}
示例8: FileBackedDataset
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
public FileBackedDataset(String path, ObjectReader<IndependentPair<PointList, IMAGE>, FileObject> reader,
PointListConnections conns)
throws IOException
{
super(path, reader);
this.connections = conns;
}
示例9: readConnections
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
void readConnections() throws IOException
{
connections = new PointListConnections();
final FileObject firstASF = this.getFileObject(0);
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(firstASF.getContent().getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (!line.startsWith("#")) {
final String[] parts = line.split("\\s+");
if (parts.length < 7)
continue;
final int from = Integer.parseInt(parts[4].trim());
final int to = Integer.parseInt(parts[6].trim());
connections.addConnection(from, to);
}
}
} finally {
if (br != null) {
try {
br.close();
} catch (final IOException e) {
// ignore
}
;
}
}
}
示例10: getComponent
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
@Override
public Component getComponent(int width, int height) throws IOException {
// the main panel
final JPanel base = new JPanel();
base.setPreferredSize(new Dimension(width, height));
base.setLayout(new GridBagLayout());
final JTabbedPane tabs = new JTabbedPane();
tabs.setPreferredSize(new Dimension(width, height));
final ShapeModelDataset<MBFImage> dataset = AMToolsSampleDataset.load(ImageUtilities.MBFIMAGE_READER);
final Float[][] colours = RGBColour.randomColours(dataset.size()).toArray(new Float[dataset.size()][]);
final List<PointList> points = dataset.getPointLists();
final PointListConnections connections = dataset.getConnections();
final ImageComponent unaligned = createShapes(width, height, points, connections, colours);
final PointList mean = GeneralisedProcrustesAnalysis.alignPoints(points, 5, 10);
for (final PointList pl : points) {
pl.translate(width / 3, height / 3);
pl.scaleCentroid(100);
}
final ImageComponent aligned = createShapes(width, height, points, connections, colours);
final List<PointList> meanList = new ArrayList<PointList>(1);
mean.translate(width / 3, height / 3);
mean.scaleCentroid(100);
meanList.add(mean);
final ImageComponent meanComp = createShapes(width, height, meanList, connections,
new Float[][] { RGBColour.WHITE });
tabs.addTab("Unaligned", unaligned);
tabs.addTab("Aligned", aligned);
tabs.addTab("Mean", meanComp);
base.add(tabs);
return base;
}
示例11: main
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final ShapeModelDataset<FImage> dataset = ShapeModelDatasets.loadASFDataset("/Users/jsh2/Downloads/imm_face_db",
ImageUtilities.FIMAGE_READER);
final PointListConnections conns = dataset.getConnections();
final float scale = 0.02f;
final FNormalLandmarkModel.Factory factory = new FNormalLandmarkModel.Factory(conns,
FLineSampler.INTERPOLATED_DERIVATIVE, 5, 9, scale);
final MultiResolutionActiveShapeModel<FImage> asm = MultiResolutionActiveShapeModel.trainModel(3,
new NumberComponentSelector(19), dataset, new PointDistributionModel.BoxConstraint(3), factory);
final Matrix pose = TransformUtilities.translateMatrix(300, 300).times(TransformUtilities.scaleMatrix(70, 70));
PointList shape = asm.getPDM().getMean().transform(pose);
// PointList shape = ASFDataset.readASF(new File(dir,
// "01-1m.asf")).firstObject();
final FImage img = dataset.get(0).secondObject();
// PointList shape = ASFDataset.readASF(new File(dir,
// "16-6m.asf")).firstObject();
// FImage img = ASFDataset.readASF(new File(dir,
// "16-6m.asf")).secondObject();
final MBFImage image = img.toRGB();
image.drawLines(conns.getLines(shape), 1, RGBColour.RED);
final long t1 = System.currentTimeMillis();
final IterationResult newData = asm.fit(img, shape);
final long t2 = System.currentTimeMillis();
shape = newData.shape;
System.out.println(newData.fit);
System.out.println(t2 - t1);
image.drawLines(conns.getLines(shape), 1, RGBColour.GREEN);
final float shapeScale = shape.computeIntrinsicScale();
for (final Point2d pt : shape) {
final Line2d normal = conns.calculateNormalLine(pt, shape, scale * shapeScale);
if (normal != null)
image.drawLine(normal, 1, RGBColour.BLUE);
}
DisplayUtilities.display(image);
}
示例12: getConnections
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
@Override
public PointListConnections getConnections() {
return connections;
}
示例13: main
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final ShapeModelDataset<FImage> dataset = ShapeModelDatasets.loadASFDataset("/Users/jsh2/Downloads/imm_face_db",
ImageUtilities.FIMAGE_READER);
final PointListConnections conns = dataset.getConnections();
final float scale = 0.02f;
final FNormalLandmarkModel.Factory factory = new FNormalLandmarkModel.Factory(conns, FLineSampler.INTERPOLATED,
5, 9, scale);
// BlockLandmarkModel.Factory factory = new
// BlockLandmarkModel.Factory();
final ActiveShapeModel<FImage> asm = ActiveShapeModel.trainModel(new PercentageEnergyComponentSelector(0.95),
dataset,
new PointDistributionModel.BoxConstraint(3), factory);
final IndependentPair<PointList, FImage> initial = dataset.get(0);
// final IndependentPair<PointList, FImage> initial =
// ASFDataset.readASF(new File(dir, "01-1m.asf"));
// final int idx = 2;
// final Point2d pt = initial.firstObject().get(idx);
// pt.translate(4, 0);
VideoDisplay.createVideoDisplay(new AnimatedVideo<MBFImage>(new MBFImage(640, 480, 3), 30) {
PointList shape = initial.firstObject().transform(
TransformUtilities.scaleMatrixAboutPoint(0.9, 0.9, 320, 240));
FImage img = initial.secondObject();
@Override
protected void updateNextFrame(MBFImage frame) {
frame.drawImage(img.toRGB(), 0, 0);
frame.drawLines(conns.getLines(shape), 1, RGBColour.BLUE);
final IterationResult next = asm.performIteration(img, shape);
shape = next.shape;
// frame.drawPoint(pt, RGBColour.RED, 3);
// Point2d newpt =
// ((NormalLandmarkModel)asm.getLandmarkModels()[idx]).updatePosition(img,
// pt, shape).first;
// pt.setX(newpt.getX());
// pt.setY(newpt.getY());
}
});
}
示例14: BasicDataset
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
public BasicDataset(List<IndependentPair<PointList, IMAGE>> data, PointListConnections connections) {
this.data = data;
this.connections = connections;
}
示例15: Factory
import org.openimaj.math.geometry.point.PointListConnections; //导入依赖的package包/类
/**
* Default constructor.
* @param connections connections between points.
* @param sampler sampler for sampling along normals
* @param numModelSamples number of samples for the model
* @param numSearchSamples number of samples for search; must be bigger than numModelSamples
* @param normalLength length of the normal in intrinsic scale units
*/
public Factory(PointListConnections connections, FLineSampler sampler, int numModelSamples, int numSearchSamples, float normalLength) {
this.connections = connections;
this.sampler = sampler;
this.numModelSamples = numModelSamples;
this.normalLength = normalLength;
this.numSearchSamples = numSearchSamples;
}