Пример #1
0
  public static void main(String[] args) {

    MarvinImagePlugin moravec =
        MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.corner.moravec");
    moravec.load();
    moravec.setAttribute("threshold", 50000);

    // 1. Figures
    MarvinImage imageIn = MarvinImageIO.loadImage("./res/moravec.png");
    MarvinAttributes attr = new MarvinAttributes();
    moravec.process(imageIn, null, attr);
    imageIn = showCorners(imageIn, attr, 6);
    MarvinImageIO.saveImage(imageIn, "./res/moravec_out.png");

    // 2. Face
    moravec.setAttribute("threshold", 2000);
    moravec.setAttribute("matrixSize", 7);
    imageIn = MarvinImageIO.loadImage("./res/alan.jpg");
    attr = new MarvinAttributes();
    moravec.process(imageIn, null, attr);
    imageIn = showCorners(imageIn, attr, 3);
    MarvinImageIO.saveImage(imageIn, "./res/alanOut.png");

    // 3. House
    moravec.setAttribute("threshold", 1500);
    moravec.setAttribute("matrixSize", 7);
    imageIn = MarvinImageIO.loadImage("./res/cards.jpg");
    attr = new MarvinAttributes();
    moravec.process(imageIn, null, attr);
    imageIn = showCorners(imageIn, attr, 3);
    MarvinImageIO.saveImage(imageIn, "./res/cardsOut.png");
  }
Пример #2
0
  public ChromaKey() {
    try {
      videoPanel = new MarvinImagePanel();
      videoInterface = new MarvinJavaCVAdapter();
      videoInterface.connect(1);

      imageWidth = videoInterface.getImageWidth();
      imageHeight = videoInterface.getImageHeight();

      imageOut = new MarvinImage(imageWidth, imageHeight);

      loadGUI();

      pluginChroma = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.subtract.jar");
      pluginCombine =
          MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.combine.combineByMask.jar");

      MarvinImage l_imageParadise = MarvinImageIO.loadImage("./res/paradise.jpg");
      Integer cameraWidth = videoInterface.getImageWidth();
      Integer cameraHeight = videoInterface.getImageHeight();

      MarvinImagePlugin pluginScale =
          MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.transform.scale.jar");
      pluginScale.setAttribute("newWidth", cameraWidth);
      pluginScale.setAttribute("newHeight", cameraHeight);

      MarvinImage l_imageParadiseResize = new MarvinImage(1, 1);
      pluginScale.process(l_imageParadise, l_imageParadiseResize);
      l_imageParadise = l_imageParadiseResize;

      pluginCombine.setAttribute("combinationImage", l_imageParadise);
      pluginCombine.setAttribute("colorMask", new Color(0, 0, 255));

      imageBackground = new MarvinImage(cameraWidth, cameraHeight);

      thread = new Thread(this);
      thread.start();
      playing = true;
      removeBackground = false;
    } catch (MarvinVideoInterfaceException e) {
      e.printStackTrace();
    }
  }