Exemplo n.º 1
0
  @Override
  public synchronized void afterUpdate(final VideoDisplay<MBFImage> display) {
    if (this.matcher != null && !this.videoFrame.isPaused()) {
      final MBFImage capImg = this.videoFrame.getVideo().getCurrentFrame();
      final LocalFeatureList<Keypoint> kpl = this.engine.findFeatures(capImg);

      final MBFImageRenderer renderer = capImg.createRenderer();
      renderer.drawPoints(kpl, RGBColour.MAGENTA, 3);

      MBFImage matches;
      if (this.matcher.findMatches(kpl)) {
        try {
          // Shape sh =
          // modelImage.getBounds().transform(((MatrixTransformProvider)
          // matcher.getModel()).getTransform().inverse());
          // renderer.drawShape(sh, 3, RGBColour.BLUE);
          final Matrix boundsToPoly =
              ((MatrixTransformProvider) this.matcher.getModel()).getTransform().inverse();
          this.renderMode.render(renderer, boundsToPoly, this.modelImage.getBounds());
        } catch (final RuntimeException e) {
        }

        matches =
            MatchingUtilities.drawMatches(
                this.modelImage, capImg, this.matcher.getMatches(), RGBColour.RED);
      } else {
        matches =
            MatchingUtilities.drawMatches(
                this.modelImage, capImg, this.matcher.getMatches(), RGBColour.RED);
      }

      this.matchPanel.setPreferredSize(this.matchPanel.getSize());
      this.matchFrame.setImage(ImageUtilities.createBufferedImageForDisplay(matches));
    }
  }
  /**
   * {@inheritDoc}
   *
   * @see org.openimaj.video.VideoDisplayListener#beforeUpdate(org.openimaj.image.Image)
   */
  @Override
  public void beforeUpdate(MBFImage frame) {
    if (edgeDetect) frame.processInplace(new CannyEdgeDetector2());

    if (faceDetect) {
      HaarCascadeDetector d = new HaarCascadeDetector(100);
      List<DetectedFace> faces = d.detectFaces(Transforms.calculateIntensityNTSC(frame));

      for (DetectedFace face : faces) {
        Shape transBounds = face.getBounds();
        MBFImageRenderer renderer = frame.createRenderer();
        renderer.drawPolygon(transBounds.asPolygon(), RGBColour.RED);
      }
    }

    if (faceKPDetect) {
      System.out.println("HERE");
      FKEFaceDetector fkp =
          new FKEFaceDetector(HaarCascadeDetector.BuiltInCascade.frontalface_alt.load());
      List<KEDetectedFace> faces = fkp.detectFaces(Transforms.calculateIntensityNTSC(frame));

      for (KEDetectedFace face : faces) {
        Shape transBounds = face.getBounds();
        MBFImageRenderer renderer = frame.createRenderer();
        renderer.drawPolygon(transBounds.asPolygon(), RGBColour.RED);

        for (FacialKeypoint kp : face.getKeypoints()) {
          Point2d pt = kp.position.clone();
          pt.translate((float) transBounds.minX(), (float) transBounds.minY());
          renderer.drawPoint(pt, RGBColour.GREEN, 3);
        }
      }
    }

    if (moustache)
      try {
        frame.internalAssign(new Mustache().addMustaches(frame));
      } catch (IOException e) {
        e.printStackTrace();
      }
  }
Exemplo n.º 3
0
      @Override
      public void render(
          final MBFImageRenderer renderer, final Matrix transform, final Rectangle rectangle) {
        if (this.toRender == null) {
          this.toRender =
              new XuggleVideo(
                  VideoColourSIFT.class.getResource("/org/openimaj/demos/video/keyboardcat.flv"),
                  true);
          this.renderToBounds =
              TransformUtilities.makeTransform(
                  new Rectangle(0, 0, this.toRender.getWidth(), this.toRender.getHeight()),
                  rectangle);
        }

        final MBFProjectionProcessor mbfPP = new MBFProjectionProcessor();
        mbfPP.setMatrix(transform.times(this.renderToBounds));
        mbfPP.accumulate(this.toRender.getNextFrame());
        mbfPP.performProjection(0, 0, renderer.getImage());
      }
Exemplo n.º 4
0
      @Override
      public void render(
          final MBFImageRenderer renderer, final Matrix transform, final Rectangle rectangle) {
        if (this.toRender == null) {
          try {
            this.toRender =
                ImageUtilities.readMBF(
                    VideoColourSIFT.class.getResource("/org/openimaj/demos/OpenIMAJ.png"));
          } catch (final IOException e) {
            System.err.println("Can't load image to render");
          }
          this.renderToBounds =
              TransformUtilities.makeTransform(this.toRender.getBounds(), rectangle);
        }

        final MBFProjectionProcessor mbfPP = new MBFProjectionProcessor();
        mbfPP.setMatrix(transform.times(this.renderToBounds));
        mbfPP.accumulate(this.toRender);
        mbfPP.performProjection(0, 0, renderer.getImage());
      }
Exemplo n.º 5
0
 @Override
 public void render(
     final MBFImageRenderer renderer, final Matrix transform, final Rectangle rectangle) {
   renderer.drawShape(rectangle.transform(transform), 3, RGBColour.BLUE);
 }