diff --git a/doc/tutorials/definitions/tocDefinitions.rst b/doc/tutorials/definitions/tocDefinitions.rst index 4695623cc..d1fb03970 100644 --- a/doc/tutorials/definitions/tocDefinitions.rst +++ b/doc/tutorials/definitions/tocDefinitions.rst @@ -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 index 84c152e6d..000000000 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 index 34e03972e..000000000 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 index fee34afa1..000000000 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 index 11694526a..000000000 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 index 2b9ec5c3c..000000000 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 index 4bf83ee03..000000000 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 index c3f353155..000000000 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 index ed79d92d4..000000000 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 index 3a98e38b1..000000000 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 index 019432016..000000000 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 index 5650aa79a..000000000 Binary files a/doc/tutorials/introduction/desktop_java/images/eclipse_user_lib8.png and /dev/null differ diff --git a/doc/tutorials/introduction/desktop_java/java_dev_intro.rst b/doc/tutorials/introduction/desktop_java/java_dev_intro.rst index 1b20bec25..d5cb31f89 100644 --- a/doc/tutorials/introduction/desktop_java/java_dev_intro.rst +++ b/doc/tutorials/introduction/desktop_java/java_dev_intro.rst @@ -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 `_, `Apache Ant `_ or the -`Simple Build Tool (SBT) `_ to build the application. +We will use either `Apache Ant `_ or `Simple Build Tool (SBT) `_ 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 index 000000000..53b3631fd 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 index 000000000..63ef65f14 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 index 000000000..917e76b8e 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 index 000000000..e65faef2d 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 index 000000000..bc79cde80 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 index 000000000..14dfa6247 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 index 000000000..a0a4962e9 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 index 000000000..8ef7b32a3 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 index 000000000..67b15daba 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 index 000000000..8aaef5d4e 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 index 000000000..b13c65c7a 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 index 000000000..1c80e9821 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 index 000000000..bc2247da9 --- /dev/null +++ b/doc/tutorials/introduction/java_eclipse/java_eclipse.rst @@ -0,0 +1,110 @@ + +.. _Java_Eclipse: + + +Using OpenCV Java with Eclipse +********************************************* + +Since version 2.4.4 `OpenCV supports Java `_. 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 `_ 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 index 000000000..64ec01c25 Binary files /dev/null and b/doc/tutorials/introduction/table_of_content_introduction/images/eclipse-logo.png differ diff --git a/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst b/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst index 2238b8787..ee8dd67ef 100644 --- a/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst +++ b/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst @@ -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