ImageRenderer matchedPartsRenderer = new PiccoloImageRenderer(testImage){
@Override
protected void addContent(PLayer layer) {
for (List<RegionMatch> tmss : Lists.newArrayList(tms1,tms2,tms3,tms4)){
for (RegionMatch tms : tmss){
PPath c = PPath.createRectangle(tms.getX(),tms.getY(),tms.getWidth(),tms.getHeight());
c.setStroke(new BasicStroke(2f));
c.setStrokePaint(Color.blue);
c.setTransparency(0.5f);
layer.addChild(c);
}
}
}
};
logger.step(matchedPartsRenderer, "matched parts");
// generate hypotheses
final List<MatchHypothesis> hypotheses = Lists.newArrayList();
for (RegionMatch scoreMatch1 : tms1){
for (RegionMatch scoreMatch3 : tms3){
ModelPartMatch m1 = new ModelPartMatch(model.getTopLeft(), scoreMatch1);
ModelPartMatch m2 = new ModelPartMatch(model.getBottomRight(), scoreMatch3);
MatchHypothesis newHypothesis = new MatchHypothesis(m1,m2);
if (newHypothesis.isValid()){
hypotheses.add(newHypothesis);
}
}
}
ImageRenderer hypothesesRenderer = new PiccoloImageRenderer(testImage){
@Override
protected void addContent(PLayer layer) {
for (MatchHypothesis h : hypotheses){
ModelPartMatch m1 = h.getTopLeft();
ModelPartMatch m2 = h.getBottomRight();
RegionMatch p1 = m1.getScoreMatch();
RegionMatch p2 = m2.getScoreMatch();
PPath line = PPath.createLine(p1.getX(),p1.getY(),p2.getX(),p2.getY());
line.setStroke(new BasicStroke(2f));
line.setStrokePaint(Color.red);
layer.addChild(line);
Point p = h.getExpectedBottomLeftPartModelLocation();
PPath c = PPath.createRectangle(p.x,p.y,10,10);
c.setStroke(new BasicStroke(2f));
c.setStrokePaint(Color.green);
layer.addChild(c);
p = h.getExpectedTopRightPartModelLocation();
c = PPath.createRectangle(p.x,p.y,10,10);
c.setStroke(new BasicStroke(2f));
c.setStrokePaint(Color.green);
layer.addChild(c);
}
}
};
logger.step(hypothesesRenderer, "hypotheses");