Some Clojure Quil + OpenCV demo projects
- Working Clojure install
- Some familiarity with Quil (Clojure's Processing port)
- Some familiarity / interest in OpenCV
- OpenCV JARs installed in Maven (see below)
The demos highlighted here are Quil sketches. Run them as you would any Quil sketch. I prefer to eval the ns in an Emacs Cider REPL.
Optical Flow: Vectors, while moving camera (above)
- Flow vectors drawn as lines
- Corners highlighted
- Corners highlighted, variable camera size
- Larger flow vectors example, used as input to gesture demo
- Flocking + flow as gestures, with bad performance
You'll have to build and install the OpenCV JAR files for your setup. Installation tested on Archlinux and OS X. The following is a rough summary of "Introduction to OpenCV Development with Clojure."
Note, at time of writing, the latest version was 2.4.10. So, you may need to replace 2410
in the instructions below with the current version.
Confirm Java is already installed:
$ java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
Otherwise, install it.
brew update
brew install cmake
brew install python2
brew install ant
If python2 not available, make sure you have Python pointing to Python v2.
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 2.4
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=OFF ..
... output omitted ...
... make sure that java is on the list of OpenCV modules "to be built"
... if it isn't on the list, the check for missing Java deps in the
... same output
...
make -j8
NO NEED TO INSTALL IT, WE JUST NEED THE JAR. So, there's no reason to install it.
Built files are:
build/bin/
build/lib/libopencv_java2410.dylib
Create a file named profiles.clj in the ~/.lein directory and copy into it the following content:
{:user {:plugins [[lein-localrepo "0.5.3"]]}}
You may need to change 0.5.3
to the latest version of lein-localrepo
.
mkdir clj-opencv
cd clj-opencv
cp <path>/<to>/opencv/build/bin/opencv-2410.jar .
mkdir -p native/macosx/x86_64
cp ../opencv/build/lib/libopencv_java2410.dylib native/macosx/x86_64
jar -cMf opencv-native-2410.jar native
lein localrepo install opencv-2410.jar opencv/opencv 2.4.10
lein localrepo install opencv-native-2410.jar opencv/opencv-native 2.4.10