Ejemplo n.º 1
0
  @Override
  public void draw() {
    // When a frame becomes available
    if (HighGui.queryFrame(capture, im)) {
      background(70);

      // Draw it
      image(PUtils.getPImage(im), 0, 0);

      ThresholdType type = ThresholdType.CV_THRESH_BINARY;
      if (r.value() != -1) type = ThresholdType.values()[(int) r.value() - 1];
      ImgProc.threshold(im, im_thresh, thresh_slider.value(), 255, type);
      image(PUtils.getPImage(im_thresh), w, 0);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void setup() {
    size(2 * w, h + 150);

    // Camera initiated to capture from device
    capture = HighGui.captureFromCAM(0);

    im = CxCore.createImage(w, h, PixelDepth.IPL_DEPTH_8U, ColorModel.BGR);
    im_thresh = CxCore.createImage(w, h, PixelDepth.IPL_DEPTH_8U, ColorModel.BGR);

    // Init GUI
    ControlP5 controlP5 = new ControlP5(this);
    thresh_slider = controlP5.addSlider("thresh_val", 0, 255, 20, h + 20, 10, 100);
    r = controlP5.addRadioButton("thresh_type", 80, h + 20);
    for (int i = 0; i < ThresholdType.values().length; i++) {
      r.addItem(ThresholdType.values()[i].toString(), i + 1);
    }
    r.activate(0);
  }