Updated Kinect Library for Processing

A quick post to announce an updated Kinect library for Processing on github. This new library uses the most recent libfreenect drivers (mac os x only still) and builds off of the existing JNI Java Wrapper. Links:

Download library and example:
openkinect.zip

Source:
https://github.com/shiffman/libfreenect/tree/master/wrappers/java/processing

My tests show 30 FPS no problem for either the depth or RGB image, if you request both images, however, I’m only currently getting about 20 FPS. The update fixes a few bugs, exposes the raw depth data and includes a point cloud demo (see above video).

I have a list of “to-do” items here:

https://github.com/shiffman/libfreenect/issues
(a shortened version of the very long list in my head)

Box2D and Processing

 

I’m pleased to announce I’ve published a first draft of a tutorial about using Box2D in Processing.

Tutorial: http://www.shiffman.net/teaching/nature/box2d-processing/
Google code repository: http://code.google.com/p/pbox2d/

I’m struggling here to figure out whether I’m (a) creating a Processing Box2D library or (b) simply creating a tutorial and set of examples piggybacking off of JBox2D. For now, I’m doing a little bit of both. The library is just a few helper functions, but the examples require you to dig into actual Box2D code. These examples aren’t nearly as comprehensive as what you’ll find in the JBox2D demos. It’s my goal, however, to make the material accessible and easy to use. Hopefully, with some feedback and more time, I’ll be able to publish a more sophisticated library and thorough suite of example. Who knows, maybe no one will ever need any of my previous Nature of Code tutorials any more!

Next up, I’m planning on creating a few simple examples that use the fantastic and awe-inspiring toxiclibs.

XBee API Library for Processing

Rob Faludi and I are working on a Processing library for Digi’s XBee Series 1 radios. Direct from Rob’s blog:

The library currently facilitates receiving single sample I/O packets in API mode, and returns an object that contains the analog values, digital values, sender’s 16-bit address and RSSI value. The next tasks will be to receive regular RX frames, issue AT commands and receive responses, issue TX frames and receive responses to those. We’d also like to support the XBee Series 2 radios, which have a similar API structure.

Here’s where you can download and learn about the library.

Most Pixels Ever Alpha Release

Seriously, Run Lola Run.  Run!

I’m pleased to announce that we’re releasing the first version of The Most Pixels Ever, an open-source Java framework for spanning Processing sketches across multiple screens (developed with Chris Kairalla). This is an early version that has many limitations and needs a great deal of improvement, but it does work. The site isn’t complete, but the source is available, and there are a couple tutorials to help get your started.

I’ll be using the library in conjunction with teaching a new class at ITP starting today!

Processing Yahoo Search Library

2011 Update: While this library may still work, I am deprecating it as Yahoo does not support the Java Search API any longer as far as I can tell

Now, I am rather overdue for an update on my upcoming book. I’ll be posting details soon. However, in the course of finishing up a chapter on String parsing, I discovered that my good friend, the Google SOAP API is no longer being supported (obviously, I’m a little late on the ball here.)

So, I quickly whipped up a Processing library to make use of the Yahoo Search API. Now, you can access the Yahoo! API directly in Processing. There’s even an example here. However, you would have to write your own thread if you wanted to search asynchronously. In addition, if you’re not comfortable diving into outside Java APIs, you might struggle to figure out the syntax. (Switchboard also provides an interface to the Yahoo! API.)

So I set out (as an example for my book) to make a quick and easy bridge to the Yahoo API.

  • Download the library here
  • Go and get a developer ID
  • Download the Yahoo! Search SDK Find the file: yahoo_search-2.X.X.jar and put it in the library folder (along with the above download).
  • Finally, take a peek at this example code.

    // Import the library
    import pyahoo.*;
     
    YahooSearch yahoo;
     
    void setup() {
      size(400,400);
      // Make a search object
      yahoo = new YahooSearch(this,"YOUR API KEY HERE");
     
    }
     
    void mousePressed() {
      yahoo.search("processing.org");
      // You can request more results like so (the default is 10):
      // yahoo.search("processing.org",30);
    }
     
    void draw() {
      noLoop();
    }
     
    // The searches will come in one at a time to here when finished
    void searchEvent(YahooSearch yahoo) {
      // You can get the titles, URLs, or Summaries back as an array of Strings
      String[] titles = yahoo.getTitles();
      String[] urls = yahoo.getUrls();
      println("\nI searched for " + yahoo.getSearchString());
      println("There are a total of " + yahoo.getTotalResultsAvailable() + " results available");
      println("Here are the first " + yahoo.getNumberRequested());
      for (int i = 0; i < titles.length; i++) {
        println("___________");
        println("Item # " + i);
        println(titles[i]);
        println(urls[i]);
      }
     
      // You can also access the Yahoo API Directly by asking for the WebSearchResult object:
      // WebSearchResults results = yahoo.getResults();
      // WebSearchResult[] results = yahoo.getResultsArray();
      // In this mode, make sure to import the Yahoo library up topl
      // import com.yahoo.search.WebSearchResults;
      // See Yahoo API documentation for more
    }

    There’s also a fancier example (mostly uncommented, sorry) that produced the image at the top of this post here.

    Thoughts? Helpful? Useful?

    Processing QRCode Library

    qrcode

    From: http://qrcode.sourceforge.jp/:

    “QR Code is a two-dimensional barcode, used widely in Japan. The advantage of QR Code from well-known barcode is larger data capacity (more than 100 bytes, typically) and error correction.”

    Thanks to an idea from Tom Igoe, I make a quick and dirty interface for Processing for QRCode decoding. The Pqrcode library page is here.

    Also, qrcode images can be generated here.

    Sftp with Java / Processing

    I know, I know, you’ve been waiting your whole life for this.

    Download beta SFTP Processing library (source and example included in zip).

    The library uses JSch (Java Secure Channel).
    Copyright (c) 2002,2003,2004,2005,2006,2007 Atsuhiko Yamanaka, JCraft, Inc.

    import sftp.*;
     
    Sftp sftp;
     
    void setup() {
      size(200,200);
      background(0);
      // Create the SFTP object
      // if 3rd arg = false, you must set the password in your code
      // if 3rd arg = true, you will be prompted to enter your password
      sftp = new Sftp("www.hostname.com","login", true);
      // sftp.setPassword("XXXXXX");
      sftp.start(); // start the thread
      noLoop();
    }
     
    void mousePressed() {
      // At any point you can execute an SFTP command 
      // Not all commands are currently implemented
      // but you do have "ls" and "get"
      // Gosh, I should implement "put", sorry!
      sftp.executeCommand("ls");
      sftp.executeCommand("get file.txt");
    }