Added a new tutorial "Using OpenCV Java with Eclipse". Removed information related...
authorBaris Evrim Demiroz <b.evrim@gmail.com>
Tue, 27 Aug 2013 19:42:03 +0000 (22:42 +0300)
committerBaris Evrim Demiroz <b.evrim@gmail.com>
Tue, 27 Aug 2013 19:42:03 +0000 (22:42 +0300)
28 files changed:
doc/tutorials/definitions/tocDefinitions.rst
doc/tutorials/introduction/desktop_java/images/eclipse_main_class.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_new_java_prj.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_run.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib2.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib3.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib4.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib5.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib6.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib7.png [deleted file]
doc/tutorials/introduction/desktop_java/images/eclipse_user_lib8.png [deleted file]
doc/tutorials/introduction/desktop_java/java_dev_intro.rst
doc/tutorials/introduction/java_eclipse/images/1-window-preferences.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/10-new-project-created.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/11-the-code.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/2-user-library-new.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/3-library-name.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/4-add-external-jars.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/5-native-library.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/6-external-folder.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/7-user-library-final.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/7_5-new-java-project.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/8-add-library.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/images/9-select-user-lib.png [new file with mode: 0644]
doc/tutorials/introduction/java_eclipse/java_eclipse.rst [new file with mode: 0644]
doc/tutorials/introduction/table_of_content_introduction/images/eclipse-logo.png [new file with mode: 0644]
doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst

index 4695623..d1fb039 100644 (file)
@@ -11,3 +11,4 @@
 .. |Author_EricCh| unicode:: Eric U+0020 Christiansen
 .. |Author_AndreyP| unicode:: Andrey U+0020 Pavlenko
 .. |Author_AlexS| unicode:: Alexander U+0020 Smorkalov
+.. |Author_BarisD| unicode:: Bar U+0131 U+015F U+0020 Evrim U+0020 Demir U+00F6 z
\ No newline at end of file
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_main_class.png b/doc/tutorials/introduction/desktop_java/images/eclipse_main_class.png
deleted file mode 100644 (file)
index 84c152e..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_main_class.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_new_java_prj.png b/doc/tutorials/introduction/desktop_java/images/eclipse_new_java_prj.png
deleted file mode 100644 (file)
index 34e0397..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_new_java_prj.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_run.png b/doc/tutorials/introduction/desktop_java/images/eclipse_run.png
deleted file mode 100644 (file)
index fee34af..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_run.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib.png
deleted file mode 100644 (file)
index 1169452..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib2.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib2.png
deleted file mode 100644 (file)
index 2b9ec5c..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib2.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib3.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib3.png
deleted file mode 100644 (file)
index 4bf83ee..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib3.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib4.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib4.png
deleted file mode 100644 (file)
index c3f3531..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib4.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib5.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib5.png
deleted file mode 100644 (file)
index ed79d92..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib5.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib6.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib6.png
deleted file mode 100644 (file)
index 3a98e38..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib6.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib7.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib7.png
deleted file mode 100644 (file)
index 0194320..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib7.png and /dev/null differ
diff --git a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib8.png b/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib8.png
deleted file mode 100644 (file)
index 5650aa7..0000000
Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib8.png and /dev/null differ
index 1b20bec..d5cb31f 100644 (file)
@@ -7,10 +7,9 @@ Introduction to Java Development
 
 As of OpenCV 2.4.4, OpenCV supports desktop Java development using nearly the same interface as for
 Android development. This guide will help you to create your first Java (or Scala) application using OpenCV.
-We will use either `Eclipse <http://eclipse.org/>`_, `Apache Ant <http://ant.apache.org/>`_ or the
-`Simple Build Tool (SBT) <http://www.scala-sbt.org/>`_ to build the application.
+We will use either `Apache Ant <http://ant.apache.org/>`_ or `Simple Build Tool (SBT) <http://www.scala-sbt.org/>`_ to build the application.
 
-For further reading after this guide, look at the :ref:`Android_Dev_Intro` tutorials.
+If you want to use Eclipse head to :ref:`Java_Eclipse`. For further reading after this guide, look at the :ref:`Android_Dev_Intro` tutorials.
 
 What we'll do in this guide
 ===========================
@@ -19,7 +18,7 @@ In this guide, we will:
 
 * Get OpenCV with desktop Java support
 
-* Create an ``Ant``, ``Eclipse`` or ``SBT`` project
+* Create an ``Ant`` or ``SBT`` project
 
 * Write a simple OpenCV application in Java or Scala
 
@@ -233,97 +232,6 @@ Java sample with Ant
         :alt: run app with Ant
         :align: center
 
