Processing 3.5 on the RPi4 (with OpenCV and Kinect support)
Ten years ago I created with my friend Rubén Tortosa an art installation that would use a Kinect to capture the silhouette of a person standing in front of it. At the time, it was a PC running Ubuntu 10.10 and using Microsoft's Kinect camera. Microsoft wanted all of us to only use that camera with the Xbox game system. Thanks to the libfreenect library many of us did exactly the opposite.
That piece has gone through several exhibits and it is now starting to cough up every now and then. So I wanted to check if the new Raspberry Pi 4 was a possible candidate for replacing the PC.
I installed the 32-bit Jesse distro on a 16GB SD card and placed into my RPi4. I was able to install Processing on the Pi with this command-line:
curl https://processing.org/download/install-arm.sh | sudo sh
The next step was to be able to use it, but as I was running a headless system, I could not rely on the local display. I am using Xvnc instead, so now I have a "virtual" screen I can access remotely using VNC. The only tool that worked fine with it was RealVNC (not Mac's finder cmd+K nor TightVNC worked for compatibility reasons).RealVNC asked me to create an account but once done it did not bug me more and it seems to work reliably. I do not know how secure the connection may be, but the fact that other VNC clients did not work makes me think that there might be there a security concern.
Once the GUI was up and I could use my computer to remotely open Processing and run programs it became apparent that things were not going to be easy. I installed OpenCV and Open Kinect libraries for Processing but code examples did not work 😓
On the OpenCV front, it became apparent the downloaded library relied on libpng12 while the one on my system was libpng16. But luckily, the install of version 12 alongside was uneventful. Now, OpenCV examples are working.
Open Kinect was giving a NullPointer exception on the very first line, so it appeared the binary library loaded but it interacted poorly with the java binding. Somehow I ended up replacing it with a version 0.3a that worked nicely on the Pi. Of course, libfreenect needs to be installed first.
The downgraded version of OpenKinect worked nicely with libreenect and so did all the code examples so I was finally in a position to migrate my old code.
I was using an old library for setting a Processing up to full-screen. Now that is obsoleted by the new fullScreen() command that substitutes the size() command on the setup() method. A few methods have changed in the Kinect front, but following the examples, it was easy to fix those too.
The remaining problem was the absence of the blobs() method on OpenCV. A bit of digging let me to what I believe is a newer implementation called findContours(). Once converted it still did not work. The reason being that contrary to the old blobs() method, findContours() does not give you the largest blob first. So now I find the largest contours looping through all of them and then pass that to the rest of the program.
So finally the same old app is running happily in the RPi4, amazing.
Comments