Pages

OpenCV-JavaCV : eclipse project configuration windows 7

NOTE: A Easier and Simpler version of the installation step is available !!  Check the latest ( Jan , 2017) article.

---

Eclipse (windows 7) project setup for JNA wrapper of OpenCV : JavaCV - getting started.

OpenCV (Open Source Computer Vision Library) is library of programming functions for real time computer vision.  JavaCV provides wrappers to commonly used libraries for OpenCV and few others.

Download the Essentials :


                  Microsoft Visual C++ 2010 Redistributable Package (x86)
                  Microsoft Visual C++ 2010 Redistributable Package (x64) (If your system is 64 bit)

Installation Steps:

1) Install Microsoft Visual C++ Redistributable Packages. DON'T install x86-bit version if you have x64-bit computer.
2) Extract OpenCV-**-win-superpack.exe inside the root directory C:\
3) Configure path: Add the following environment variables in system path (Make Sure that the folder path is correct)
64-bit version of the JDK:
           C:\opencv\build\common\tbb\intel64\vc10\;C:\opencv\build\x64\vc10\bin\;
32-bit version of the JDK:
           C:\opencv\build\common\tbb\ia32\vc10\;C:\opencv\build\x86\vc10\bin\;

4) Extract the javacv-**-bin.zip and add the .jar files (match with the version of your system) to build path of eclipse project.
Eclipse Project Structure :

Creating javacv eclipse project:

  1. If the above installations are correctly done and environment variables are set properly... 
  2. Create a java project on eclipse as usual and don't forget to add the .jar to build path (described in step 4 above)...
  3. Goto here  for test code
  4. Run the project..
  5. Everything should work fine..

Environment Variable configuration:

Right Click on My Computer -> choose properties -> choose Advance System Settings -> choose Environment Variables and follow following steps 1,2,3 as in image
OpenCV/JavaCV resources :

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

Don't forget to see posts about JavaCV and Image Processing here : 

