Processing and Opencv 2.3.1 – How to install in win 7

THIS HOW-TO WORKS ONLY WITH PROCESSING 1.5.1, NOT WITH THE LAST 2.03b

 

The procedures to install opencv 2.3.1 libraries and JavaCvPro are explained in several sites. But I had many difficulties doing an installation in Windows 7, even following the step-by-step guides.

Then I would write a step-by-step procedure that is as simple as possible. The information sources that I used are :

http://code.google.com/p/javacv/wiki/Windows7AndOpenCV

http://www.mon-club-elec.fr/pmwiki_reference_lib_javacvPro/pmwiki.php

 

This installation is working in windows 7 (32 and 64 bit) with Processing 1.5.  It was tested by me in 4 different pc. These are the steps:

 

1. Install the runtime components for Microsoft Visual C++ 2010:

 

2. Extract OpenCV-2.3.1-win-superpack.exe inside the root directory C:\. At the end, the opencv are in  C:\OpenCV\

 

3. Add the ddl path generated by opencv to windows 7 path. This can be made easily with a free program:  RapidEE. Download it from here and launch it.

 

4. Find the registry key PATH and click on it.

 

 

 

5. Click the right mouse button and choose add value in the menu. Add these values:

  • C:\opencv\build\x64\vc10\bin\
  • C:\opencv\build\x64\vc10\lib\
  • C:\opencv\build\common\tbb\intel64\vc10\

If the win7 32bit version the directory are with x86 instead of x64. For 32bit version add also C:\opencv\build\common\tbb\ia32\vc10\

 

 

 

6. Download the JavaCvPro library (version 0.3) here.

 

7. Extract and copy all in the Processing library directory: Processing /Mode/java/libraries

 

8. Download the last version of binary JavaCV  library here (today is  javacv-bin-20120329.zip).

 

9. Extract and copy all in the Processing library directory: Processing /Mode/java/libraries

 

10. Create a directory called library inside the javacv-bin directory and put all the file (not the sample directory) inside this new library directory

 

11. Rename the library javacv-bin extracted with this name: javacv

 

12. Download the last version of the binary Javacpp library here  ( today is javacpp-0.1-bin.zip)

 

13. Extract and copy all in the Processing library directory: Processing /Mode/java/libraries

 

10. Create a directory called library inside the javacpp-bin directory and put all the file (not the sample directory) inside this new library directory

 

11. Rename the library javacpp-bin with this name: javacpp

 

 

If all the steps are succeeded, it is done. Now you can start Processing and test this simple program (take from here):

import com.googlecode.javacv.*;
import com.googlecode.javacv.cpp.*;

import monclubelec.javacvPro.*;

OpenCV opencv; // déclare un objet OpenCV principal

void setup(){ // fonction d'initialisation exécutée 1 fois au démarrage

        opencv = new OpenCV(this); // initialise objet OpenCV à partir du parent This
        opencv.allocate(320,240); // crée le buffer image de la taille voulue

}

void  draw() { // fonction exécutée en boucle

}

 

It is very important to include also the javacv and javacpp libraries. In the http://www.mon-club-elec.fr documentation this is not required, but in my experience, without these libraries, the program doesn’t work.

 

 

