Code Monkey home page Code Monkey logo

threevee's Introduction

ThreeVee

OpenCV 3 with Clojure & Quil

A Quil sketch designed to detect faces with OpenCV 3.3 and LISP!

Usage

LightTable - open core.clj and press Ctrl+Shift+Enter to evaluate the file.

Emacs - run cider, open core.clj and press C-c C-k to evaluate the file.

REPL - run (require 'threevee.core).

Notes

OpenCV Required

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 3.3.0. So, you may need to replace 330 in the instructions below with the current version.

Java

Confirm Java is already installed:

$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Otherwise, install it.

On OS X, I used Homebrew, requiring the following

brew update
brew install cmake
brew install python2
brew install ant

If python2 not available, make sure you have Python pointing to Python v2.

Build the OpenCV JAR files

To install OpenCV (with Java support) through Homebrew, you need to edit the opencv formula in Homebrew, to add support for Java: brew edit opencv In the text editor that will open, change the line: -DBUILD_opencv_java=OFF in -DBUILD_opencv_java=ON then, after saving the file, you can effectively install OpenCV: brew install --build-from-source opencv

After the installation of OpenCV, the needed jar file and the dylib library will be located at /usr/local/Cellar/opencv/3.x.x/share/OpenCV/java/, e.g., /usr/local/Cellar/opencv/3.3.0_3/share/OpenCV/java/.

NO NEED TO INSTALL IT, WE JUST NEED THE JAR. So, there's no reason to install it.

Use lein-localrepo to install JAR files

Create a file named profiles.clj in the ~/.lein directory and copy into it the following content:

{:user {:plugins [[lein-localrepo "0.5.4"]]}}

You may need to change 0.5.4 to the latest version of lein-localrepo.

mkdir clj-opencv
cd clj-opencv
cp <path>/<to>/opencv/build/bin/opencv-330.jar .
mkdir -p native/macosx/x86_64
cp ../opencv/build/lib/libopencv_java330.dylib native/macosx/x86_64
jar -cMf opencv-native-330.jar native
lein localrepo install opencv-330.jar opencv/opencv 3.3.0
lein localrepo install opencv-native-330.jar opencv/opencv-native 3.3.0

Get Haar Cascade Classifier XML Files

From https://github.com/opencv/opencv Place them in the following locations (if you need them): src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_eye.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_frontalcatface.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_frontalcatface_extended.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_frontalface_alt.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_frontalface_alt_tree.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_frontalface_default.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_fullbody.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_lefteye_2splits.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_licence_plate_rus_16stages.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_lowerbody.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_profileface.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_righteye_2splits.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_russian_plate_number.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_smile.xml src/CASCADE_CLASSIFIERS/OpenCV/haarcascades/haarcascade_upperbody.xml

Contrib Classifiers

From https://github.com/opencv/opencv_contrib Place them in the following locations (if you need them): src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_eyepair_big.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_eyepair_small.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_leftear.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_lefteye.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_lefteye_alt.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_mouth.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_nose.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_rightear.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_righteye.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_righteye_alt.xml src/CASCADE_CLASSIFIERS/contrib/haarcascades/haarcascade_mcs_upperbody.xml

Run with Boot

Leiningen has an injections feature (in project.clj) which loads the native OpenCV libraries. This doesn't work in Boot, because the java.library.path is not the same. Set this up manually from the command line (doesn't work in the boot.properties file).

env BOOT_JVM_OPTIONS="$BOOT_JVM_OPTIONS -Djava.library.path=/path/to/native/macosx/x86_64" boot extract-faces

For /path/to/native, see location of exploded opencv-native-xxx.jar above.

License

Copyright © 2017 Pas de Chocolat, LLC

Distributed under the MIT License

threevee's People

Contributors

mudphone avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dagron

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.