Skip to content

Commit edb15de

Browse files
author
Andrey Pavlenko
committed
review feed-back considered
1 parent a8c2fc6 commit edb15de

File tree

5 files changed

+36
-1530
lines changed

5 files changed

+36
-1530
lines changed

doc/tutorials/definitions/tocDefinitions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
.. |Author_EduardF| unicode:: Eduard U+0020 Feicho
1010
.. |Author_AlexB| unicode:: Alexandre U+0020 Benoit
1111
.. |Author_EricCh| unicode:: Eric U+0020 Christiansen
12+
.. |Author_AndreyP| unicode:: Andrey U+0020 Pavlenko

doc/tutorials/introduction/desktop_java/java_dev_intro.rst

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ We will use either `Eclipse <http://eclipse.org/>`_, `Apache Ant <http://ant.apa
1313
`Simple Build Tool (SBT) <http://www.scala-sbt.org/>`_ to build the application.
1414

1515
For further reading after this guide, look at the :ref:`Android_Dev_Intro` tutorials.
16-
The interfaces for desktop Java and Android are nearly identical. You may also consult the
17-
`Java wiki page <http://code.opencv.org/projects/opencv/wiki/Java_API_howto>`_.
1816

1917
What we'll do in this guide
2018
***************************
@@ -39,15 +37,13 @@ The most simple way to get it is downloading the appropriate package of **versio
3937

4038
.. note:: Windows users can find the prebuilt files needed for Java development in the
4139
:file:`opencv/build/java/` folder inside the package.
42-
Other OSes users (and Windows ones optionally) can build OpenCV from sources locally.
40+
For other OSes it's required to build OpenCV from sources.
4341

44-
Another option to get OpenCV sources is to clone OpenCV git repository,
45-
either the primary one at ``git://code.opencv.org/opencv.git`` or
46-
its `Github mirror <https://github.com/Itseez/opencv/>`_.
47-
Be aware that Java is currently only supported on the ``2.4`` git branch and not yet merged to the ``master``.
42+
Another option to get OpenCV sources is to clone `OpenCV git repository
43+
<https://github.com/Itseez/opencv/>`_.
4844
In order to build OpenCV with Java bindings you need :abbr:`JDK (Java Development Kit)`
4945
(we recommend `Oracle/Sun JDK 6 or 7 <http://www.oracle.com/technetwork/java/javase/downloads/>`_),
50-
`Apache Ant <http://ant.apache.org/>`_ and ``Python`` v2.6 or higher to be installed.
46+
`Apache Ant <http://ant.apache.org/>`_ and `Python` v2.6 or higher to be installed.
5147

5248
Build OpenCV
5349
############
@@ -110,7 +106,7 @@ Create a simple Java sample and an Ant build file for it
110106
.. note::
111107
The described sample is provided with OpenCV library in the :file:`opencv/samples/java/ant` folder.
112108

113-
* Create a folder where you'll create this sample application.
109+
* Create a folder where you'll develop this sample application.
114110

115111
* In this folder create an XML file with the following content using any text editor:
116112

@@ -180,7 +176,7 @@ Create a simple Java sample and an Ant build file for it
180176
See `Ant documentation <http://ant.apache.org/manual/>`_ for detailed description
181177
of its build file format.
182178

183-
* Create an :file:`src` folder nect to the :file:`build.xml` file and a :file:`SimpleSample.java` file in it.
179+
* Create an :file:`src` folder next to the :file:`build.xml` file and a :file:`SimpleSample.java` file in it.
184180

185181
* Put the following Java code into the :file:`SimpleSample.java` file:
186182
.. code-block:: java
@@ -205,7 +201,7 @@ Create a simple Java sample and an Ant build file for it
205201
206202
}
207203
208-
* run the following command in console in the folder containing :file:`build.xml`:
204+
* Run the following command in console in the folder containing :file:`build.xml`:
209205
.. code-block:: bash
210206
211207
ant -DocvJarDir=path/to/dir/containing/opencv-244.jar -DocvLibDir=path/to/dir/containing/opencv_java244/native/library
@@ -226,6 +222,8 @@ Create a simple Java sample and an Ant build file for it
226222
Create a simple Java project in Eclipse
227223
***************************************
228224

225+
Now let's look at the possiblity of using OpenCV in Java when developing in Eclipse IDE.
226+
229227
* Create a new Eclipse workspace
230228
* Create a new Java project via :guilabel:`File --> New --> Java Project`
231229

@@ -292,7 +290,7 @@ Create a simple Java project in Eclipse
292290
:alt: Eclipse: Main class
293291
:align: center
294292

295-
* Put a simple OpenCV calls there, e.g.:
293+
* Put some simple OpenCV calls there, e.g.:
296294
.. code-block:: java
297295
298296
import org.opencv.core.CvType;
@@ -306,7 +304,7 @@ Create a simple Java project in Eclipse
306304
}
307305
}
308306
309-
* Press :guilabel:`Run` button and see the identity matrix content in the Eclipse ``Console`` window.
307+
* Press :guilabel:`Run` button and find the identity matrix content in the Eclipse ``Console`` window.
310308

