Favorite OpenCV 2.0 Library

I have been using the OpenCV library listed in the official Processing libraries page and have found it to be somehow deprecated as of the new Processing distribution. It also only implements OpenCV at a 1.0 level as I understand anyways so a new one must be found.

There are at least 2 new libraries for Processing that implement OpenCV:

One by "atduskgreg" -- https://github.com/atduskgreg/opencv-processing

And another, "JavacvPro" -- http://www.mon-club-elec.fr/pmwiki_reference_lib_javacvPro/pmwiki.php?n=Main.Presentation

Has anyone tried these any which do you prefer?

I am a native English speaker and am looking to route in all types of Syphon feeds to take advantage of as many functions as possible.

Answers

  • I still have / want to work more with OpenCV someday (so much to do, so little time) so I can't help you out yet. However I would like to ask you to just try it yourself (apparantly nobody is replying so far) and post your findings here. I think it would be very interesting for future users, at least personally I would find it interesting to hear your findings! :)

  • I definitely will be exploring and reporting on this more!

  • Answer ✓

    The libarary atduskgreg is one of the best opencv library out there. I have worked with it before. It pretty simple to install and implement. Let me know if you need any help.

  • I found this library, atduskgreg, hard to install.

    What folder from within the distribution do you put in your library?

    I found no instructions from the site. You figure you would put the entire folder in the libraries but none of the sketches call on the library "gab" properly. I have other 3rd party libraries installed just fine so I'm sure it's pointing in the right direction.

    I tried running this folder in many positions, in 32 and 64 bit mode, but found no luck.

    Can you please help me understand how to install this properly?

    Thank you,

  • Two ways:

    1. (Automatic) In PDE go to: Sketch > Import Library > Add Library > Type "cv" > Select OpenCV for Processing > Click Install
    2. (Manual) Download latest release from: https://github.com/atduskgreg/opencv-processing/releases & unzip in Libraries folder
  • Got it, the installer made quick work of it

  • I would like to see about getting a syphon feed into OpenCV correctly.

    I tried a few paths last night and was able to apply image filters (threshold, contrast, etc) to the Syphon feed but not able to take it further and draw contours for image for instance.

    I was able to call a contour function but it draws it only on some mouse related graphics on top.

    How should I go about directing the Syphon feed into this OpenCV library?


    Main Body

    import codeanticode.syphon.*;
    import gab.opencv.*;
    
    
    PGraphics pg;
    PImage sandCVimg;
    ArrayList<Contour> contours;
    SyphonClient MultiplePS3client;
    SyphonServer SandIRserve;
    OpenCV opencv;
    
    // This is from the Syphon Class
    SFD send;
    
    
    void setup() {
      size(640, 480, P3D);
      pg = createGraphics(640, 480, P3D);
    
      // Create syhpon client to receive frames 
      // Using the exact Syphon feed from the PS3 Eye App 
      //  MultiplePS3client = new SyphonClient(this, "Multiple PS3 eye and syphon");
    
    
      //  Use this for any other Syphon feeds
      MultiplePS3client = new SyphonClient(this);
    
      // Copies the syphon feed into an OpenCV suitable image
      sandCVimg = pg;
      //Assigns the image to OpenCV
      opencv = new OpenCV(this, sandCVimg);
      //  Load image instead of Syphon
      //  opencv = new OpenCV(this, "Sensebellum Logo Color.jpg");
      contours = opencv.findContours();
      println("found " + contours.size() + " contours");
    
    
    
      //  This is from the Syphon Class
      send = new SFD(this);
    }
    
    
    void draw() { 
      pg = MultiplePS3client.getGraphics(pg);
      image(pg, 0, 0, width, height);
    
      //OpenCV Drawing
      opencv.loadImage(sandCVimg);
      opencv.brightness(0);
      opencv.threshold((int)map(mouseX, 0, width, 1, 200));
    
      // For drawing the OpenCV Contours
      noFill();
      strokeWeight(3);
    
      for (Contour contour : contours) {
        stroke(0, 255, 0);
        contour.draw();
      }
    
      //Always goes at the end of the OpenCV draw
      image(opencv.getOutput(), 0, 0);
    
      //For testing the addition of graphics
      rectMode(CENTER);
      rect(mouseX, mouseY, 50, 30);
    
    
      //  This is from the Syphon Class
      send.update();
    }  
    

    "Syphon Class"

    import codeanticode.syphon.*;
    class SFD {
      public PGraphics canvas;
      public SyphonServer server;
      PApplet that;
      SFD(PApplet tthat) {
        that = tthat;
        canvas = createGraphics(that.width, that.height, P3D);
        // Create syhpon server to send frames out.
        server = new SyphonServer(that, "Sandbox Out");
      }
    
      void update() {
        that.loadPixels();
        canvas.loadPixels();
    
        //    arrayCopy(that.pixels, canvas.pixels);
    
        for (int x = 0; x < that.width; x++) {
          for (int y = 0; y < that.height; y++) {
            canvas.pixels[((that.height-y-1)*that.width+x)] = that.pixels[y*that.width+x];
          }
        }
    
        //    for(int i=0;i<that.pixels.length;i++){
        //      canvas.pixels[i] = that.pixels[i];
        //    }
        canvas.updatePixels();
        server.sendImage(canvas);
      }
    }
    
  • The "contours = opencv.findContours();" call should be put in draw() not setup(). That fixed it

Sign In or Register to comment.