-Java project in Eclipse
-=======================
-
-Now let's look at the possiblity of using OpenCV in Java when developing in Eclipse IDE.
-
-* Create a new Eclipse workspace
-* Create a new Java project via :guilabel:`File --> New --> Java Project`
-
-  .. image:: images/eclipse_new_java_prj.png
-     :alt: Eclipse: new Java project
-     :align: center
-
-  Call it say "HelloCV".
-
-* Open :guilabel:`Java Build Path` tab on :guilabel:`Project Properties` dialog
-  and configure additional library (OpenCV) reference (jar and native library location):
-
-  .. image:: images/eclipse_user_lib.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib2.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib3.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib4.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib5.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib6.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib7.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-  |
-
-  .. image:: images/eclipse_user_lib8.png
-     :alt: Eclipse: external JAR
-     :align: center
-
-
-* Add a new Java class (say ``Main``) containing the application entry:
-
-  .. image:: images/eclipse_main_class.png
-     :alt: Eclipse: Main class
-     :align: center
-
-* Put some simple OpenCV calls there, e.g.:
-
-  .. code-block:: java
-
-    import org.opencv.core.Core;
-    import org.opencv.core.CvType;
-    import org.opencv.core.Mat;
-
-    public class Main {
-        public static void main(String[] args) {
-            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
-            Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
-            System.out.println("m = " + m.dump());
-        }
-    }
-
-* Press :guilabel:`Run` button and find the identity matrix content in the Eclipse ``Console`` window.
-
-  .. image:: images/eclipse_run.png
-     :alt: Eclipse: run
-     :align: center
 
 SBT project for Java and Scala
 ==============================
