Wednesday, June 5, 2013

Setting up OpenCV with Eclipse on Windows 7

Prerequisites

  • JDK
  • Apache Ant
  • Python

Installing the JDK

  1. Download the latest JDK
  2. Install the downloaded application.
  3. Follow the installation instructions.

Installing Apache Ant

  1. Download the latest binary distribution of Apache Ant
  2. Extract the downloaded compressed file to a directory (e.g. C:\Users\mizuki\Documents\apache-ant-1.9.1).
  3. Set the following environmental variables to their corresponding directories: JAVA_HOME (e.g. C:\Program Files\Java\jdk1.7.0_21\), ANT_HOME (e.g. C:\Users\mizuki\Documents\apache-ant-1.9.1\), and add %ANT_HOME%/bin to PATH.
  4. Open the command prompt and from the ANT_HOME directory, run ant -f fetch.xml -Ddest=system to get the library dependencies of most Ant tasks. (I am not sure if this step is needed but I just did this based on the Apache Ant installation guide)

Installing Python

  1. Download Python v2.6 or higher. 
  2. Install the downloaded application.
  3. Follow the installation instructions.

Installing OpenCV

  1. Download OpenCV
  2. Extract the downloaded file to a directory (e.g. C:\Users\mizuki\Documents\opencv\).

Installing the Eclipse IDE

  1. Download the latest Eclipse IDE
  2. Extract the downloaded compressed file to a directory (e.g. C:\Users\mizuki\Documents\eclipse-SDK-4.2.2-win32\).

Creating a Simple Java Project

  1. Start the Eclipse IDE and create a new workspace.
  2. Create a new Java project. 
  3. Name the project "HelloCV".
  4. Open Properties of the created project and click on Java Build Path to configure the needed OpenCV libraries. 
     
     
     
     
     
  5. Go to the directory where OpenCV was extracted and find the jar file under build > java
  6. Select the Native library location.
  7. For its location path, the dll file will be under the folder x86 for 32-bit processor and x64 for 64-bit processor still under the build > java folder.
  8. Create a new Java class Main.java with code shown in: OpenCV tutorial. However, use the string "opencv_java245" for the library.


No comments:

Post a Comment