40 Replies to “Processing and Opencv 2.3.1 – How to install in win 7”

  1. I’m using Win7-32bit with processing 1.5.1 and get always the error:
    Unsatisfied LinkError C:\Users\”MYUSERNAME”\AppData\Local\Temp\javacpp3088171996531\jniopencv_core.dll: Can’t find depent libraries

    Exception in thread “Animation Thread” java.lang.UnsatisfiedLinkError: C:\Users\”MYUSERNAME”\AppData\Local\Temp\javacpp3088171996531\jniopencv_core.dll: Can’t find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
    at java.lang.Runtime.load0(Runtime.java:770)
    at java.lang.System.load(System.java:1003)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:566)
    at com.googlecode.javacpp.Loader.load(Loader.java:489)
    at com.googlecode.javacpp.Loader.load(Loader.java:431)
    at com.googlecode.javacv.cpp.opencv_core.(opencv_core.java:136)
    at monclubelec.javacvPro.OpenCV.(Unknown Source)
    at sketch_sep05a.setup(sketch_sep05a.java:33)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.UnsatisfiedLinkError: no opencv_core245 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
    at com.googlecode.javacpp.Loader.load(Loader.java:481)
    … 7 more

    i used your sample code and checked 3 times your tutorial.

    1. I think there is a problem with the opencv path, but I have no solution ready to use.
      Please verify if the path in the registry is correct.

  2. Now it worked, but I have to add the libraries manually. If I just copy and paste the code does not work.

    Can I use the latest version of OpenCV?

  3. Error:

    Display 0 does not exist, using the default display instead.
    Exception in thread “Animation Thread” java.lang.UnsatisfiedLinkError: C:\Users\Sid\AppData\Local\Temp\javacpp760675181273\jniopencv_core.dll: Can’t find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
    at java.lang.Runtime.load0(Runtime.java:770)
    at java.lang.System.load(System.java:1003)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:566)
    at com.googlecode.javacpp.Loader.load(Loader.java:489)
    at com.googlecode.javacpp.Loader.load(Loader.java:431)
    at com.googlecode.javacv.cpp.opencv_core.(opencv_core.java:136)
    at monclubelec.javacvPro.OpenCV.(Unknown Source)
    at sketch_130611a.setup(sketch_130611a.java:33)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.UnsatisfiedLinkError: no opencv_core245 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
    at com.googlecode.javacpp.Loader.load(Loader.java:481)
    … 7 more

    My system:
    -Windows Vista Starter 32 bits

    There was the Path. I had to create.

  4. It’s in reality a nice and useful piece of info.
    I’m happy that you simply shared this useful info
    with us. Please keep us informed like this. Thanks for sharing.

  5. Awesome explanation man…too good….just loved it…….saved a lot of time……just found it a little late(too many results on google)……but awesome work man……………..

  6. I would add little more details about my setup

    Downloaded Processing 1.5.1, OpenCV 2.3.1 and other libs as mentioned here and installed on Vista home premium as Admin.

    .. and my env variables are set as follows
    C:\opencv\build\x86\vc10\bin\
    C:\opencv\build\x86\vc10\lib\
    C:\opencv\build\common\tbb\ia32\vc10\

    put all libararies under processing/modes/java , a little typo in this web page saying Modes as Mode.

  7. Thanks for all the hard work you’ve put in, I’ve been trying to make this work for 3 days without success.

    Now i can run escape from the dreaded Unsatified link error.

  8. I have followed the steps and finally it success until your given code here:
    import com.googlecode.javacv.*;
    import com.googlecode.javacv.cpp.*;

    import monclubelec.javacvPro.*;

    OpenCV opencv; // déclare un objet OpenCV principal

    void setup(){ // fonction d’initialisation exécutée 1 fois au démarrage

    opencv = new OpenCV(this); // initialise objet OpenCV à partir du parent This
    opencv.allocate(320,240); // crée le buffer image de la taille voulue

    }

    void draw() { // fonction exécutée en boucle

    }

    but I found trouble when trying to run another samples like javacvpro_examples_blobs, it shows error like this:

    UnsatisfiedLinkError: C:\Users\Lenovo\AppData\Local\Temp\jniopencv_core6802312146559815152.dll: %1 is not a valid Win32 application

    Exception in thread “Animation Thread” java.lang.UnsatisfiedLinkError: C:\Users\Lenovo\AppData\Local\Temp\jniopencv_core6802312146559815152.dll: %1 is not a valid Win32 application
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
    at java.lang.Runtime.load0(Runtime.java:770)
    at java.lang.System.load(System.java:1003)
    at com.googlecode.javacpp.Loader.load(Loader.java:337)
    at com.googlecode.javacpp.Loader.load(Loader.java:271)
    at com.googlecode.javacv.cpp.opencv_core.(opencv_core.java:126)
    at monclubelec.javacvPro.OpenCV.(Unknown Source)
    at javacvpro_exemple_blobs.setup(javacvpro_exemple_blobs.java:49)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

  9. ho notato però che tu hai nel path dell’user qualche cos’altro di opencv…che io non ho e che nella guida non c’è scritto di mettere…potrebbe essere quello???

  10. Ciao

    ho seguito passo passo le tue istruzioni ma mi esce questo messaggio di errore quando provo ad eseguire uno dei qualsiasi esempi presenti in javacvPro : C:\Users\Dany\AppData\Local\Temp\jniopencv_core2902485471501818752.dll: %1 non è un’applicazione di Win32 valida

    ho seven 64 bit quindi ho aggiunto i 3 valori nel path come scritto sopra e ho seguito tutto il resto, ma non arrivo ad un dunque… (dimmi se poi vuoi che ti scriva in inglese perchè possa leggere anche chi non è italiano)

    1. La guida è stata utilizzata da decine di persone diverse e funziona. Non so se il tuo messaggio può dipendere da una configurazione particolare del pc. Il messaggio che ti compare significa che non viene riconosciuto il path dove si trovano le opencv. Però come vedi l’errore è assolutamente generico, quindi non ho altro consiglio che quello di ripassare nuovamente le istruzioni e ricontrollarle.

  11. I think the problem is in retrieving the Haar object.
    In particular in the row:
    opencv.cascade(“/usr/local/share/OpenCV/haarcascades/”,”haarcascade_frontalface_alt.xml”);

    Verify the correct path. In my sources the right code is:
    opencv.cascade( “C:/opencv/data/haarcascades/”, “haarcascade_frontalface_alt.xml”);

    Try, please.

  12. I am using processing version 1.5.1. Mainly used these sources for install.

    http://robottini.altervista.org/processing-and-opencv-2-3-1-how-to-install-in-win-7 (but I’m using windows 7)
    https://forum.processing.org/topic/how-to-install-opencv-properly-i-ve-tried-everything-i-can-but-there-s-no-progress#25080000001500011

    And other sources:
    http://www.mon-club-elec.fr/pmwiki_reference_lib_javacvPro/pmwiki.php?n=Main.Opencvdetect

    This is my error:

    OpenCV Error: Null pointer (Invalid classifier cascade) in unknown function, file C:\slave\WinInstallerMegaPack\src\opencv\modules\objdetect\src\haar.cpp, line 1041
    Exception in thread “Animation Thread” java.lang.RuntimeException: C:\slave\WinInstallerMegaPack\src\opencv\modules\objdetect\src\haar.cpp:1041: error: (-27) Invalid classifier cascade

    at com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects(Native Method)
    at monclubelec.javacvPro.OpenCV.detect(Unknown Source)
    at monclubelec.javacvPro.OpenCV.detect(Unknown Source)
    at sketch_20121026.draw(sketch_20121026.java:70)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

    I am trying to do a detect() and it throws the error at this line:

    faces1 = ocv1.detect();// detect anything ressembling a FRONTALFACE

    Any help would be appreciated!

  13. ok got it running

    could you just add to your description this line at the x86 part

    that there is in the tbb folder for the 32 bit systems a folder called

    ia32/vc10

    –> to add 😉

    but some examples have the

    .start() method which just diestn work

  14. to ensure i controll again the dlls which i added in:

    Path=C:\opencv\build\common\tbb\intel64\vc10\;C:\opencv\build\x86\vc10\lib\;C:\opencv\build\x86\vc10\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Broadcom\Broadcom 802.11\Driver

    C:\opencv\build\common\tbb\intel64\vc10\
    C:\opencv\build\x86\vc10\lib\
    C:\opencv\build\x86\vc10\bin\

    i also placed them in the order shown in your how-to
    and double checked in the processing/modes/java/… folder all the downloaded and extracted

    only difference is that i named the folder save ind c:

    C:\opencv and not C:\OpcenCV

    i dont find any other differences but it doenst work

  15. first of all i´ve 2 thank you again that u respons at all 🙂

    so my problem is:

    GSVideo works but javaCVpro doesnt

    examples are in the java example directory of processing when i start the programm

    but when i try to execute e.g. the blob example actually i get this error:

    javacvPro (Processing library) – version 0.0.3 – by X.HINAULT – Novembre 2011 – http://www.mon-club-elec.fr – (c) all rights reserved – GPLv3
    Exception in thread “Animation Thread” java.lang.UnsatisfiedLinkError: C:\Users\Computer\AppData\Local\Temp\jniopencv_imgproc1478655743940818720.dll: %1 ist keine zulässige Win32-Anwendung
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
    at java.lang.Runtime.load0(Runtime.java:770)
    at java.lang.System.load(System.java:1003)
    at com.googlecode.javacpp.Loader.load(Loader.java:337)
    at com.googlecode.javacpp.Loader.load(Loader.java:271)
    at com.googlecode.javacv.cpp.opencv_imgproc.(opencv_imgproc.java:96)
    at monclubelec.javacvPro.OpenCV.gray(Unknown Source)
    at monclubelec.javacvPro.OpenCV.threshold(Unknown Source)
    at monclubelec.javacvPro.OpenCV.threshold(Unknown Source)
    at javacvpro_exemple_blobs.setup(javacvpro_exemple_blobs.java:69)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

    i try a clumsy translation cause i use a german version:

    “C:\Users\Computer\AppData\Local\Temp\jniopencv_imgproc1478655743940818720.dll: %1 ist keine zulässige Win32-Anwendung”

    “…is a not allowed Win32-Application…”

    did i forgett a step in your good explained how-to or did i do sth wrong – in the step where i had to add the .dll

    i checked – i use a 32bit win7 starter and i´ve controlled that i´ve installed the ms. redistr. package x86

    so i´m sad that i´ve no conclusion how i can solve that

    maybe u´ve another idea `

    or what i can check also

    thank you again for responses

  16. Ciao!

    Humm… My Pocessing is 2.0b3… I´ll try the 1.5.1 and tell you if it works, thanks! I will try change the location of libraries folder, maybe it works…

    Ho dimenticato da dire, sono brasiliano… parliamo il portoguese, ma lo spagnolo è molto similare… 😉 Obrigado!

    A presto e grazie tante.

  17. Caro,

    Ho seguito ogni passo, ma quando tento esecutare il codigo, sorge il messagio:
    “More than library is competing for this sketch.
    The import com.google. ….. points to multiple libraries.
    javacpp (part of Processing)
    javacv
    javacvPro
    Extra libraries need to be removed before this sketch can be used ”

    Cosa devvo fare? Qualche idea?

    Grazie e scusa il mio italiano… ho scritto cosi per praticcare un po´. 🙂

    1. Ciao Fabricio,
      witch versin of processing are you using? The 2.03b or the 1.5.1 ?
      The 1.5.1 is the right version.

      Hola Fabricio,
      que version de processing esta usando? la 2.03 o la 1.5.1?
      la correcta es la 1.5.1

  18. sry – me again

    to solve that i just used an example in the examples section from gstreamer – got it running 😉

    thx for you help

    but im still confused how to use the javaCVpro library 🙁 🙁

    here just the example code that works – maybe saves time for others (if i trash your comment section – just delete this post 🙂 )

    /**
    * Getting Started with Capture.
    *
    * GSVideo version by Andres Colubri.
    *
    * Reading and displaying an image from an attached Capture device.
    */
    import codeanticode.gsvideo.*;

    GSCapture cam;

    void setup() {
    size(640, 480);

    String[] cameras = GSCapture.list();

    if (cameras.length == 0)
    {
    println(“There are no cameras available for capture.”);
    exit();
    } else {
    println(“Available cameras:”);
    for (int i = 0; i < cameras.length; i++) {
    println(cameras[i]);
    }
    cam = new GSCapture(this, 640, 480, cameras[0]);
    cam.play();

    /*
    // You can get the resolutions supported by the
    // capture device using the resolutions() method.
    // It must be called after creating the capture
    // object.
    int[][] res = cam.resolutions();
    for (int i = 0; i < res.length; i++) {
    println(res[i][0] + "x" + res[i][1]);
    }
    */

    /*
    // You can also get the framerates supported by the
    // capture device:
    String[] fps = cam.framerates();
    for (int i = 0; i < fps.length; i++) {
    println(fps[i]);
    }
    */
    }
    }

    void draw() {
    if (cam.available() == true) {
    cam.read();
    image(cam, 0, 0);
    // The following does the same, and is faster when just drawing the image
    // without any additional resizing, transformations, or tint.
    //set(0, 0, cam);
    }
    }

    1. Michael,
      i don’t understand very well your problem.
      Are you using the 1.5.1 processing version?
      Are you using the GSVideo library ?
      Did you follow the instruction in the post above?

      If for all the 3 question the answer is yes, which is the problem you have? can you describe it?
      Thanks.

  19. hy – thx for your answer !!!!

    hm im confused now – sry

    so my mistake is that i installed something wrong ?
    (as i said i tried other ways before – might there be some
    errors cause of that ? )

    and the gstreamer solution is not your version you described before?

    tried it an i got the error that the “cam1.start()” doestn exist

    🙁

    http://gsvideo.sourceforge.net/reference/codeanticode/gsvideo/GSCapture.html

    looked up here and found no solution – just that the start() function should exist

    might the error be – that i use processing version 1.51

    thx for answers again 🙂

  20. hy, after a longer search through the i-net i found your site and did it your way

    your example works and a grey window appears

    but when i try this code snippet from:
    http://createdigitalmotion.com/2009/02/processing-tutorials-getting-started-with-video-processing-via-opencv/

    import hypermedia.video.*; // Imports the OpenCV library
    OpenCV opencv; // Creates a new OpenCV Object

    void setup()
    {

    size( 320, 240 );

    opencv = new OpenCV( this ); // Initialises the OpenCV object
    opencv.capture( 320, 240 ); // Opens a video capture stream

    }

    void draw()
    {

    opencv.read(); // Grabs a frame from the camera
    image( opencv.image(), 0, 0 ); // Displays the image in the OpenCV buffer to the screen

    }

    to capture a real picture from my (in built) webcam, this error occurs:

    !!! required library not found : C:\Users\Computer\Documents\Processing\libraries\opencv_01\OpenCV\library\OpenCV.dll: Can’t find dependent libraries
    Verify that the java.library.path property is correctly set and the ‘\path\to\OpenCV\bin’ exists in your system PATH

    Exception in thread “Animation Thread” java.lang.UnsatisfiedLinkError: hypermedia.video.OpenCV.capture(III)V
    at hypermedia.video.OpenCV.capture(Native Method)
    at hypermedia.video.OpenCV.capture(OpenCV.java:945)
    at sketch_oct09b.setup(sketch_oct09b.java:31)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

    after that i tried to put the OpenCV folder in out of the folder above so that just sketchbook/libraries/OpenCV is in there

    but same result

    then i deleted the libraries folder in the sketchbook folder (in which only the opencv folder was)

    cause on your site you only put the folders in the processing/java folder

    but then i got this message which looks predictable

    so – should i copy all the folder in your steps above instead of the java folder in the sketchbook/libraries folder ??

    or in what folder else and how do i chance the paths correct with your programm rapid … somehow

    thx for all answers !!! i would be happy if i can get opencv running on processing someday 🙂

    1. you are using this instruction: import hypermedia.video.*; // Imports the OpenCV library
      This isn’t the instruction to include the JavaCVpro, but another OpenCV library for processing !!!
      The library you are including is: http://ubaa.net/shared/processing/opencv/

      To obtain something working, please, use the GSVideo library for the video.
      Download and install the GSVideo Library here: http://codeanticode.wordpress.com/2011/05/16/gsvideo-09-release/

      Try this little code:

      import com.googlecode.javacpp.annotation.*;
      import com.googlecode.javacpp.*;

      import monclubelec.javacvPro.*;
      import codeanticode.gsvideo.*;

      OpenCV opencv; // Creates a new OpenCV Object
      GSCapture cam1;
      PImage imgSrc;

      void setup()
      {

      size( 320, 240 );
      cam1= new GSCapture(this, 320, 240);
      cam1.start();

      opencv = new OpenCV(this);
      opencv.allocate(320, 240);
      }

      void draw()
      {
      if (cam1.available() == true) {
      cam1.read();
      imgSrc=cam1.get();
      opencv.copy(imgSrc);

      image(opencv.getBuffer(), 0, 0);
      }
      }

      Good luck!

  21. Thank you very much for that, it works perfectly !
    FYI I had to use the version 0.1 of JavaCV, I had dependencies problems with the new one (0.2).

  22. Thankyou so much.

    I was having so many problems setting this up, and this link just fixed them all.

    You are amazing

  23. For first problem you can verify and do again the steps 1 and 2.

    For the second question, the library processing directory is:
    Processing /Mode/java/libraries

    so it is the library directory inside the processing directory.

    I think you can use also the contributed library, but I didn’t try it.

  24. Hi, I followed the instructions to setup OpenCV on Processing but there’s a problem, when I run my program get the following error:

    “UnsatisfiedLinkError %1 is not a valid Win32 application”

    My operating system is Windows 64-bit so I added OpenCV libraries for 64-bit system in the PATH environment variable.
    You know what could be the cause?

    Another question when you write “copy all in the Processing library directory” ,
    You mean contributed libraries? Sorry my ignorance but I’m beginner in Processing. I have Processing 1.5.1

    Thanks in advanced

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.