Doxygen tutorials: cpp done

This commit is contained in:
Maksim Shabunin
2014-11-28 16:21:28 +03:00
parent c5536534d8
commit 36a04ef8de
92 changed files with 2142 additions and 3691 deletions

View File

@@ -107,19 +107,19 @@ Manual OpenCV4Android SDK setup
### Get the OpenCV4Android SDK
1. Go to the [OpenCV download page on
-# Go to the [OpenCV download page on
SourceForge](http://sourceforge.net/projects/opencvlibrary/files/opencv-android/) and download
the latest available version. Currently it's [OpenCV-2.4.9-android-sdk.zip](http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.9/OpenCV-2.4.9-android-sdk.zip/download).
2. Create a new folder for Android with OpenCV development. For this tutorial we have unpacked
-# Create a new folder for Android with OpenCV development. For this tutorial we have unpacked
OpenCV SDK to the `C:\Work\OpenCV4Android\` directory.
@note Better to use a path without spaces in it. Otherwise you may have problems with ndk-build.
3. Unpack the SDK archive into the chosen directory.
-# Unpack the SDK archive into the chosen directory.
You can unpack it using any popular archiver (e.g with 7-Zip_):
You can unpack it using any popular archiver (e.g with 7-Zip):
![image](images/android_package_7zip.png)
![](images/android_package_7zip.png)
On Unix you can use the following command:
@code{.bash}
@@ -128,15 +128,15 @@ Manual OpenCV4Android SDK setup
### Import OpenCV library and samples to the Eclipse
1. Start Eclipse and choose your workspace location.
-# Start Eclipse and choose your workspace location.
We recommend to start working with OpenCV for Android from a new clean workspace. A new Eclipse
workspace can for example be created in the folder where you have unpacked OpenCV4Android SDK
package:
![image](images/eclipse_1_choose_workspace.png)
![](images/eclipse_1_choose_workspace.png)
2. Import OpenCV library and samples into workspace.
-# Import OpenCV library and samples into workspace.
OpenCV library is packed as a ready-for-use [Android Library
Project](http://developer.android.com/guide/developing/projects/index.html#LibraryProjects). You
@@ -146,33 +146,34 @@ Manual OpenCV4Android SDK setup
already references OpenCV library. Follow the steps below to import OpenCV and samples into the
workspace:
- Right click on the Package Explorer window and choose Import... option from the context
menu:
![](images/eclipse_5_import_command.png)
- In the main panel select General --\> Existing Projects into Workspace and press Next
button:
![](images/eclipse_6_import_existing_projects.png)
- In the Select root directory field locate your OpenCV package folder. Eclipse should
automatically locate OpenCV library and samples:
![](images/eclipse_7_select_projects.png)
- Click Finish button to complete the import operation.
@note OpenCV samples are indeed **dependent** on OpenCV library project so don't forget to import it to your workspace as well.
- Right click on the Package Explorer window and choose Import... option from the context
menu:
![image](images/eclipse_5_import_command.png)
- In the main panel select General --\> Existing Projects into Workspace and press Next
button:
![image](images/eclipse_6_import_existing_projects.png)
- In the Select root directory field locate your OpenCV package folder. Eclipse should
automatically locate OpenCV library and samples:
![image](images/eclipse_7_select_projects.png)
- Click Finish button to complete the import operation.
After clicking Finish button Eclipse will load all selected projects into workspace, and you
have to wait some time while it is building OpenCV samples. Just give a minute to Eclipse to
complete initialization.
![image](images/eclipse_cdt_cfg4.png)
![](images/eclipse_cdt_cfg4.png)
Once Eclipse completes build you will have the clean workspace without any build errors:
![image](images/eclipse_10_crystal_clean.png)
![](images/eclipse_10_crystal_clean.png)
@anchor tutorial_O4A_SDK_samples
### Running OpenCV Samples
@@ -205,7 +206,7 @@ Well, running samples from Eclipse is very simple:
@note Android Emulator can take several minutes to start. So, please, be patient. \* On the first
run Eclipse will ask you about the running mode for your application:
![image](images/eclipse_11_run_as.png)
![](images/eclipse_11_run_as.png)
- Select the Android Application option and click OK button. Eclipse will install and run the
sample.
@@ -214,7 +215,7 @@ Well, running samples from Eclipse is very simple:
Manager](https://docs.google.com/a/itseez.com/presentation/d/1EO_1kijgBg_BsjNp2ymk-aarg-0K279_1VZRcPplSuk/present#slide=id.p)
package installed. In this case you will see the following message:
![image](images/android_emulator_opencv_manager_fail.png)
![](images/android_emulator_opencv_manager_fail.png)
To get rid of the message you will need to install OpenCV Manager and the appropriate
OpenCV binary pack. Simply tap Yes if you have *Google Play Market* installed on your
@@ -226,12 +227,15 @@ Well, running samples from Eclipse is very simple:
@code{.sh}
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.9_Manager_2.18_armv7a-neon.apk
@endcode
@note armeabi, armv7a-neon, arm7a-neon-android8, mips and x86 stand for platform targets:
- armeabi is for ARM v5 and ARM v6 architectures with Android API 8+,
- armv7a-neon is for NEON-optimized ARM v7 with Android API 9+,
- arm7a-neon-android8 is for NEON-optimized ARM v7 with Android API 8,
- mips is for MIPS architecture with Android API 9+,
- x86 is for Intel x86 CPUs with Android API 9+.
@note
If using hardware device for testing/debugging, run the following command to learn its CPU
architecture:
@code{.sh}
@@ -241,6 +245,7 @@ Well, running samples from Eclipse is very simple:
Click Edit in the context menu of the selected device. In the window, which then pop-ups, find
the CPU field.
@note
You may also see section `Manager Selection` for details.
When done, you will be able to run OpenCV samples on your device/emulator seamlessly.
@@ -248,7 +253,7 @@ Well, running samples from Eclipse is very simple:
- Here is Sample - image-manipulations sample, running on top of stock camera-preview of the
emulator.
![image](images/emulator_canny.png)
![](images/emulator_canny.png)
What's next
-----------

View File

@@ -19,16 +19,16 @@ Development for Android significantly differs from development for other platfor
starting programming for Android we recommend you make sure that you are familiar with the following
key topis:
1. [Java](http://en.wikipedia.org/wiki/Java_(programming_language)) programming language that is
-# [Java](http://en.wikipedia.org/wiki/Java_(programming_language)) programming language that is
the primary development technology for Android OS. Also, you can find [Oracle docs on
Java](http://docs.oracle.com/javase/) useful.
2. [Java Native Interface (JNI)](http://en.wikipedia.org/wiki/Java_Native_Interface) that is a
-# [Java Native Interface (JNI)](http://en.wikipedia.org/wiki/Java_Native_Interface) that is a
technology of running native code in Java virtual machine. Also, you can find [Oracle docs on
JNI](http://docs.oracle.com/javase/7/docs/technotes/guides/jni/) useful.
3. [Android
-# [Android
Activity](http://developer.android.com/training/basics/activity-lifecycle/starting.html) and its
lifecycle, that is an essential Android API class.
4. OpenCV development will certainly require some knowlege of the [Android
-# OpenCV development will certainly require some knowlege of the [Android
Camera](http://developer.android.com/guide/topics/media/camera.html) specifics.
Quick environment setup for Android development
@@ -44,14 +44,15 @@ environment setup automatically and you can skip the rest of the guide.
If you are a beginner in Android development then we also recommend you to start with TADP.
@note *NVIDIA*'s Tegra Android Development Pack includes some special features for *NVIDIA*s Tegra
platform_ but its use is not limited to *Tegra* devices only. \* You need at least *1.6 Gb* free
@note *NVIDIA*'s Tegra Android Development Pack includes some special features for *NVIDIA*s [Tegra
platform](http://www.nvidia.com/object/tegra-3-processor.html)
but its use is not limited to *Tegra* devices only. \* You need at least *1.6 Gb* free
disk space for the install.
- TADP will download Android SDK platforms and Android NDK from Google's server, so Internet
connection is required for the installation.
- TADP may ask you to flash your development kit at the end of installation process. Just skip
this step if you have no Tegra Development Kit_.
this step if you have no [Tegra Development Kit](http://developer.nvidia.com/mobile/tegra-hardware-sales-inquiries).
- (UNIX) TADP will ask you for *root* in the middle of installation, so you need to be a member of
*sudo* group.
@@ -62,7 +63,7 @@ Manual environment setup for Android development
You need the following software to be installed in order to develop for Android in Java:
1. **Sun JDK 6** (Sun JDK 7 is also possible)
-# **Sun JDK 6** (Sun JDK 7 is also possible)
Visit [Java SE Downloads page](http://www.oracle.com/technetwork/java/javase/downloads/) and
download an installer for your OS.
@@ -71,30 +72,32 @@ You need the following software to be installed in order to develop for Android
guide](http://source.android.com/source/initializing.html#installing-the-jdk) for Ubuntu and Mac
OS (only JDK sections are applicable for OpenCV)
@note OpenJDK is not suitable for Android development, since Android SDK supports only Sun JDK. If you use Ubuntu, after installation of Sun JDK you should run the following command to set Sun java environment:
@code{.bash}
sudo update-java-alternatives --set java-6-sun
@endcode
1. **Android SDK**
@note OpenJDK is not suitable for Android development, since Android SDK supports only Sun JDK. If you use Ubuntu, after installation of Sun JDK you should run the following command to set Sun java environment:
@code{.bash}
sudo update-java-alternatives --set java-6-sun
@endcode
-# **Android SDK**
Get the latest Android SDK from <http://developer.android.com/sdk/index.html>
Here is Google's [install guide](http://developer.android.com/sdk/installing.html) for the SDK.
@note You can choose downloading **ADT Bundle package** that in addition to Android SDK Tools
includes Eclipse + ADT + NDK/CDT plugins, Android Platform-tools, the latest Android platform and
the latest Android system image for the emulator - this is the best choice for those who is setting
up Android development environment the first time!
@note You can choose downloading **ADT Bundle package** that in addition to Android SDK Tools
includes Eclipse + ADT + NDK/CDT plugins, Android Platform-tools, the latest Android platform and
the latest Android system image for the emulator - this is the best choice for those who is setting
up Android development environment the first time!
@note If you are running x64 version of Ubuntu Linux, then you need ia32 shared libraries for use on amd64 and ia64 systems to be installed. You can install them with the following command:
@code{.bash}
sudo apt-get install ia32-libs
@endcode
For Red Hat based systems the following command might be helpful:
@code{.bash}
sudo yum install libXtst.i386
@endcode
1. **Android SDK components**
@note If you are running x64 version of Ubuntu Linux, then you need ia32 shared libraries for use on amd64 and ia64 systems to be installed. You can install them with the following command:
@code{.bash}
sudo apt-get install ia32-libs
@endcode
For Red Hat based systems the following command might be helpful:
@code{.bash}
sudo yum install libXtst.i386
@endcode
-# **Android SDK components**
You need the following SDK components to be installed:
@@ -110,13 +113,13 @@ up Android development environment the first time!
successful compilation the **target** platform should be set to Android 3.0 (API 11) or
higher. It will not prevent them from running on Android 2.2.
![image](images/android_sdk_and_avd_manager.png)
![](images/android_sdk_and_avd_manager.png)
See [Adding Platforms and
Packages](http://developer.android.com/sdk/installing/adding-packages.html) for help with
installing/updating SDK components.
2. **Eclipse IDE**
-# **Eclipse IDE**
Check the [Android SDK System Requirements](http://developer.android.com/sdk/requirements.html)
document for a list of Eclipse versions that are compatible with the Android SDK. For OpenCV
@@ -126,7 +129,7 @@ up Android development environment the first time!
If you have no Eclipse installed, you can get it from the [official
site](http://www.eclipse.org/downloads/).
3. **ADT plugin for Eclipse**
-# **ADT plugin for Eclipse**
These instructions are copied from [Android Developers
site](http://developer.android.com/sdk/installing/installing-adt.html), check it out in case of
@@ -135,33 +138,34 @@ up Android development environment the first time!
Assuming that you have Eclipse IDE installed, as described above, follow these steps to download
and install the ADT plugin:
1. Start Eclipse, then select Help --\> Install New Software...
2. Click Add (in the top-right corner).
3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following
URL for the Location:
-# Start Eclipse, then select Help --\> Install New Software...
-# Click Add (in the top-right corner).
-# In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following
URL for the Location: <https://dl-ssl.google.com/android/eclipse/>
<https://dl-ssl.google.com/android/eclipse/>
-# Click OK
4. Click OK
@note If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
@note If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
1. In the Available Software dialog, select the checkbox next to Developer Tools and click
Next.
2. In the next window, you'll see a list of the tools to be downloaded. Click Next.
-# In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
@note If you also plan to develop native C++ code with Android NDK don't forget to enable NDK Plugins installations as well.
![image](images/eclipse_inst_adt.png)
-# In the next window, you'll see a list of the tools to be downloaded. Click Next.
1. Read and accept the license agreements, then click Finish.
@note If you also plan to develop native C++ code with Android NDK don't forget to enable NDK Plugins installations as well.
@note If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
1. When the installation completes, restart Eclipse.
![](images/eclipse_inst_adt.png)
-# Read and accept the license agreements, then click Finish.
@note If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
-# When the installation completes, restart Eclipse.
### Native development in C++
You need the following software to be installed in order to develop for Android in C++:
1. **Android NDK**
-# **Android NDK**
To compile C++ code for Android platform you need Android Native Development Kit (*NDK*).
@@ -170,17 +174,18 @@ You need the following software to be installed in order to develop for Android
extract the archive to some folder on your computer. Here are [installation
instructions](http://developer.android.com/tools/sdk/ndk/index.html#Installing).
@note Before start you can read official Android NDK documentation which is in the Android NDK
archive, in the folder `docs/`. The main article about using Android NDK build system is in the
`ANDROID-MK.html` file. Some additional information you can find in the `APPLICATION-MK.html`,
`NDK-BUILD.html` files, and `CPU-ARM-NEON.html`, `CPLUSPLUS-SUPPORT.html`, `PREBUILTS.html`. \#.
**CDT plugin for Eclipse**
@note Before start you can read official Android NDK documentation which is in the Android NDK
archive, in the folder `docs/`. The main article about using Android NDK build system is in the
`ANDROID-MK.html` file. Some additional information you can find in the `APPLICATION-MK.html`,
`NDK-BUILD.html` files, and `CPU-ARM-NEON.html`, `CPLUSPLUS-SUPPORT.html`, `PREBUILTS.html`.
If you selected for installation the NDK plugins component of Eclipse ADT plugin (see the picture
above) your Eclipse IDE should already have CDT plugin (that means C/C++ Development Tooling).
There are several possible ways to integrate compilation of C++ code by Android NDK into Eclipse
compilation process. We recommend the approach based on Eclipse CDT(C/C++ Development Tooling)
Builder.
-# **CDT plugin for Eclipse**
If you selected for installation the NDK plugins component of Eclipse ADT plugin (see the picture
above) your Eclipse IDE should already have CDT plugin (that means C/C++ Development Tooling).
There are several possible ways to integrate compilation of C++ code by Android NDK into Eclipse
compilation process. We recommend the approach based on Eclipse CDT(C/C++ Development Tooling)
Builder.
Android application structure
-----------------------------
@@ -244,6 +249,7 @@ APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
@endcode
@note We recommend setting APP_ABI := all for all targets. If you want to specify the target
explicitly, use armeabi for ARMv5/ARMv6, armeabi-v7a for ARMv7, x86 for Intel Atom or mips for MIPS.
@@ -260,18 +266,18 @@ We strongly reccomend using cmd.exe (standard Windows console) instead of Cygwin
not really supported and we are unlikely to help you in case you encounter some problems with
it. So, use it only if you're capable of handling the consequences yourself.
1. Open console and go to the root folder of an Android application
-# Open console and go to the root folder of an Android application
@code{.bash}
cd <root folder of the project>/
@endcode
2. Run the following command
-# Run the following command
@code{.bash}
<path_where_NDK_is_placed>/ndk-build
@endcode
@note On Windows we recommend to use ndk-build.cmd in standard Windows console (cmd.exe) rather than the similar bash script in Cygwin shell.
![image](images/ndk_build.png)
@note On Windows we recommend to use ndk-build.cmd in standard Windows console (cmd.exe) rather than the similar bash script in Cygwin shell.
![](images/ndk_build.png)
1. After executing this command the C++ part of the source code is compiled.
-# After executing this command the C++ part of the source code is compiled.
After that the Java part of the application can be (re)compiled (using either *Eclipse* or *Ant*
build tool).
@@ -299,8 +305,8 @@ Builder.
OpenCV for Android package since version 2.4.2 contains sample projects
pre-configured CDT Builders. For your own projects follow the steps below.
1. Define the NDKROOT environment variable containing the path to Android NDK in your system (e.g.
"X:\\\\Apps\\\\android-ndk-r8" or "/opt/android-ndk-r8").
-# Define the NDKROOT environment variable containing the path to Android NDK in your system (e.g.
"X:\\Apps\\android-ndk-r8" or "/opt/android-ndk-r8").
**On Windows** an environment variable can be set via
My Computer -\> Properties -\> Advanced -\> Environment variables. On Windows 7 it's also
@@ -309,71 +315,68 @@ OpenCV for Android package since version 2.4.2 contains sample projects
**On Linux** and **MacOS** an environment variable can be set via appending a
"export VAR_NAME=VAR_VALUE" line to the `"~/.bashrc"` file and logging off and then on.
@note It's also possible to define the NDKROOT environment variable within Eclipse IDE, but it
should be done for every new workspace you create. If you prefer this option better than setting
system environment variable, open Eclipse menu
Window -\> Preferences -\> C/C++ -\> Build -\> Environment, press the Add... button and set variable
name to NDKROOT and value to local Android NDK path. \#. After that you need to **restart Eclipse**
to apply the changes.
@note It's also possible to define the NDKROOT environment variable within Eclipse IDE, but it
should be done for every new workspace you create. If you prefer this option better than setting
system environment variable, open Eclipse menu
Window -\> Preferences -\> C/C++ -\> Build -\> Environment, press the Add... button and set variable
name to NDKROOT and value to local Android NDK path. \#. After that you need to **restart Eclipse**
to apply the changes.
1. Open Eclipse and load the Android app project to configure.
2. Add C/C++ Nature to the project via Eclipse menu
-# Open Eclipse and load the Android app project to configure.
-# Add C/C++ Nature to the project via Eclipse menu
New -\> Other -\> C/C++ -\> Convert to a C/C++ Project.
![image](images/eclipse_cdt_cfg1.png)
![](images/eclipse_cdt_cfg1.png)
And:
![](images/eclipse_cdt_cfg2.png)
![image](images/eclipse_cdt_cfg2.png)
3. Select the project(s) to convert. Specify "Project type" = Makefile project, "Toolchains" =
-# Select the project(s) to convert. Specify "Project type" = Makefile project, "Toolchains" =
Other Toolchain.
![](images/eclipse_cdt_cfg3.png)
![image](images/eclipse_cdt_cfg3.png)
4. Open Project Properties -\> C/C++ Build, uncheck Use default build command, replace "Build
-# Open Project Properties -\> C/C++ Build, uncheck Use default build command, replace "Build
command" text from "make" to
"${NDKROOT}/ndk-build.cmd" on Windows,
"${NDKROOT}/ndk-build" on Linux and MacOS.
![image](images/eclipse_cdt_cfg4.png)
![](images/eclipse_cdt_cfg4.png)
5. Go to Behaviour tab and change "Workbench build type" section like shown below:
-# Go to Behaviour tab and change "Workbench build type" section like shown below:
![image](images/eclipse_cdt_cfg5.png)
![](images/eclipse_cdt_cfg5.png)
6. Press OK and make sure the ndk-build is successfully invoked when building the project.
-# Press OK and make sure the ndk-build is successfully invoked when building the project.
![image](images/eclipse_cdt_cfg6.png)
![](images/eclipse_cdt_cfg6.png)
7. If you open your C++ source file in Eclipse editor, you'll see syntax error notifications. They
-# If you open your C++ source file in Eclipse editor, you'll see syntax error notifications. They
are not real errors, but additional CDT configuring is required.
![image](images/eclipse_cdt_cfg7.png)
![](images/eclipse_cdt_cfg7.png)
8. Open Project Properties -\> C/C++ General -\> Paths and Symbols and add the following
-# Open Project Properties -\> C/C++ General -\> Paths and Symbols and add the following
**Include** paths for **C++**:
@code
# for NDK r8 and prior:
\f${NDKROOT}/platforms/android-9/arch-arm/usr/include
\f${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include
\f${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include
\f${ProjDirPath}/../../sdk/native/jni/include
${NDKROOT}/platforms/android-9/arch-arm/usr/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include
${ProjDirPath}/../../sdk/native/jni/include
# for NDK r8b and later:
\f${NDKROOT}/platforms/android-9/arch-arm/usr/include
\f${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
\f${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
\f${ProjDirPath}/../../sdk/native/jni/include
${NDKROOT}/platforms/android-9/arch-arm/usr/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
${ProjDirPath}/../../sdk/native/jni/include
@endcode
The last path should be changed to the correct absolute or relative path to OpenCV4Android SDK
location.
This should clear the syntax error notifications in Eclipse C++ editor.
![image](images/eclipse_cdt_cfg8.png)
![](images/eclipse_cdt_cfg8.png)
Debugging and Testing
---------------------
@@ -386,18 +389,18 @@ hardware device for testing and debugging an Android project.
AVD (*Android Virtual Device*) is not probably the most convenient way to test an OpenCV-dependent
application, but sure the most uncomplicated one to configure.
1. Assuming you already have *Android SDK* and *Eclipse IDE* installed, in Eclipse go
-# Assuming you already have *Android SDK* and *Eclipse IDE* installed, in Eclipse go
Window -\> AVD Manager.
2. Press the New button in AVD Manager window.
3. Create new Android Virtual Device window will let you select some properties for your new
-# Press the New button in AVD Manager window.
-# Create new Android Virtual Device window will let you select some properties for your new
device, like target API level, size of SD-card and other.
![image](images/AVD_create.png)
![](images/AVD_create.png)
4. When you click the Create AVD button, your new AVD will be availible in AVD Manager.
5. Press Start to launch the device. Be aware that any AVD (a.k.a. Emulator) is usually much slower
-# When you click the Create AVD button, your new AVD will be availible in AVD Manager.
-# Press Start to launch the device. Be aware that any AVD (a.k.a. Emulator) is usually much slower
than a hardware Android device, so it may take up to several minutes to start.
6. Go Run -\> Run/Debug in Eclipse IDE to run your application in regular or debugging mode.
-# Go Run -\> Run/Debug in Eclipse IDE to run your application in regular or debugging mode.
Device Chooser will let you choose among the running devices or to start a new one.
### Hardware Device
@@ -412,86 +415,77 @@ instructions](http://developer.android.com/tools/device.html) for more informati
#### Windows host computer
1. Enable USB debugging on the Android device (via Settings menu).
2. Attach the Android device to your PC with a USB cable.
3. Go to Start Menu and **right-click** on Computer. Select Manage in the context menu. You may be
-# Enable USB debugging on the Android device (via Settings menu).
-# Attach the Android device to your PC with a USB cable.
-# Go to Start Menu and **right-click** on Computer. Select Manage in the context menu. You may be
asked for Administrative permissions.
4. Select Device Manager in the left pane and find an unknown device in the list. You may try
-# Select Device Manager in the left pane and find an unknown device in the list. You may try
unplugging it and then plugging back in order to check whether it's your exact equipment appears
in the list.
![image](images/usb_device_connect_01.png)
![](images/usb_device_connect_01.png)
5. Try your luck installing Google USB drivers without any modifications: **right-click** on the
-# Try your luck installing Google USB drivers without any modifications: **right-click** on the
unknown device, select Properties menu item --\> Details tab --\> Update Driver button.
![image](images/usb_device_connect_05.png)
![](images/usb_device_connect_05.png)
6. Select Browse computer for driver software.
-# Select Browse computer for driver software.
![image](images/usb_device_connect_06.png)
![](images/usb_device_connect_06.png)
7. Specify the path to `<Android SDK folder>/extras/google/usb_driver/` folder.
-# Specify the path to `<Android SDK folder>/extras/google/usb_driver/` folder.
![image](images/usb_device_connect_07.png)
![](images/usb_device_connect_07.png)
8. If you get the prompt to install unverified drivers and report about success - you've finished
-# If you get the prompt to install unverified drivers and report about success - you've finished
with USB driver installation.
![image](images/usb_device_connect_08.png)
![](images/usb_device_connect_08.png)
\` \`
![](images/usb_device_connect_09.png)
-# Otherwise (getting the failure like shown below) follow the next steps.
![image](images/usb_device_connect_09.png)
![](images/usb_device_connect_12.png)
9. Otherwise (getting the failure like shown below) follow the next steps.
-# Again **right-click** on the unknown device, select Properties --\> Details --\> Hardware Ids
and copy the line like `USB\VID_XXXX&PID_XXXX&MI_XX`.
![image](images/usb_device_connect_12.png)
![](images/usb_device_connect_02.png)
10. Again **right-click** on the unknown device, select Properties --\> Details --\> Hardware Ids
and copy the line like USB\\VID_XXXX&PID_XXXX&MI_XX.
![image](images/usb_device_connect_02.png)
11. Now open file `<Android SDK folder>/extras/google/usb_driver/android_winusb.inf`. Select either
-# Now open file `<Android SDK folder>/extras/google/usb_driver/android_winusb.inf`. Select either
Google.NTx86 or Google.NTamd64 section depending on your host system architecture.
![image](images/usb_device_connect_03.png)
![](images/usb_device_connect_03.png)
12. There should be a record like existing ones for your device and you need to add one manually.
-# There should be a record like existing ones for your device and you need to add one manually.
![image](images/usb_device_connect_04.png)
![](images/usb_device_connect_04.png)
13. Save the `android_winusb.inf` file and try to install the USB driver again.
-# Save the `android_winusb.inf` file and try to install the USB driver again.
![image](images/usb_device_connect_05.png)
![](images/usb_device_connect_05.png)
\` \`
![](images/usb_device_connect_06.png)
![image](images/usb_device_connect_06.png)
![](images/usb_device_connect_07.png)
\` \`
-# This time installation should go successfully.
![image](images/usb_device_connect_07.png)
![](images/usb_device_connect_08.png)
14. This time installation should go successfully.
![](images/usb_device_connect_09.png)
![image](images/usb_device_connect_08.png)
-# And an unknown device is now recognized as an Android phone.
\` \`
![](images/usb_device_connect_10.png)
![image](images/usb_device_connect_09.png)
-# Successful device USB connection can be verified in console via adb devices command.
15. And an unknown device is now recognized as an Android phone.
![](images/usb_device_connect_11.png)
![image](images/usb_device_connect_10.png)
16. Successful device USB connection can be verified in console via adb devices command.
![image](images/usb_device_connect_11.png)
17. Now, in Eclipse go Run -\> Run/Debug to run your application in regular or debugging mode.
-# Now, in Eclipse go Run -\> Run/Debug to run your application in regular or debugging mode.
Device Chooser will let you choose among the devices.
#### Linux host computer
@@ -507,7 +501,7 @@ SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
Then restart your adb server (even better to restart the system), plug in your Android device and
execute adb devices command. You will see the list of attached devices:
![image](images/usb_device_connect_ubuntu.png)
![](images/usb_device_connect_ubuntu.png)
#### Mac OS host computer

View File

@@ -38,17 +38,17 @@ OpenCV. You can get more information here: `Android OpenCV Manager` and in these
Using async initialization is a **recommended** way for application development. It uses the OpenCV
Manager to access OpenCV libraries externally installed in the target system.
1. Add OpenCV library project to your workspace. Use menu
-# Add OpenCV library project to your workspace. Use menu
File -\> Import -\> Existing project in your workspace.
Press Browse button and locate OpenCV4Android SDK (`OpenCV-2.4.9-android-sdk/sdk`).
![image](images/eclipse_opencv_dependency0.png)
![](images/eclipse_opencv_dependency0.png)
2. In application project add a reference to the OpenCV Java SDK in
-# In application project add a reference to the OpenCV Java SDK in
Project -\> Properties -\> Android -\> Library -\> Add select OpenCV Library - 2.4.9.
![image](images/eclipse_opencv_dependency1.png)
![](images/eclipse_opencv_dependency1.png)
In most cases OpenCV Manager may be installed automatically from Google Play. For the case, when
Google Play is not available, i.e. emulator, developer board, etc, you can install it manually using
@@ -101,18 +101,18 @@ designed mostly for development purposes. This approach is deprecated for the pr
release package is recommended to communicate with OpenCV Manager via the async initialization
described above.
1. Add the OpenCV library project to your workspace the same way as for the async initialization
-# Add the OpenCV library project to your workspace the same way as for the async initialization
above. Use menu File -\> Import -\> Existing project in your workspace, press Browse button and
select OpenCV SDK path (`OpenCV-2.4.9-android-sdk/sdk`).
![image](images/eclipse_opencv_dependency0.png)
![](images/eclipse_opencv_dependency0.png)
2. In the application project add a reference to the OpenCV4Android SDK in
-# In the application project add a reference to the OpenCV4Android SDK in
Project -\> Properties -\> Android -\> Library -\> Add select OpenCV Library - 2.4.9;
![image](images/eclipse_opencv_dependency1.png)
![](images/eclipse_opencv_dependency1.png)
3. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
-# If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
native libs from `<OpenCV-2.4.9-android-sdk>/sdk/native/libs/<target_arch>` to your project
directory to folder `libs/<target_arch>`.
@@ -126,7 +126,7 @@ described above.
@endcode
The result should look like the following:
@code{.make}
include \f$(CLEAR_VARS)
include $(CLEAR_VARS)
# OpenCV
OPENCV_CAMERA_MODULES:=on
@@ -139,7 +139,7 @@ described above.
Eclipse will automatically include all the libraries from the `libs` folder to the application
package (APK).
4. The last step of enabling OpenCV in your application is Java initialization code before calling
-# The last step of enabling OpenCV in your application is Java initialization code before calling
OpenCV API. It can be done, for example, in the static section of the Activity class:
@code{.java}
static {
@@ -166,23 +166,23 @@ described above.
To build your own Android application, using OpenCV as native part, the following steps should be
taken:
1. You can use an environment variable to specify the location of OpenCV package or just hardcode
-# You can use an environment variable to specify the location of OpenCV package or just hardcode
absolute or relative path in the `jni/Android.mk` of your projects.
2. The file `jni/Android.mk` should be written for the current application using the common rules
-# The file `jni/Android.mk` should be written for the current application using the common rules
for this file.
For detailed information see the Android NDK documentation from the Android NDK archive, in the
file `<path_where_NDK_is_placed>/docs/ANDROID-MK.html`.
3. The following line:
-# The following line:
@code{.make}
include C:\Work\OpenCV4Android\OpenCV-2.4.9-android-sdk\sdk\native\jni\OpenCV.mk
@endcode
Should be inserted into the `jni/Android.mk` file **after** this line:
@code{.make}
include \f$(CLEAR_VARS)
include $(CLEAR_VARS)
@endcode
4. Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when
-# Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when
your application uses the async initialization via the OpenCV Manager API.
@note These variables should be set **before** the "include .../OpenCV.mk" line:
@@ -202,7 +202,7 @@ taken:
Perform static linking with OpenCV. By default dynamic link is used and the project JNI lib
depends on libopencv_java.so.
5. The file `Application.mk` should exist and should contain lines:
-# The file `Application.mk` should exist and should contain lines:
@code{.make}
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
@@ -221,7 +221,7 @@ taken:
APP_PLATFORM := android-9
@endcode
6. Either use @ref tutorial_android_dev_intro_ndk "manual" ndk-build invocation or
-# Either use @ref tutorial_android_dev_intro_ndk "manual" ndk-build invocation or
@ref tutorial_android_dev_intro_eclipse "setup Eclipse CDT Builder" to build native JNI lib
before (re)building the Java part and creating
an APK.
@@ -232,18 +232,18 @@ Hello OpenCV Sample
Here are basic steps to guide you trough the process of creating a simple OpenCV-centric
application. It will be capable of accessing camera output, processing it and displaying the result.
1. Open Eclipse IDE, create a new clean workspace, create a new Android project
-# Open Eclipse IDE, create a new clean workspace, create a new Android project
File --\> New --\> Android Project
2. Set name, target, package and minSDKVersion accordingly. The minimal SDK version for build with
-# Set name, target, package and minSDKVersion accordingly. The minimal SDK version for build with
OpenCV4Android SDK is 11. Minimal device API Level (for application manifest) is 8.
3. Allow Eclipse to create default activity. Lets name the activity HelloOpenCvActivity.
4. Choose Blank Activity with full screen layout. Lets name the layout HelloOpenCvLayout.
5. Import OpenCV library project to your workspace.
6. Reference OpenCV library within your project properties.
-# Allow Eclipse to create default activity. Lets name the activity HelloOpenCvActivity.
-# Choose Blank Activity with full screen layout. Lets name the layout HelloOpenCvLayout.
-# Import OpenCV library project to your workspace.
-# Reference OpenCV library within your project properties.
![image](images/dev_OCV_reference.png)
![](images/dev_OCV_reference.png)
7. Edit your layout file as xml file and pass the following layout there:
-# Edit your layout file as xml file and pass the following layout there:
@code{.xml}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
@@ -261,7 +261,7 @@ application. It will be capable of accessing camera output, processing it and di
</LinearLayout>
@endcode
8. Add the following permissions to the `AndroidManifest.xml` file:
-# Add the following permissions to the `AndroidManifest.xml` file:
@code{.xml}
</application>
@@ -272,14 +272,14 @@ application. It will be capable of accessing camera output, processing it and di
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
@endcode
9. Set application theme in AndroidManifest.xml to hide title and system buttons.
-# Set application theme in AndroidManifest.xml to hide title and system buttons.
@code{.xml}
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
@endcode
10. Add OpenCV library initialization to your activity. Fix errors by adding requited imports.
-# Add OpenCV library initialization to your activity. Fix errors by adding requited imports.
@code{.java}
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
@@ -305,7 +305,7 @@ application. It will be capable of accessing camera output, processing it and di
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
}
@endcode
11. Defines that your activity implements CvCameraViewListener2 interface and fix activity related
-# Defines that your activity implements CvCameraViewListener2 interface and fix activity related
errors by defining missed methods. For this activity define onCreate, onDestroy and onPause and
implement them according code snippet bellow. Fix errors by adding requited imports.
@code{.java}
@@ -346,7 +346,7 @@ application. It will be capable of accessing camera output, processing it and di
return inputFrame.rgba();
}
@endcode
12. Run your application on device or emulator.
-# Run your application on device or emulator.
Lets discuss some most important steps. Every Android application with UI must implement Activity
and View. By the first steps we create blank activity and default view layout. The simplest

View File

@@ -32,9 +32,11 @@ tutorial](http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_j
If you are in hurry, here is a minimum quick start guide to install OpenCV on Mac OS X:
NOTE 1: I'm assuming you already installed [xcode](https://developer.apple.com/xcode/),
@note
I'm assuming you already installed [xcode](https://developer.apple.com/xcode/),
[jdk](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and
[Cmake](http://www.cmake.org/cmake/resources/software.html).
@code{.bash}
cd ~/
mkdir opt
@@ -60,9 +62,9 @@ cycle of your CLJ projects.
The available [installation guide](https://github.com/technomancy/leiningen#installation) is very
easy to be followed:
1. [Download the script](https://raw.github.com/technomancy/leiningen/stable/bin/lein)
2. Place it on your $PATH (cf. \~/bin is a good choice if it is on your path.)
3. Set the script to be executable. (i.e. chmod 755 \~/bin/lein).
-# [Download the script](https://raw.github.com/technomancy/leiningen/stable/bin/lein)
-# Place it on your $PATH (cf. \~/bin is a good choice if it is on your path.)
-# Set the script to be executable. (i.e. chmod 755 \~/bin/lein).
If you work on Windows, follow [this instruction](https://github.com/technomancy/leiningen#windows)
@@ -171,9 +173,9 @@ Your directories layout should look like the following:
tree
.
|__ native
|   |__ macosx
|   |__ x86_64
|   |__ libopencv_java247.dylib
| |__ macosx
| |__ x86_64
| |__ libopencv_java247.dylib
|
|__ opencv-247.jar
|__ opencv-native-247.jar
@@ -215,13 +217,13 @@ simple-sample/
|__ LICENSE
|__ README.md
|__ doc
|   |__ intro.md
| |__ intro.md
|
|__ project.clj
|__ resources
|__ src
|   |__ simple_sample
|   |__ core.clj
| |__ simple_sample
| |__ core.clj
|__ test
|__ simple_sample
|__ core_test.clj
@@ -299,7 +301,9 @@ nil
Then you can start interacting with OpenCV by just referencing the fully qualified names of its
classes.
NOTE 2: [Here](http://docs.opencv.org/java/) you can find the full OpenCV Java API.
@note
[Here](http://docs.opencv.org/java/) you can find the full OpenCV Java API.
@code{.clojure}
user=> (org.opencv.core.Point. 0 0)
#<Point {0.0, 0.0}>
@@ -409,6 +413,7 @@ class SimpleSample {
}
@endcode
### Add injections to the project
Before start coding, we'd like to eliminate the boring need of interactively loading the native
@@ -454,6 +459,7 @@ We're going to mimic almost verbatim the original OpenCV java tutorial to:
- change the value of every element of the second row to 1
- change the value of every element of the 6th column to 5
- print the content of the obtained matrix
@code{.clojure}
user=> (def m (Mat. 5 10 CvType/CV_8UC1 (Scalar. 0 0)))
#'user/m
@@ -473,6 +479,7 @@ user=> (println (.dump m))
0, 0, 0, 0, 0, 5, 0, 0, 0, 0]
nil
@endcode
If you are accustomed to a functional language all those abused and mutating nouns are going to
irritate your preference for verbs. Even if the CLJ interop syntax is very handy and complete, there
is still an impedance mismatch between any OOP language and any FP language (bein Scala a mixed
@@ -483,6 +490,7 @@ To exit the REPL type (exit), ctr-D or (quit) at the REPL prompt.
user=> (exit)
Bye for now!
@endcode
### Interactively load and blur an image
In the next sample you will learn how to interactively load and blur and image from the REPL by
@@ -500,7 +508,7 @@ main argument to both the GaussianBlur and the imwrite methods.
First we want to add an image file to a newly create directory for storing static resources of the
project.
![image](images/lena.png)
![](images/lena.png)
@code{.bash}
mkdir -p resources/images
cp ~/opt/opencv/doc/tutorials/introduction/desktop_java/images/lena.png resource/images/
@@ -554,7 +562,7 @@ Bye for now!
@endcode
Following is the new blurred image of Lena.
![image](images/blurred.png)
![](images/blurred.png)
Next Steps
----------
@@ -577,4 +585,3 @@ the gap.
Copyright © 2013 Giacomo (Mimmo) Cosenza aka Magomimmo
Distributed under the BSD 3-clause License, the same of OpenCV.

View File

@@ -49,10 +49,11 @@ In Linux it can be achieved with the following command in Terminal:
cd ~/<my_working _directory>
git clone https://github.com/Itseez/opencv.git
@endcode
Building OpenCV
---------------
1. Create a build directory, make it current and run the following command:
-# Create a build directory, make it current and run the following command:
@code{.bash}
cmake [<some optional parameters>] -DCMAKE_TOOLCHAIN_FILE=<path to the OpenCV source directory>/platforms/linux/arm-gnueabi.toolchain.cmake <path to the OpenCV source directory>
@endcode
@@ -69,13 +70,15 @@ Building OpenCV
cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..
@endcode
2. Run make in build (\<cmake_binary_dir\>) directory:
-# Run make in build (\<cmake_binary_dir\>) directory:
@code{.bash}
make
@endcode
@note
Optionally you can strip symbols info from the created library via install/strip make target.
This option produces smaller binary (\~ twice smaller) but makes further debugging harder.
Optionally you can strip symbols info from the created library via install/strip make target.
This option produces smaller binary (\~ twice smaller) but makes further debugging harder.
### Enable hardware optimizations
@@ -86,5 +89,4 @@ extensions.
TBB is supported on multi core ARM SoCs also. Add -DWITH_TBB=ON and -DBUILD_TBB=ON to enable it.
Cmake scripts download TBB sources from official project site
[](http://threadingbuildingblocks.org/) and build it.
<http://threadingbuildingblocks.org/> and build it.

View File

@@ -33,7 +33,9 @@ from the [OpenCV SourceForge repository](http://sourceforge.net/projects/opencvl
@note Windows users can find the prebuilt files needed for Java development in the
`opencv/build/java/` folder inside the package. For other OSes it's required to build OpenCV from
sources. Another option to get OpenCV sources is to clone [OpenCV git
sources.
Another option to get OpenCV sources is to clone [OpenCV git
repository](https://github.com/Itseez/opencv/). In order to build OpenCV with Java bindings you need
JDK (Java Development Kit) (we recommend [Oracle/Sun JDK 6 or
7](http://www.oracle.com/technetwork/java/javase/downloads/)), [Apache Ant](http://ant.apache.org/)
@@ -67,7 +69,7 @@ Examine the output of CMake and ensure java is one of the
modules "To be built". If not, it's likely you're missing a dependency. You should troubleshoot by
looking through the CMake output for any Java-related tools that aren't found and installing them.
![image](images/cmake_output.png)
![](images/cmake_output.png)
@note If CMake can't find Java in your system set the JAVA_HOME environment variable with the path to installed JDK before running it. E.g.:
@code{.bash}
@@ -141,7 +143,7 @@ folder.
The command should initiate [re]building and running the sample. You should see on the
screen something like this:
![image](images/ant_output.png)
![](images/ant_output.png)
SBT project for Java and Scala
------------------------------
@@ -203,7 +205,7 @@ eclipse # Running "eclipse" from within the sbt console
@endcode
You should see something like this:
![image](images/sbt_eclipse.png)
![](images/sbt_eclipse.png)
You can now import the SBT project to Eclipse using Import ... -\> Existing projects into workspace.
Whether you actually do this is optional for the guide; we'll be using SBT to build the project, so
@@ -225,7 +227,7 @@ sbt run
@endcode
You should see something like this:
![image](images/sbt_run.png)
![](images/sbt_run.png)
### Running SBT samples
@@ -241,7 +243,7 @@ sbt eclipse
@endcode
Next, create the directory `src/main/resources` and download this Lena image into it:
![image](images/lena.png)
![](images/lena.png)
Make sure it's called `"lena.png"`. Items in the resources directory are available to the Java
application at runtime.
@@ -315,11 +317,11 @@ sbt run
@endcode
You should see something like this:
![image](images/sbt_run_face.png)
![](images/sbt_run_face.png)
It should also write the following image to `faceDetection.png`:
![image](images/faceDetection.png)
![](images/faceDetection.png)
You're done! Now you have a sample Java application working with OpenCV, so you can start the work
on your own. We wish you good luck and many years of joyful life!

View File

@@ -21,6 +21,8 @@ Download the source code from
Explanation
-----------
@dontinclude cpp/tutorial_code/introduction/display_image/display_image.cpp
In OpenCV 2 we have multiple modules. Each one takes care of a different area or approach towards
image processing. You could already observe this in the structure of the user guide of these
tutorials itself. Before you use any of them you first need to include the header files where the
@@ -31,36 +33,25 @@ You'll almost always end up using the:
- *core* section, as here are defined the basic building blocks of the library
- *highgui* module, as this contains the functions for input and output operations
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
1-6
@until <string>
We also include the *iostream* to facilitate console line output and input. To avoid data structure
and function name conflicts with other libraries, OpenCV has its own namespace: *cv*. To avoid the
need appending prior each of these the *cv::* keyword you can import the namespace in the whole file
by using the lines:
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
8-9
@line using namespace cv
This is true for the STL library too (used for console I/O). Now, let's analyze the *main* function.
We start up assuring that we acquire a valid image name argument from the command line. Otherwise
take a picture by default: "HappyFish.jpg".
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
13-17
@skip string
@until }
Then create a *Mat* object that will store the data of the loaded image.
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
19
@skipline Mat
Now we call the @ref cv::imread function which loads the image name specified by the first argument
(*argv[1]*). The second argument specifies the format in what we want the image. This may be:
@@ -69,10 +60,7 @@ Now we call the @ref cv::imread function which loads the image name specified by
- IMREAD_GRAYSCALE ( 0) loads the image as an intensity one
- IMREAD_COLOR (\>0) loads the image in the RGB format
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
20
@skipline image = imread
@note
OpenCV offers support for the image formats Windows bitmap (bmp), portable image formats (pbm,
@@ -94,30 +82,18 @@ the image it contains from a size point of view. It may be:
would like the image to keep its aspect ratio (*WINDOW_KEEPRATIO*) or not
(*WINDOW_FREERATIO*).
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
28
@skipline namedWindow
Finally, to update the content of the OpenCV window with a new image use the @ref cv::imshow
function. Specify the OpenCV window name to update and the image to use during this operation:
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
29
@skipline imshow
Because we want our window to be displayed until the user presses a key (otherwise the program would
end far too quickly), we use the @ref cv::waitKey function whose only parameter is just how long
should it wait for a user input (measured in milliseconds). Zero means to wait forever.
@includelineno cpp/tutorial_code/introduction/display_image/display_image.cpp
lines
31
@skipline waitKey
Result
------
@@ -130,11 +106,10 @@ Result
@endcode
- You should get a nice window as the one shown below:
![image](images/Display_Image_Tutorial_Result.jpg)
![](images/Display_Image_Tutorial_Result.jpg)
\htmlonly
<div align="center">
<iframe title="Introduction - Display an Image" width="560" height="349" src="http://www.youtube.com/embed/1OJEqpuaGc4?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
</div>
\endhtmlonly

View File

@@ -21,13 +21,13 @@ git clone https://github.com/Itseez/opencv.git
Building OpenCV from Source, using CMake and Command Line
---------------------------------------------------------
1. Make symbolic link for Xcode to let OpenCV build scripts find the compiler, header files etc.
-# Make symbolic link for Xcode to let OpenCV build scripts find the compiler, header files etc.
@code{.bash}
cd /
sudo ln -s /Applications/Xcode.app/Contents/Developer Developer
@endcode
2. Build OpenCV framework:
-# Build OpenCV framework:
@code{.bash}
cd ~/<my_working_directory>
python opencv/platforms/ios/build_framework.py ios

View File

@@ -17,51 +17,51 @@ 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 Window --\> Preferences from the menu.
![image](images/1-window-preferences.png)
![](images/1-window-preferences.png)
Navigate under Java --\> Build Path --\> User Libraries and click New....
![image](images/2-user-library-new.png)
![](images/2-user-library-new.png)
Enter a name, e.g. OpenCV-2.4.6, for your new library.
![image](images/3-library-name.png)
![](images/3-library-name.png)
Now select your new user library and click Add External JARs....
![image](images/4-add-external-jars.png)
![](images/4-add-external-jars.png)
Browse through `C:\OpenCV-2.4.6\build\java\` and select opencv-246.jar. After adding the jar,
extend the opencv-246.jar and select Native library location and press Edit....
![image](images/5-native-library.png)
![](images/5-native-library.png)
Select 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)
![](images/6-external-folder.png)
Your user library configuration should look like this:
![image](images/7-user-library-final.png)
![](images/7-user-library-final.png)
Testing the configuration on a new Java project
-----------------------------------------------
Now start creating a new Java project.
![image](images/7_5-new-java-project.png)
![](images/7_5-new-java-project.png)
On the Java Settings step, under Libraries tab, select Add Library... and select OpenCV-2.4.6, then
click Finish.
![image](images/8-add-library.png)
![](images/8-add-library.png)
![image](images/9-select-user-lib.png)
![](images/9-select-user-lib.png)
Libraries should look like this:
![image](images/10-new-project-created.png)
![](images/10-new-project-created.png)
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:
@@ -82,7 +82,7 @@ public class Hello
@endcode
When you run the code you should see 3x3 identity matrix as output.
![image](images/11-the-code.png)
![](images/11-the-code.png)
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 :)

View File

@@ -4,45 +4,45 @@ Using OpenCV with Eclipse (plugin CDT) {#tutorial_linux_eclipse}
Prerequisites
-------------
Two ways, one by forming a project directly, and another by CMake Prerequisites
1. Having installed [Eclipse](http://www.eclipse.org/) in your workstation (only the CDT plugin for
-# Having installed [Eclipse](http://www.eclipse.org/) in your workstation (only the CDT plugin for
C/C++ is needed). You can follow the following steps:
- Go to the Eclipse site
- Download [Eclipse IDE for C/C++
Developers](http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliossr2) .
Choose the link according to your workstation.
2. Having installed OpenCV. If not yet, go @ref tutorial_linux_install "here".
-# Having installed OpenCV. If not yet, go @ref tutorial_linux_install "here".
Making a project
----------------
1. Start Eclipse. Just run the executable that comes in the folder.
2. Go to **File -\> New -\> C/C++ Project**
-# Start Eclipse. Just run the executable that comes in the folder.
-# Go to **File -\> New -\> C/C++ Project**
![image](images/a0.png)
![](images/a0.png)
3. Choose a name for your project (i.e. DisplayImage). An **Empty Project** should be okay for this
-# Choose a name for your project (i.e. DisplayImage). An **Empty Project** should be okay for this
example.
![image](images/a1.png)
![](images/a1.png)
4. Leave everything else by default. Press **Finish**.
5. Your project (in this case DisplayImage) should appear in the **Project Navigator** (usually at
-# Leave everything else by default. Press **Finish**.
-# Your project (in this case DisplayImage) should appear in the **Project Navigator** (usually at
the left side of your window).
![image](images/a3.png)
![](images/a3.png)
6. Now, let's add a source file using OpenCV:
-# Now, let's add a source file using OpenCV:
- Right click on **DisplayImage** (in the Navigator). **New -\> Folder** .
![image](images/a4.png)
![](images/a4.png)
- Name your folder **src** and then hit **Finish**
- Right click on your newly created **src** folder. Choose **New source file**:
- Call it **DisplayImage.cpp**. Hit **Finish**
![image](images/a7.png)
![](images/a7.png)
7. So, now you have a project with a empty .cpp file. Let's fill it with some sample code (in other
-# So, now you have a project with a empty .cpp file. Let's fill it with some sample code (in other
words, copy and paste the snippet below):
@code{.cpp}
#include <opencv2/opencv.hpp>
@@ -68,7 +68,7 @@ Making a project
return 0;
}
@endcode
8. We are only missing one final step: To tell OpenCV where the OpenCV headers and libraries are.
-# We are only missing one final step: To tell OpenCV where the OpenCV headers and libraries are.
For this, do the following:
- Go to **Project--\>Properties**
@@ -78,7 +78,7 @@ Making a project
include the path of the folder where opencv was installed. In our example, this is
/usr/local/include/opencv.
![image](images/a9.png)
![](images/a9.png)
@note If you do not know where your opencv files are, open the **Terminal** and type:
@code{.bash}
@@ -103,7 +103,7 @@ Making a project
opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_features2d
opencv_calib3d opencv_objdetect opencv_contrib opencv_legacy opencv_flann
![image](images/a10.png)
![](images/a10.png)
If you don't know where your libraries are (or you are just psychotic and want to make sure
the path is fine), type in **Terminal**:
@@ -120,7 +120,7 @@ Making a project
In the Console you should get something like
![image](images/a12.png)
![](images/a12.png)
If you check in your folder, there should be an executable there.
@@ -138,21 +138,21 @@ Assuming that the image to use as the argument would be located in
\<DisplayImage_directory\>/images/HappyLittleFish.png. We can still do this, but let's do it from
Eclipse:
1. Go to **Run-\>Run Configurations**
2. Under C/C++ Application you will see the name of your executable + Debug (if not, click over
-# Go to **Run-\>Run Configurations**
-# Under C/C++ Application you will see the name of your executable + Debug (if not, click over
C/C++ Application a couple of times). Select the name (in this case **DisplayImage Debug**).
3. Now, in the right side of the window, choose the **Arguments** Tab. Write the path of the image
-# Now, in the right side of the window, choose the **Arguments** Tab. Write the path of the image
file we want to open (path relative to the workspace/DisplayImage folder). Let's use
**HappyLittleFish.png**:
![image](images/a14.png)
![](images/a14.png)
4. Click on the **Apply** button and then in Run. An OpenCV window should pop up with the fish
-# Click on the **Apply** button and then in Run. An OpenCV window should pop up with the fish
image (or whatever you used).
![image](images/a15.jpg)
![](images/a15.jpg)
5. Congratulations! You are ready to have fun with OpenCV using Eclipse.
-# Congratulations! You are ready to have fun with OpenCV using Eclipse.
### V2: Using CMake+OpenCV with Eclipse (plugin CDT)
@@ -170,25 +170,25 @@ int main ( int argc, char **argv )
return 0;
}
@endcode
1. Create a build directory, say, under *foo*: mkdir /build. Then cd build.
2. Put a `CmakeLists.txt` file in build:
-# Create a build directory, say, under *foo*: mkdir /build. Then cd build.
-# Put a `CmakeLists.txt` file in build:
@code{.bash}
PROJECT( helloworld_proj )
FIND_PACKAGE( OpenCV REQUIRED )
ADD_EXECUTABLE( helloworld helloworld.cxx )
TARGET_LINK_LIBRARIES( helloworld \f${OpenCV_LIBS} )
@endcode
1. Run: cmake-gui .. and make sure you fill in where opencv was built.
2. Then click configure and then generate. If it's OK, **quit cmake-gui**
3. Run `make -j4` (the -j4 is optional, it just tells the compiler to build in 4 threads). Make
-# Run: cmake-gui .. and make sure you fill in where opencv was built.
-# Then click configure and then generate. If it's OK, **quit cmake-gui**
-# Run `make -j4` (the -j4 is optional, it just tells the compiler to build in 4 threads). Make
sure it builds.
4. Start eclipse. Put the workspace in some directory but **not** in foo or `foo\build`
5. Right click in the Project Explorer section. Select Import And then open the C/C++ filter.
-# Start eclipse. Put the workspace in some directory but **not** in foo or `foo\build`
-# Right click in the Project Explorer section. Select Import And then open the C/C++ filter.
Choose *Existing Code* as a Makefile Project.
6. Name your project, say *helloworld*. Browse to the Existing Code location `foo\build` (where
-# Name your project, say *helloworld*. Browse to the Existing Code location `foo\build` (where
you ran your cmake-gui from). Select *Linux GCC* in the *"Toolchain for Indexer Settings"* and
press *Finish*.
7. Right click in the Project Explorer section. Select Properties. Under C/C++ Build, set the
-# Right click in the Project Explorer section. Select Properties. Under C/C++ Build, set the
*build directory:* from something like `${workspace_loc:/helloworld}` to
`${workspace_loc:/helloworld}/build` since that's where you are building to.
@@ -196,4 +196,4 @@ TARGET_LINK_LIBRARIES( helloworld \f${OpenCV_LIBS} )
`make VERBOSE=1 -j4` which tells the compiler to produce detailed symbol files for debugging and
also to compile in 4 parallel threads.
8. Done!
-# Done!

View File

@@ -1,13 +1,12 @@
Using OpenCV with gcc and CMake {#tutorial_linux_gcc_cmake}
===============================
@note We assume that you have successfully installed OpenCV in your workstation. .. container::
enumeratevisibleitemswithsquare
@note We assume that you have successfully installed OpenCV in your workstation.
- The easiest way of using OpenCV in your code is to use [CMake](http://www.cmake.org/). A few
advantages (taken from the Wiki):
1. No need to change anything when porting between Linux and Windows
2. Can easily be combined with other tools by CMake( i.e. Qt, ITK and VTK )
-# No need to change anything when porting between Linux and Windows
-# Can easily be combined with other tools by CMake( i.e. Qt, ITK and VTK )
- If you are not familiar with CMake, checkout the
[tutorial](http://www.cmake.org/cmake/help/cmake_tutorial.html) on its website.
@@ -75,5 +74,4 @@ giving an image location as an argument, i.e.:
@endcode
You should get a nice window as the one shown below:
![image](images/GCC_CMake_Example_Tutorial.jpg)
![](images/GCC_CMake_Example_Tutorial.jpg)

View File

@@ -49,7 +49,7 @@ git clone https://github.com/Itseez/opencv_contrib.git
Building OpenCV from Source Using CMake
---------------------------------------
1. Create a temporary directory, which we denote as \<cmake_build_dir\>, where you want to put
-# Create a temporary directory, which we denote as \<cmake_build_dir\>, where you want to put
the generated Makefiles, project files as well the object files and output binaries and enter
there.
@@ -59,7 +59,7 @@ Building OpenCV from Source Using CMake
mkdir build
cd build
@endcode
2. Configuring. Run cmake [\<some optional parameters\>] \<path to the OpenCV source directory\>
-# Configuring. Run cmake [\<some optional parameters\>] \<path to the OpenCV source directory\>
For example
@code{.bash}
@@ -73,14 +73,14 @@ Building OpenCV from Source Using CMake
- run: “Configure”
- run: “Generate”
3. Description of some parameters
- build type: CMAKE_BUILD_TYPE=Release\\Debug
-# Description of some parameters
- build type: `CMAKE_BUILD_TYPE=Release\Debug`
- to build with modules from opencv_contrib set OPENCV_EXTRA_MODULES_PATH to \<path to
opencv_contrib/modules/\>
- set BUILD_DOCS for building documents
- set BUILD_EXAMPLES to build all examples
4. [optional] Building python. Set the following python parameters:
-# [optional] Building python. Set the following python parameters:
- PYTHON2(3)_EXECUTABLE = \<path to python\>
- PYTHON_INCLUDE_DIR = /usr/include/python\<version\>
- PYTHON_INCLUDE_DIR2 = /usr/include/x86_64-linux-gnu/python\<version\>
@@ -88,18 +88,18 @@ Building OpenCV from Source Using CMake
- PYTHON2(3)_NUMPY_INCLUDE_DIRS =
/usr/lib/python\<version\>/dist-packages/numpy/core/include/
5. [optional] Building java.
-# [optional] Building java.
- Unset parameter: BUILD_SHARED_LIBS
- It is useful also to unset BUILD_EXAMPLES, BUILD_TESTS, BUILD_PERF_TESTS - as they all
will be statically linked with OpenCV and can take a lot of memory.
6. Build. From build directory execute make, recomend to do it in several threads
-# Build. From build directory execute make, recomend to do it in several threads
For example
@code{.bash}
make -j7 # runs 7 jobs in parallel
@endcode
7. [optional] Building documents. Enter \<cmake_build_dir/doc/\> and run make with target
-# [optional] Building documents. Enter \<cmake_build_dir/doc/\> and run make with target
"html_docs"
For example
@@ -107,11 +107,11 @@ Building OpenCV from Source Using CMake
cd ~/opencv/build/doc/
make -j7 html_docs
@endcode
8. To install libraries, from build directory execute
-# To install libraries, from build directory execute
@code{.bash}
sudo make install
@endcode
9. [optional] Running tests
-# [optional] Running tests
- Get the required test data from [OpenCV extra
repository](https://github.com/Itseez/opencv_extra).

View File

@@ -55,9 +55,9 @@ int main( int argc, char** argv )
Explanation
-----------
1. We begin by loading an image using @ref cv::imread , located in the path given by *imageName*.
-# We begin by loading an image using @ref cv::imread , located in the path given by *imageName*.
For this example, assume you are loading a RGB image.
2. Now we are going to convert our image from BGR to Grayscale format. OpenCV has a really nice
-# Now we are going to convert our image from BGR to Grayscale format. OpenCV has a really nice
function to do this kind of transformations:
@code{.cpp}
cvtColor( image, gray_image, COLOR_BGR2GRAY );
@@ -70,7 +70,7 @@ Explanation
this case we use **COLOR_BGR2GRAY** (because of @ref cv::imread has BGR default channel
order in case of color images).
3. So now we have our new *gray_image* and want to save it on disk (otherwise it will get lost
-# So now we have our new *gray_image* and want to save it on disk (otherwise it will get lost
after the program ends). To save it, we will use a function analagous to @ref cv::imread : @ref
cv::imwrite
@code{.cpp}
@@ -79,7 +79,7 @@ Explanation
Which will save our *gray_image* as *Gray_Image.jpg* in the folder *images* located two levels
up of my current location.
4. Finally, let's check out the images. We create two windows and use them to show the original
-# Finally, let's check out the images. We create two windows and use them to show the original
image as well as the new one:
@code{.cpp}
namedWindow( imageName, WINDOW_AUTOSIZE );
@@ -88,18 +88,18 @@ Explanation
imshow( imageName, image );
imshow( "Gray image", gray_image );
@endcode
5. Add the *waitKey(0)* function call for the program to wait forever for an user key press.
-# Add the *waitKey(0)* function call for the program to wait forever for an user key press.
Result
------
When you run your program you should get something like this:
![image](images/Load_Save_Image_Result_1.jpg)
![](images/Load_Save_Image_Result_1.jpg)
And if you check in your folder (in my case *images*), you should have a newly .jpg file named
*Gray_Image.jpg*:
![image](images/Load_Save_Image_Result_2.jpg)
![](images/Load_Save_Image_Result_2.jpg)
Congratulations, you are done with this tutorial!

View File

@@ -14,15 +14,15 @@ technologies we integrate into our library. .. _Windows_Install_Prebuild:
Installation by Using the Pre-built Libraries {#tutorial_windows_install_prebuilt}
=============================================
1. Launch a web browser of choice and go to our [page on
-# Launch a web browser of choice and go to our [page on
Sourceforge](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/).
2. Choose a build you want to use and download it.
3. Make sure you have admin rights. Unpack the self-extracting archive.
4. You can check the installation at the chosen path as you can see below.
-# Choose a build you want to use and download it.
-# Make sure you have admin rights. Unpack the self-extracting archive.
-# You can check the installation at the chosen path as you can see below.
![image](images/OpenCV_Install_Directory.png)
![](images/OpenCV_Install_Directory.png)
5. To finalize the installation go to the @ref tutorial_windows_install_path section.
-# To finalize the installation go to the @ref tutorial_windows_install_path section.
Installation by Making Your Own Libraries from the Source Files {#tutorial_windows_install_build}
===============================================================
@@ -97,18 +97,18 @@ libraries). If you do not need the support for some of these you can just freely
### Building the library
1. Make sure you have a working IDE with a valid compiler. In case of the Microsoft Visual Studio
-# Make sure you have a working IDE with a valid compiler. In case of the Microsoft Visual Studio
just install it and make sure it starts up.
2. Install [CMake](http://www.cmake.org/cmake/resources/software.html). Simply follow the wizard, no need to add it to the path. The default install
-# Install [CMake](http://www.cmake.org/cmake/resources/software.html). Simply follow the wizard, no need to add it to the path. The default install
options are OK.
3. Download and install an up-to-date version of msysgit from its [official
-# Download and install an up-to-date version of msysgit from its [official
site](http://code.google.com/p/msysgit/downloads/list). There is also the portable version,
which you need only to unpack to get access to the console version of Git. Supposing that for
some of us it could be quite enough.
4. Install [TortoiseGit](http://code.google.com/p/tortoisegit/wiki/Download). Choose the 32 or 64 bit version according to the type of OS you work in.
-# Install [TortoiseGit](http://code.google.com/p/tortoisegit/wiki/Download). Choose the 32 or 64 bit version according to the type of OS you work in.
While installing, locate your msysgit (if it doesn't do that automatically). Follow the
wizard -- the default options are OK for the most part.
5. Choose a directory in your file system, where you will download the OpenCV libraries to. I
-# Choose a directory in your file system, where you will download the OpenCV libraries to. I
recommend creating a new one that has short path and no special charachters in it, for example
`D:/OpenCV`. For this tutorial I'll suggest you do so. If you use your own path and know, what
you're doing -- it's OK.
@@ -118,7 +118,7 @@ libraries). If you do not need the support for some of these you can just freely
-# Push the OK button and be patient as the repository is quite a heavy download. It will take
some time depending on your Internet connection.
6. In this section I will cover installing the 3rd party libraries.
-# In this section I will cover installing the 3rd party libraries.
-# Download the [Python libraries](http://www.python.org/downloads/) and install it with the default options. You will need a
couple other python extensions. Luckily installing all these may be automated by a nice tool
called [Setuptools](http://pypi.python.org/pypi/setuptools#downloads). Download and install
@@ -131,9 +131,9 @@ libraries). If you do not need the support for some of these you can just freely
Script sub-folder. Here just pass to the *easy_install.exe* as argument the name of the
program you want to install. Add the *sphinx* argument.
![image](images/cmsdstartwindows.jpg)
![](images/cmsdstartwindows.jpg)
![image](images/Sphinx_Install.png)
![](images/Sphinx_Install.png)
@note
The *CD* navigation command works only inside a drive. For example if you are somewhere in the
@@ -152,7 +152,7 @@ libraries). If you do not need the support for some of these you can just freely
sure you select for the *"Install missing packages on-the-fly"* the *Yes* option, as you can
see on the image below. Again this will take quite some time so be patient.
![image](images/MiktexInstall.png)
![](images/MiktexInstall.png)
-# For the [Intel Threading Building Blocks (*TBB*)](http://threadingbuildingblocks.org/file.php?fid=77)
download the source files and extract
@@ -161,7 +161,7 @@ libraries). If you do not need the support for some of these you can just freely
the story is the same. For
exctracting the archives I recommend using the [7-Zip](http://www.7-zip.org/) application.
![image](images/IntelTBB.png)
![](images/IntelTBB.png)
-# For the [Intel IPP Asynchronous C/C++](http://software.intel.com/en-us/intel-ipp-preview) download the source files and set environment
variable **IPP_ASYNC_ROOT**. It should point to
@@ -182,14 +182,14 @@ libraries). If you do not need the support for some of these you can just freely
Downloads](http://qt.nokia.com/downloads) page. Download the source files (not the
installers!!!):
![image](images/qtDownloadThisPackage.png)
![](images/qtDownloadThisPackage.png)
Extract it into a nice and short named directory like `D:/OpenCV/dep/qt/` . Then you need to
build it. Start up a *Visual* *Studio* *Command* *Prompt* (*2010*) by using the start menu
search (or navigate through the start menu
All Programs --\> Microsoft Visual Studio 2010 --\> Visual Studio Tools --\> Visual Studio Command Prompt (2010)).
![image](images/visualstudiocommandprompt.jpg)
![](images/visualstudiocommandprompt.jpg)
Now navigate to the extracted folder and enter inside it by using this console window. You
should have a folder containing files like *Install*, *Make* and so on. Use the *dir* command
@@ -216,25 +216,25 @@ libraries). If you do not need the support for some of these you can just freely
Visual Studio Add-in*. After this you can make and build Qt applications without using the *Qt
Creator*. Everything is nicely integrated into Visual Studio.
7. Now start the *CMake (cmake-gui)*. You may again enter it in the start menu search or get it
-# Now start the *CMake (cmake-gui)*. You may again enter it in the start menu search or get it
from the All Programs --\> CMake 2.8 --\> CMake (cmake-gui). First, select the directory for the
source files of the OpenCV library (1). Then, specify a directory where you will build the
binary files for OpenCV (2).
![image](images/CMakeSelectBin.jpg)
![](images/CMakeSelectBin.jpg)
Press the Configure button to specify the compiler (and *IDE*) you want to use. Note that in
case you can choose between different compilers for making either 64 bit or 32 bit libraries.
Select the one you use in your application development.
![image](images/CMake_Configure_Windows.jpg)
![](images/CMake_Configure_Windows.jpg)
CMake will start out and based on your system variables will try to automatically locate as many
packages as possible. You can modify the packages to use for the build in the WITH --\> WITH_X
menu points (where *X* is the package abbreviation). Here are a list of current packages you can
turn on or off:
![image](images/CMakeBuildWithWindowsGUI.jpg)
![](images/CMakeBuildWithWindowsGUI.jpg)
Select all the packages you want to use and press again the *Configure* button. For an easier
overview of the build options make sure the *Grouped* option under the binary directory
@@ -242,9 +242,9 @@ libraries). If you do not need the support for some of these you can just freely
directories. In case of these CMake will throw an error in its output window (located at the
bottom of the GUI) and set its field values, to not found constants. For example:
![image](images/CMakePackageNotFoundWindows.jpg)
![](images/CMakePackageNotFoundWindows.jpg)
![image](images/CMakeOutputPackageNotFound.jpg)
![](images/CMakeOutputPackageNotFound.jpg)
For these you need to manually set the queried directories or files path. After this press again
the *Configure* button to see if the value entered by you was accepted or not. Do this until all
@@ -254,7 +254,7 @@ libraries). If you do not need the support for some of these you can just freely
option will make sure that they are categorized inside directories in the *Solution Explorer*.
It is a must have feature, if you ask me.
![image](images/CMakeBuildOptionsOpenCV.jpg)
![](images/CMakeBuildOptionsOpenCV.jpg)
Furthermore, you need to select what part of OpenCV you want to build.
@@ -286,24 +286,24 @@ libraries). If you do not need the support for some of these you can just freely
IDE at the startup. Now you need to build both the *Release* and the *Debug* binaries. Use the
drop-down menu on your IDE to change to another of these after building for one of them.
![image](images/ChangeBuildVisualStudio.jpg)
![](images/ChangeBuildVisualStudio.jpg)
In the end you can observe the built binary files inside the bin directory:
![image](images/OpenCVBuildResultWindows.jpg)
![](images/OpenCVBuildResultWindows.jpg)
For the documentation you need to explicitly issue the build commands on the *doc* project for
the PDF files and on the *doc_html* for the HTML ones. Each of these will call *Sphinx* to do
all the hard work. You can find the generated documentation inside the `Build/Doc/_html` for the
HTML pages and within the `Build/Doc` the PDF manuals.
![image](images/WindowsBuildDoc.png)
![](images/WindowsBuildDoc.png)
To collect the header and the binary files, that you will use during your own projects, into a
separate directory (simillary to how the pre-built binaries ship) you need to explicitely build
the *Install* project.
![image](images/WindowsBuildInstall.png)
![](images/WindowsBuildInstall.png)
This will create an *Install* directory inside the *Build* one collecting all the built binaries
into a single place. Use this only after you built both the *Release* and *Debug* versions.
@@ -314,7 +314,7 @@ libraries). If you do not need the support for some of these you can just freely
If everything is okay the *contours.exe* output should resemble the following image (if
built with Qt support):
![image](images/WindowsQtContoursOutput.png)
![](images/WindowsQtContoursOutput.png)
@note
If you use the GPU module (CUDA libraries) make sure you also upgrade to the latest drivers of
@@ -353,9 +353,9 @@ following new entry (right click in the application to bring up the menu):
%OPENCV_DIR%\bin
@endcode
![image](images/PathEditorOpenCVInsertNew.png)
![](images/PathEditorOpenCVInsertNew.png)
![image](images/PathEditorOpenCVSetPath.png)
![](images/PathEditorOpenCVSetPath.png)
Save it to the registry and you are done. If you ever change the location of your build directories
or want to try out your applicaton with a different build all you will need to do is to update the

View File

@@ -1,13 +1,13 @@
How to build applications with OpenCV inside the "Microsoft Visual Studio" {#tutorial_windows_visual_studio_Opencv}
==========================================================================
Everything I describe here will apply to the C\\C++ interface of OpenCV. I start out from the
Everything I describe here will apply to the `C\C++` interface of OpenCV. I start out from the
assumption that you have read and completed with success the @ref tutorial_windows_install tutorial.
Therefore, before you go any further make sure you have an OpenCV directory that contains the OpenCV
header files plus binaries and you have set the environment variables as described here
@ref tutorial_windows_install_path.
![image](images/OpenCV_Install_Directory.jpg)
![](images/OpenCV_Install_Directory.jpg)
The OpenCV libraries, distributed by us, on the Microsoft Windows operating system are in a
Dynamic Linked Libraries (*DLL*). These have the advantage that all the content of the
@@ -58,7 +58,7 @@ create a new solution inside Visual studio by going through the File --\> New --
selection. Choose *Win32 Console Application* as type. Enter its name and select the path where to
create it. Then in the upcoming dialog make sure you create an empty project.
![image](images/NewProjectVisualStudio.jpg)
![](images/NewProjectVisualStudio.jpg)
The *local* method
------------------
@@ -75,7 +75,7 @@ you can view and modify them by using the *Property Manger*. You can bring up th
View --\> Property Pages. Expand it and you can see the existing rule packages (called *Proporty
Sheets*).
![image](images/PropertyPageExample.jpg)
![](images/PropertyPageExample.jpg)
The really useful stuff of these is that you may create a rule package *once* and you can later just
add it to your new projects. Create it once and reuse it later. We want to create a new *Property
@@ -83,7 +83,7 @@ Sheet* that will contain all the rules that the compiler and linker needs to kno
need a separate one for the Debug and the Release Builds. Start up with the Debug one as shown in
the image below:
![image](images/AddNewPropertySheet.jpg)
![](images/AddNewPropertySheet.jpg)
Use for example the *OpenCV_Debug* name. Then by selecting the sheet Right Click --\> Properties.
In the following I will show to set the OpenCV rules locally, as I find unnecessary to pollute
@@ -93,7 +93,7 @@ group, you should add any .c/.cpp file to the project.
@code{.bash}
\f$(OPENCV_DIR)\..\..\include
@endcode
![image](images/PropertySheetOpenCVInclude.jpg)
![](images/PropertySheetOpenCVInclude.jpg)
When adding third party libraries settings it is generally a good idea to use the power behind the
environment variables. The full location of the OpenCV library may change on each system. Moreover,
@@ -111,15 +111,15 @@ directory:
$(OPENCV_DIR)\lib
@endcode
![image](images/PropertySheetOpenCVLib.jpg)
![](images/PropertySheetOpenCVLib.jpg)
Then you need to specify the libraries in which the linker should look into. To do this go to the
Linker --\> Input and under the *"Additional Dependencies"* entry add the name of all modules which
you want to use:
![image](images/PropertySheetOpenCVLibrariesDebugSmple.jpg)
![](images/PropertySheetOpenCVLibrariesDebugSmple.jpg)
![image](images/PropertySheetOpenCVLibrariesDebug.jpg)
![](images/PropertySheetOpenCVLibrariesDebug.jpg)
The names of the libraries are as follow:
@code{.bash}
@@ -150,19 +150,19 @@ click ok to save and do the same with a new property inside the Release rule sec
omit the *d* letters from the library names and to save the property sheets with the save icon above
them.
![image](images/PropertySheetOpenCVLibrariesRelease.jpg)
![](images/PropertySheetOpenCVLibrariesRelease.jpg)
You can find your property sheets inside your projects directory. At this point it is a wise
decision to back them up into some special directory, to always have them at hand in the future,
whenever you create an OpenCV project. Note that for Visual Studio 2010 the file extension is
*props*, while for 2008 this is *vsprops*.
![image](images/PropertySheetInsideFolder.jpg)
![](images/PropertySheetInsideFolder.jpg)
Next time when you make a new OpenCV project just use the "Add Existing Property Sheet..." menu
entry inside the Property Manager to easily add the OpenCV build rules.
![image](images/PropertyPageAddExisting.jpg)
![](images/PropertyPageAddExisting.jpg)
The *global* method
-------------------
@@ -175,12 +175,12 @@ by using for instance: a Property page.
In Visual Studio 2008 you can find this under the:
Tools --\> Options --\> Projects and Solutions --\> VC++ Directories.
![image](images/VCDirectories2008.jpg)
![](images/VCDirectories2008.jpg)
In Visual Studio 2010 this has been moved to a global property sheet which is automatically added to
every project you create:
![image](images/VCDirectories2010.jpg)
![](images/VCDirectories2010.jpg)
The process is the same as described in case of the local approach. Just add the include directories
by using the environment variable *OPENCV_DIR*.
@@ -210,7 +210,7 @@ OpenCV logo](samples/data/opencv-logo.png). Before starting up the application m
the image file in your current working directory. Modify the image file name inside the code to try
it out on other images too. Run it and voil á:
![image](images/SuccessVisualStudioWindows.jpg)
![](images/SuccessVisualStudioWindows.jpg)
Command line arguments with Visual Studio
-----------------------------------------
@@ -230,7 +230,7 @@ with the console window on the Microsoft Windows many people come to use it almo
adding the same argument again and again while you are testing your application is, somewhat, a
cumbersome task. Luckily, in the Visual Studio there is a menu to automate all this:
![image](images/VisualStudioCommandLineArguments.jpg)
![](images/VisualStudioCommandLineArguments.jpg)
Specify here the name of the inputs and while you start your application from the Visual Studio
enviroment you have automatic argument passing. In the next introductionary tutorial you'll see an

View File

@@ -10,10 +10,10 @@ Prerequisites
This tutorial assumes that you have the following available:
1. Visual Studio 2012 Professional (or better) with Update 1 installed. Update 1 can be downloaded
-# Visual Studio 2012 Professional (or better) with Update 1 installed. Update 1 can be downloaded
[here](http://www.microsoft.com/en-us/download/details.aspx?id=35774).
2. An OpenCV installation on your Windows machine (Tutorial: @ref tutorial_windows_install).
3. Ability to create and build OpenCV projects in Visual Studio (Tutorial: @ref tutorial_windows_visual_studio_Opencv).
-# An OpenCV installation on your Windows machine (Tutorial: @ref tutorial_windows_install).
-# Ability to create and build OpenCV projects in Visual Studio (Tutorial: @ref tutorial_windows_visual_studio_Opencv).
Installation
------------
@@ -98,13 +98,13 @@ Launch the program in the debugger (Debug --\> Start Debugging, or hit *F5*). Wh
hit, the program is paused and Visual Studio displays a yellow instruction pointer at the
breakpoint:
![image](images/breakpoint.png)
![](images/breakpoint.png)
Now you can inspect the state of you program. For example, you can bring up the *Locals* window
(Debug --\> Windows --\> Locals), which will show the names and values of the variables in the
current scope:
![image](images/vs_locals.png)
![](images/vs_locals.png)
Note that the built-in *Locals* window will display text only. This is where the Image Watch plug-in
comes in. Image Watch is like another *Locals* window, but with an image viewer built into it. To
@@ -114,7 +114,7 @@ had Image Watch open, and where it was located between debugging sessions. This
to do this once--the next time you start debugging, Image Watch will be back where you left it.
Here's what the docked Image Watch window looks like at our breakpoint:
![image](images/toolwindow.jpg)
![](images/toolwindow.jpg)
The radio button at the top left (*Locals/Watch*) selects what is shown in the *Image List* below:
*Locals* lists all OpenCV image objects in the current scope (this list is automatically populated).
@@ -128,7 +128,7 @@ If an image has a thumbnail, left-clicking on that image will select it for deta
*Image Viewer* on the right. The viewer lets you pan (drag mouse) and zoom (mouse wheel). It also
displays the pixel coordinate and value at the current mouse position.
![image](images/viewer.jpg)
![](images/viewer.jpg)
Note that the second image in the list, *edges*, is shown as "invalid". This indicates that some
data members of this image object have corrupt or invalid values (for example, a negative image
@@ -146,18 +146,18 @@ Now assume you want to do a visual sanity check of the *cv::Canny()* implementat
*edges* image into the viewer by selecting it in the *Image List* and zoom into a region with a
clearly defined edge:
![image](images/edges_zoom.png)
![](images/edges_zoom.png)
Right-click on the *Image Viewer* to bring up the view context menu and enable Link Views (a check
box next to the menu item indicates whether the option is enabled).
![image](images/viewer_context_menu.png)
![](images/viewer_context_menu.png)
The Link Views feature keeps the view region fixed when flipping between images of the same size. To
see how this works, select the input image from the image list--you should now see the corresponding
zoomed-in region in the input image:
![image](images/input_zoom.png)
![](images/input_zoom.png)
You may also switch back and forth between viewing input and edges with your up/down cursor keys.
That way you can easily verify that the detected edges line up nicely with the data in the input
@@ -168,12 +168,12 @@ More ...
Image watch has a number of more advanced features, such as
1. pinning images to a *Watch* list for inspection across scopes or between debugging sessions
2. clamping, thresholding, or diff'ing images directly inside the Watch window
3. comparing an in-memory image against a reference image from a file
-# pinning images to a *Watch* list for inspection across scopes or between debugging sessions
-# clamping, thresholding, or diff'ing images directly inside the Watch window
-# comparing an in-memory image against a reference image from a file
Please refer to the online [Image Watch
Documentation](http://go.microsoft.com/fwlink/?LinkId=285461) for details--you also can get to the
documentation page by clicking on the *Help* link in the Image Watch window:
![image](images/help_button.jpg)
![](images/help_button.jpg)