Package org.sikuli.core.draw

Examples of org.sikuli.core.draw.ImageRenderer


        TemplateMatcher.findMatchesByGrayscaleAtOriginalResolution(testImage, model.getTopRight().getImage(), numMatches, minSimilarity);

    final List<RegionMatch> tms4 =
        TemplateMatcher.findMatchesByGrayscaleAtOriginalResolution(testImage, model.getBottomLeft().getImage(), numMatches, minSimilarity);
   
    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();
View Full Code Here


    return filteredCandidateMatches;
  }

  static ImageRenderer visualize(BufferedImage image,
      final List<TextMatch> matches) {
    ImageRenderer a = new PiccoloImageRenderer(image) {

      @Override
      protected void addContent(PLayer layer) {
        for (int i = 0; i < matches.size(); ++i) {
          if (i > 1)
View Full Code Here

    model.bottomRight = new ModelPart(new Rectangle(w-d,h-d,d,d), s);
    model.bottomLeft = new ModelPart(new Rectangle(0,h-d,d,d), s);
         
    final List<ModelPart> parts = Lists.newArrayList(model.topLeft,model.topRight,model.bottomRight,model.bottomLeft);
   
    ImageRenderer ir = new PiccoloImageRenderer(trimmedModelImage){
      @Override
      protected void addContent(PLayer layer) {
        for (ModelPart part : parts){         
          PPath p = PPath.createRectangle(0,0,d,d);
          p.setStrokePaint(Color.red);
View Full Code Here

    }
  }
 
  void logMouseAction(final String actionName, final ScreenLocation location){
    BufferedImage img = loggedScreenRegion.capture();
    ImageRenderer ir = new LogImageRenderer(img){

      @Override
      protected void addContent(PLayer layer) {
        PPath c = PPath.createEllipse(0, 0, 10,10);
        c.setPaint(Color.red);
        c.setOffset(location.getX() - loggedScreenRegion.getBounds().getX() - 5, location.getY() - loggedScreenRegion.getBounds().getY() - 5);
        layer.addChild(c);
       
        addTextLabel(layer, actionName,location.getX() - loggedScreenRegion.getBounds().x - 20, location.getY() - loggedScreenRegion.getBounds().y - 40);
        addNodeWithShadow(layer, c);
      }     
    };
    writeLogImage(ir.render(), actionName);   
  }
View Full Code Here

  };
 
  private void logFindHelper(final String actionName, final ScreenRegion screenRegion, final Target target,
      final List<ScreenRegion> results){
    BufferedImage img = loggedScreenRegion.getLastCapturedImage();
    ImageRenderer ir = new LogImageRenderer(img){
     
      @Override
      protected void addContent(PLayer layer) {
        addTextLabel(layer, actionName, 3, 3);   
       
        // draw the target image
        BufferedImage targetImage = ((DefaultTarget) target).toImage();
        if (targetImage != null){
          PImage im = new PImage(targetImage);
          im.setOffset(3, 30);
          im.setPaint(Color.black);
          addNodeWithShadow(layer, im);
        }
       
        // draw a rectangle around the screen region in which find was performed
        addRectangle(layer, screenRegion.getBounds().x - loggedScreenRegion.getBounds().x,
            screenRegion.getBounds().y - loggedScreenRegion.getBounds().y, screenRegion.getBounds().width, screenRegion.getBounds().height,
            Color.green);
       
        // draw a rectangle around the found target
        for (ScreenRegion result : results){
          addRectangle(layer, result.getBounds().x - loggedScreenRegion.getBounds().x,
              result.getBounds().y - loggedScreenRegion.getBounds().y, result.getBounds().width, result.getBounds().height,
              Color.red);
        }
       
      } 
    };
    writeLogImage(ir.render(), actionName)
  }
View Full Code Here

TOP

Related Classes of org.sikuli.core.draw.ImageRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.