Conflict between two OpenCV Processing commands [closed]

asked 2018-01-09 10:39:22 -0500

Hello there!

I get a NullPointerException when I am trying to run both findCannyEdges and the BackgroundSubstraction effect from this library.

When you comment out one of the two codelines that are conflicting, you can see the effects that I am trying to show next to one another.

I'm a bit stuck as to how I can solve this?

import gab.opencv.*;  
import processing.video.*;
Capture cam;

OpenCV opencv;
PImage edges, movement;

void setup() {
  size(1200, 760);

  //Start webcam capture
  cam = new Capture(this, 320, 240, 30);
  cam.start();

  opencv = new OpenCV(this, 320, 240);
  opencv.startBackgroundSubtraction(5, 3, 0.5);
}

void draw() {
  background(51);

  // Read webcam image
  if(cam.available()) {
    cam.read();
  }

  //Display depth map
  image(cam, 25, height*0.05, width/3, height/2);

  showMovement();
  showEdges();
}

void showEdges(){
  opencv = new OpenCV(this, cam); //THIS ONE CONFLICTS WITH updateBackground
  opencv.findCannyEdges(20,75);
  edges = opencv.getSnapshot();
  image(edges, width/3, height*0.05, width/3, height/2); 
}

void showMovement(){
  opencv.loadImage(cam);
  opencv.updateBackground(); //THIS ONE CONFLICTS WITH new OpenCV
  opencv.dilate();
  opencv.erode();
  noFill();
  stroke(255, 0, 0);
  strokeWeight(3);
  for (Contour contour : opencv.findContours()) {
    contour.draw();
  }  
}

// Called every time a new frame is available to read
void movieEvent(Movie m) {
  m.read();
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2018-01-09 11:10:55.140385

Comments

1

sorry, but we cannot help you with processing problems. it' an unsupported, 3rdparty api

(and you probably should use opencv's java api instead of it)

berak gravatar imageberak ( 2018-01-09 11:12:23 -0500 )edit