311309
.. image:: images/eclipse_run.png
312310
:alt: Eclipse: run
@@ -320,7 +318,7 @@ those unfamiliar with this build tool. We're using SBT because it is particularl
320318

321319
First, download and install `SBT <http://www.scala-sbt.org/>`_ using the instructions on its `web site <http://www.scala-sbt.org/>`_.
322320

323-
Next, navigate to a new directory where you'd like the application source to live (outside opencv).
321+
Next, navigate to a new directory where you'd like the application source to live (outside :file:`opencv` dir).
324322
Let's call it "JavaSample" and create a directory for it:
325323

326324
.. code-block:: bash
@@ -384,11 +382,11 @@ You should see something like this:
384382
:alt: SBT output
385383
:align: center
386384

387-
You can now import the SBT project using :guilabel:`Import ... -> Existing projects into workspace` from Eclipse.
385+
You can now import the SBT project to Eclipse using :guilabel:`Import ... -> Existing projects into workspace`.
388386
Whether you actually do this is optional for the guide;
389-
we'll be using SBT to build the project, so if you choose to use Eclipse it will just be as a text editor.
387+
we'll be using SBT to build the project, so if you choose to use Eclipse it will just serve as a text editor.
390388

391-
To test everything is working, create a simple "Hello OpenCV" application.
389+
To test that everything is working, create a simple "Hello OpenCV" application.
392390
Do this by creating a file :file:`src/main/java/HelloOpenCV.java` with the following contents:
393391

394392
.. code-block:: java
@@ -432,10 +430,11 @@ Next, create the directory src/main/resources and download this Lena image into
432430
:alt: Lena
433431
:align: center
434432

435-
Make sure it's called :file:`"lena.bmp"`.
433+
Make sure it's called :file:`"lena.png"`.
436434
Items in the resources directory are available to the Java application at runtime.
437435

438-
Next, copy :file:`lbpcascade_frontalface.xml` into the resources directory:
436+
Next, copy :file:`lbpcascade_frontalface.xml` from :file:`opencv/data/` into the :file:`resources`
437+
directory:
439438

440439
.. code-block:: bash
441440
@@ -465,7 +464,7 @@ Now modify src/main/java/HelloOpenCV.java so it contains the following Java code
465464
// Create a face detector from the cascade file in the resources
466465
// directory.
467466
CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());
468-
Mat image = Highgui.imread(getClass().getResource("/lena.bmp").getPath());
467+
Mat image = Highgui.imread(getClass().getResource("/lena.png").getPath());
469468
470469
// Detect faces in the image.
471470
// MatOfRect is a special container class for Rect.
@@ -518,3 +517,7 @@ It should also write the following image to :file:`faceDetection.png`:
518517
.. image:: images/faceDetection.png
519518
:alt: Detected face
520519
:align: center
520+
521+
You're done!
522+
Now you have a sample Java application working with OpenCV, so you can start the work on your own.
523+
We wish you good luck and many years of joyful life!

doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Here you can read tutorials about how to set up your computer to work with the O
111111

112112
*Compatibility:* > OpenCV 2.4.4
113113

114-
*Author:* |Author_EricCh|
114+
*Authors:* |Author_EricCh| and |Author_AndreyP|
115115

116116
Explains how to build and run a simple desktop Java application using Eclipse, Ant or the Simple Build Tool (SBT).
117117

samples/java/sbt/README

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
A demo of the Java wrapper for OpenCV with two examples: 1) feature detection and matching and 2) face detection. The examples are coded in Scala and Java. Anyone familiar with Java should be able to read the Scala examples. Please feel free to contribute code examples in Scala or Java, or any JVM language.
1+
A demo of the Java wrapper for OpenCV with two examples:
2+
1) feature detection and matching and
3+
2) face detection.
4+
The examples are coded in Scala and Java.
5+
Anyone familiar with Java should be able to read the Scala examples.
6+
Please feel free to contribute code examples in Scala or Java, or any JVM language.
27

38
To run the examples:
4-
1) Install OpenCV and copy the OpenCV jar to lib/. This jar must match the native libraries installed in your system. If this isn't the case, you may get a java.lang.UnsatisfiedLinkError at runtime.
5-
6-
3) Go to the root directory and type "sbt/sbt run". This should generate images in your current directory.
9+
1) Install OpenCV and copy the OpenCV jar to lib/.
10+
This jar must match the native libraries installed in your system.
11+
If this isn't the case, you may get a java.lang.UnsatisfiedLinkError at runtime.
12+
2) Go to the root directory and type "sbt/sbt run".
13+
This should generate images in your current directory.

0 commit comments

Comments
 (0)