32 comments:

  1. Hello, very gut post. I have a problem witch de jar library becouse the code ist not recognition for the library import..., do you help me? Thank you for all!

    ReplyDelete
  2. hello, none of the import is working or what ? could you please confirm this? You can paste your code here.. and after that i could suggest you.

    ReplyDelete
  3. C:\Users\Junaid\AppData\Local\Temp\jniopencv_core7274896174049413705.dll: Can't find dependent libraries

    ReplyDelete
    Replies
    1. This might be due to your mistake in class path setting. Make sure that you have followed the steps.

      Delete
  4. It worked perfectly. Thanks.

    ReplyDelete
  5. Hello, thanks for your post.

    I still have a question for the third etap.
    I am here : http://imageshack.us/photo/my-images/31/variables.jpg/

    When I click on "New", what are the names of the variables ?
    Can someone printscreen this part and post it ?

    Thank you !

    ReplyDelete
    Replies
    1. I have updated my post with screenshot and steps to configure environment variables.

      Delete
    2. Where is the screenshot for the environment variables?

      Delete
    3. I have fixed the snapshot appearance.

      Delete
  6. I was looking for a good Java based open source and supported alternative to JMF for webcam captures in both Windows and Linux. This works like a charm! Thank you :)

    ReplyDelete
  7. Hello,

    Thank you for this good tutorial. I think I did all steps and I get this output:

    ------Console

    JavaCV build timestamp 201202181244
    Copyright (C) 2009-2012 Samuel Audet
    Project site: http://code.google.com/p/javacv/

    Licensed under the GNU General Public License version 2 (GPLv2) with Classpath exception.
    Please refer to LICENSE.txt or http://www.gnu.org/licenses/ for details.

    -------

    But I cannot find jpg file. I don't understand.

    cagdas

    ReplyDelete
  8. i installed opencv 2.40 and tried to configure on eclipse.....i ran the sample program:
    import static com.googlecode.javacv.cpp.opencv_core.*;
    import static com.googlecode.javacv.cpp.opencv_imgproc.*;
    import static com.googlecode.javacv.cpp.opencv_highgui.*;

    public class ssss {
    public static void smooth(String filename) {
    IplImage image = cvLoadImage(filename);
    if (image != null) {
    cvSmooth(image, image, CV_GAUSSIAN, 3);
    cvSaveImage(filename, image);
    cvReleaseImage(image);
    }
    }
    }


    it will run without errors, but will just disply this in console:
    Warning: Could not load class bin.ssss: java.lang.NoClassDefFoundError: bin/ssss (wrong name: ssss)

    ReplyDelete
    Replies
    1. Hi Umanga,

      Glad to hear that you configured and ran the program without errors.
      The message you are mentioning is a WARNING about your class ssss itself. It looks like your class is not compiled (AT THAT TIME) and eclipse could not find it in bin folder of project. So, it is displaying this message.

      In short - this message has noting to do with javacv. Its just a warning not an error.

      Thanks.

      Delete
  9. Hi,
    I get the following error even if I followed all the steps
    Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: C:\Users\Mariella\AppData\Local\Temp\jniopencv_core4949821359325956938.dll: %1 non è un'applicazione di Win32 valida (It isn't a valid Win32 application)
    what can i do??
    Thank you

    ReplyDelete
    Replies
    1. Hi bttmll,
      I also had the same problem but as specified here http://code.google.com/p/javacv/wiki/Windows7AndOpenCV you have to use opencv 2.4.0. I've just tried the solution and it works.

      regards,
      genia

      Delete
    2. Yes Like Genia said, I try to with the superpack, and version 2.4.1 (the newer) and didnt work, I read Genia comment and I try with version 2.4.0... and guess what :P!? It WORKS!!! Thanks Ganesh and Genia ! =D!! great blog!

      Delete
  10. For your information, there is nothing called "super pack" in 2.4 !! It is just OpenCV - 2.4.0.exe. Is this is what you are referring to?

    ReplyDelete
    Replies
    1. Hi, At the time when I wrote this article for the first time, there was version 2.3 which was named as "OpenCV-2.3.0-win-superpack.exe" : http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/

      Few weeks earlier, I had revised the version info but forgot to remove the text "SuperPack"

      Thanks for noticing.

      Delete
  11. Hi,

    Thanks a lot for the info. Now, I need another help please. From where did you learn JavaCV? Can you please tell us some learning materials? From the beginning to advance? Please help.

    ReplyDelete
    Replies
    1. Hi,

      I have a list of useful links bookmarked in my browser that i used when i was studying about JavaCV. I will post them in a new article soon.

      Thanks for suggestion.

      Delete
    2. That's great to hear. OK, I am waiting for it :). It is hard to find 100% java based resources! If you do so, that would be great!

      Delete
  12. I had the UnsatisfiedLinkError and the problem was that JavaCV required OpenCV 2.4.2 and mine was OpenCV 2.4.0 which I downloaded from this post.

    So, here is a link for OpenCV 2.4.2: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.2/OpenCV-2.4.2.exe/download?use_mirror=ignum

    The test code is not working, probably because of mine camera drivers but i tested libraries with code from other posts and it worked.

    ReplyDelete
  13. @Ganesh
    Thanks a lot u made my work very easy. All codes and setup are working fine.
    Doing Good Job Keep it up.

    Thanks
    Pratik

    ReplyDelete
  14. Hi Ganesh. Thanks for the tutorial. I am building a rather simple camera-accessing application NOT for my computer but for other person's.

    Do I have to install all these stuff to their computer? Is there a simpler way to access the camera via Java? So I can just send my friend the .jar file or the .exe file and that would be all.

    ReplyDelete
  15. I downloaded and extracted opencv 2.4.6.0

    However I could not located following patch - C:\opencv\build\common\tbb\ia32\vc10;

    There is no common folder itself. Can anyone tell me if it is correct or I am missing something.

    Thanks

    ReplyDelete
    Replies
    1. Even i did not get the folder named common when i downloaded the openCV 2.4.7. Could you please confirm about this??

      Delete
    2. I got the files and folders correctly. Version 2.4.0 from the link at the top of this page.

      Delete

Your Comment and Question will help to make this blog better...