diff --git a/doc/tutorials/introduction/java_eclipse/images/1-window-preferences.png b/doc/tutorials/introduction/java_eclipse/images/1-window-preferences.png
new file mode 100644 (file)
index 0000000..53b3631
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/1-window-preferences.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/10-new-project-created.png b/doc/tutorials/introduction/java_eclipse/images/10-new-project-created.png
new file mode 100644 (file)
index 0000000..63ef65f
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/10-new-project-created.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/11-the-code.png b/doc/tutorials/introduction/java_eclipse/images/11-the-code.png
new file mode 100644 (file)
index 0000000..917e76b
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/11-the-code.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/2-user-library-new.png b/doc/tutorials/introduction/java_eclipse/images/2-user-library-new.png
new file mode 100644 (file)
index 0000000..e65faef
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/2-user-library-new.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/3-library-name.png b/doc/tutorials/introduction/java_eclipse/images/3-library-name.png
new file mode 100644 (file)
index 0000000..bc79cde
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/3-library-name.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/4-add-external-jars.png b/doc/tutorials/introduction/java_eclipse/images/4-add-external-jars.png
new file mode 100644 (file)
index 0000000..14dfa62
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/4-add-external-jars.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/5-native-library.png b/doc/tutorials/introduction/java_eclipse/images/5-native-library.png
new file mode 100644 (file)
index 0000000..a0a4962
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/5-native-library.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/6-external-folder.png b/doc/tutorials/introduction/java_eclipse/images/6-external-folder.png
new file mode 100644 (file)
index 0000000..8ef7b32
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/6-external-folder.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/7-user-library-final.png b/doc/tutorials/introduction/java_eclipse/images/7-user-library-final.png
new file mode 100644 (file)
index 0000000..67b15da
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/7-user-library-final.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/7_5-new-java-project.png b/doc/tutorials/introduction/java_eclipse/images/7_5-new-java-project.png
new file mode 100644 (file)
index 0000000..8aaef5d
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/7_5-new-java-project.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/8-add-library.png b/doc/tutorials/introduction/java_eclipse/images/8-add-library.png
new file mode 100644 (file)
index 0000000..b13c65c
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/8-add-library.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/images/9-select-user-lib.png b/doc/tutorials/introduction/java_eclipse/images/9-select-user-lib.png
new file mode 100644 (file)
index 0000000..1c80e98
Binary files /dev/null and b/doc/tutorials/introduction/java_eclipse/images/9-select-user-lib.png differ
diff --git a/doc/tutorials/introduction/java_eclipse/java_eclipse.rst b/doc/tutorials/introduction/java_eclipse/java_eclipse.rst
new file mode 100644 (file)
index 0000000..bc2247d
--- /dev/null
@@ -0,0 +1,110 @@
+
+.. _Java_Eclipse:
+
+
+Using OpenCV Java with Eclipse
+*********************************************
+
+Since version 2.4.4 `OpenCV supports Java <http://opencv.org/opencv-java-api.html>`_. In this tutorial I will explain how to setup development environment for using OpenCV Java with Eclipse in **Windows**, so you can enjoy the benefits of garbage collected, very refactorable (rename variable, extract method and whatnot) modern language that enables you to write code with less effort and make less mistakes. Here we go.
+
+
+Configuring Eclipse
+===================
+
+First, obtain a fresh release of OpenCV `from download page <http://opencv.org/downloads.html>`_ and extract it under a simple location like ``C:\OpenCV-2.4.6\``. I am using version 2.4.6, but the steps are more or less the same for other versions.
+
+Now, we will define OpenCV as a user library in Eclipse, so we can reuse the configuration for any project. Launch Eclipse and select :guilabel:`Window --> Preferences` from the menu.
+
+.. image:: images/1-window-preferences.png
+     :alt: Eclipse preferences
+     :align: center
+
+Navigate under :guilabel:`Java --> Build Path --> User Libraries` and click :guilabel:`New...`.
+
+.. image:: images/2-user-library-new.png
+     :alt: Creating a new library
+     :align: center
+
+Enter a name, e.g. ``OpenCV-2.4.6``, for your new library.
+
+.. image:: images/3-library-name.png
+     :alt: Naming the new library
+     :align: center
+
+Now select your new user library and click :guilabel:`Add External JARs...`.
+
+.. image:: images/4-add-external-jars.png
+     :alt: Adding external jar
+     :align: center
+
+Browse through ``C:\OpenCV-2.4.6\build\java\`` and select ``opencv-246.jar``. After adding the jar, extend the :guilabel:`opencv-246.jar` and select :guilabel:`Native library location` and press :guilabel:`Edit...`.
+
+.. image:: images/5-native-library.png
+     :alt: Selecting native library location 1
+     :align: center
+
+Select :guilabel:`External Folder...` and browse to select the folder ``C:\OpenCV-2.4.6\build\java\x64``. If you have a 32-bit system you need to select the ``x86`` folder instead of ``x64``.
+
+.. image:: images/6-external-folder.png
+     :alt: Selecting native library location 2
+     :align: center
+
+Your user library configuration should look like this:
+
+.. image:: images/7-user-library-final.png
+     :alt: Selecting native library location 2
+     :align: center
+
+
+Testing the configuration on a new Java project
+=====================================================
+
+Now start creating a new Java project.
+
+.. image:: images/7_5-new-java-project.png
+     :alt: Creating new Java project
+     :align: center
+
+On the :guilabel:`Java Settings` step, under :guilabel:`Libraries` tab, select :guilabel:`Add Library...` and select :guilabel:`OpenCV-2.4.6`, then click :guilabel:`Finish`.
+
+.. image:: images/8-add-library.png
+     :alt: Adding user defined library 1
+     :align: center
+
+.. image:: images/9-select-user-lib.png
+     :alt: Adding user defined library 2
+     :align: center
+
+
+Libraries should look like this:
+
+.. image:: images/10-new-project-created.png
+     :alt: Adding user defined library
+     :align: center
+
+
+Now you have created and configured a new Java project it is time to test it. Create a new java file. Here is a starter code for your convenience:
+
+.. code-block:: java
+
+   import org.opencv.core.Core;
+   import org.opencv.core.CvType;
+   import org.opencv.core.Mat;
+
+   public class Hello
+   {
+      public static void main( String[] args )
+      {
+         System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
+         Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
+         System.out.println( "mat = " + mat.dump() );
+      }
+   }
+
+When you run the code you should see 3x3 identity matrix as output.
+
+.. image:: images/11-the-code.png
+     :alt: Adding user defined library
+     :align: center
+
+That is it, whenever you start a new project just add the OpenCV user library that you have defined to your project and you are good to go. Enjoy your powerful, less painful development environment :)
\ No newline at end of file
diff --git a/doc/tutorials/introduction/table_of_content_introduction/images/eclipse-logo.png b/doc/tutorials/introduction/table_of_content_introduction/images/eclipse-logo.png
new file mode 100644 (file)
index 0000000..64ec01c
Binary files /dev/null and b/doc/tutorials/introduction/table_of_content_introduction/images/eclipse-logo.png differ
index 2238b87..ee8dd67 100644 (file)
@@ -138,6 +138,24 @@ world of the OpenCV.
                         :height: 90pt
                         :width:  90pt
 
+  .. tabularcolumns:: m{100pt} m{300pt}
+  .. cssclass:: toctableopencv
+
+  ================ =================================================
+  |EclipseLogo|    **Title:** :ref:`Java_Eclipse`
+
+                   *Compatibility:* > OpenCV 2.4.4
+
+                   *Author:* |Author_BarisD|
+
+                   A tutorial on how to use OpenCV Java with Eclipse.
+
+  ================ =================================================
+
+     .. |EclipseLogo| image:: images/eclipse-logo.png
+                        :height: 90pt
+                        :width:  90pt
+
 * **Android**
 
   .. tabularcolumns:: m{100pt} m{300pt}
@@ -295,6 +313,7 @@ world of the OpenCV.
    ../windows_visual_studio_Opencv/windows_visual_studio_Opencv
    ../windows_visual_studio_image_watch/windows_visual_studio_image_watch
    ../desktop_java/java_dev_intro
+   ../java_eclipse/java_eclipse
    ../android_binary_package/android_dev_intro
    ../android_binary_package/O4A_SDK
    ../android_binary_package/dev_with_OCV_on_Android