Merge branch '2.4'
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Tue, 12 Feb 2013 12:30:18 +0000 (16:30 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Tue, 12 Feb 2013 12:30:18 +0000 (16:30 +0400)
13 files changed:
1  2 
CMakeLists.txt
doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.rst
doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.rst
modules/core/src/arithm.cpp
modules/ocl/src/filtering.cpp
modules/ocl/src/kernels/blend_linear.cl
modules/python/test/test2.py
modules/ts/src/ts_perf.cpp
platforms/linux/scripts/cmake_arm_gnueabi_hardfp.sh
platforms/linux/scripts/cmake_arm_gnueabi_softfp.sh
samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java
samples/android/tutorial-1-camerapreview/CMakeLists.txt
samples/android/tutorial-3-cameracontrol/CMakeLists.txt

diff --cc CMakeLists.txt
Simple merge
@@@ -17,15 -17,17 +17,17 @@@ For example in the above image you can 
  *Mat*
  =====
  
- OpenCV has been around ever since 2001. In those days the library was built around a *C* interface. In those days to store the image in the memory they used a C structure entitled *IplImage*. This is the one you'll see in most of the older tutorials and educational materials. The problem with this is that it brings to the table all the minuses of the C language. The biggest issue is the manual management. It builds on the assumption that the user is responsible for taking care of memory allocation and deallocation. While this is no issue in case of smaller programs once your code base start to grove larger and larger it will be more and more a struggle to handle all this rather than focusing on actually solving your development goal.
+ OpenCV has been around since 2001. In those days the library was built around a *C* interface and to store the image in the memory they used a C structure called *IplImage*. This is the one you'll see in most of the older tutorials and educational materials. The problem with this is that it brings to the table all the minuses of the C language. The biggest issue is the manual memory management. It builds on the assumption that the user is responsible for taking care of memory allocation and deallocation. While this is not a problem with smaller programs, once your code base grows it will be more of a struggle to handle all this rather than focusing on solving your development goal.
  
- Luckily C++ came around and introduced the concept of classes making possible to build another road for the user: automatic memory management (more or less). The good news is that C++ if fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV with its 2.0 version introduced a new C++ interface that by taking advantage of these offers a new way of doing things. A way, in which you do not need to fiddle with memory management; making your code concise (less to write, to achieve more). The only main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting this platform, there's no point on using the *old* methods (unless you're a masochist programmer and you're asking for trouble).
 -Luckily C++ came around and introduced the concept of classes making easier for the user through automatic memory management (more or less). The good news is that C++ is fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV 2.0 introduced a new C++ interface which offered a new way of doing things which means you do not need to fiddle with memory management, making your code concise (less to write, to achieve more). The main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting embedded platforms, there's no point to using the *old* methods (unless you're a masochist programmer and you're asking for trouble). 
++Luckily C++ came around and introduced the concept of classes making easier for the user through automatic memory management (more or less). The good news is that C++ is fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV 2.0 introduced a new C++ interface which offered a new way of doing things which means you do not need to fiddle with memory management, making your code concise (less to write, to achieve more). The main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting embedded platforms, there's no point to using the *old* methods (unless you're a masochist programmer and you're asking for trouble).
  
- The first thing you need to know about *Mat* is that you no longer need to manually allocate its size and release it as soon as you do not need it. While doing this is still a possibility, most of the OpenCV functions will allocate its output data manually. As a nice bonus if you pass on an already existing *Mat* object, what already has allocated the required space for the matrix, this will be reused. In other words we use at all times only as much memory as much we must to perform the task.
+ The first thing you need to know about *Mat* is that you no longer need to manually allocate its memory and release it as soon as you do not need it. While doing this is still a possibility, most of the OpenCV functions will allocate its output data manually. As a nice bonus if you pass on an already existing *Mat* object, which has already  allocated the required space for the matrix, this will be reused. In other words we use at all times only as much memory as we need to perform the task.
  
- *Mat* is basically a class having two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored and so on) and a pointer to the matrix containing the pixel values (may take any dimensionality depending on the method chosen for storing) . The matrix header size is constant. However, the size of the matrix itself may vary from image to image and usually is larger by order of magnitudes. Therefore, when you're passing on images in your program and at some point you need to create a copy of the image the big price you will need to build is for the matrix itself rather than its header. OpenCV is an image processing library. It contains a large collection of image processing functions. To solve a computational challenge most of the time you will end up using multiple functions of the library. Due to this passing on images to functions is a common practice. We should not forget that we are talking about image processing algorithms, which tend to be quite computational heavy. The last thing we want to do is to further decrease the speed of your program by making unnecessary copies of potentially *large* images.
 -*Mat* is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude. 
++*Mat* is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude.
  
- To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointer point to the same address. Moreover, the copy operators **will only copy the headers**, and as also copy the pointer to the large matrix too, however not the matrix itself.
+ OpenCV is an image processing library. It contains a large collection of image processing functions. To solve a computational challenge, most of the time you will end up using multiple functions of the library. Because of this, passing images to functions is a common practice. We should not forget that we are talking about image processing algorithms, which tend to be quite computational heavy. The last thing we want to do is  further decrease the speed of your program by making unnecessary copies of potentially *large* images.
 -To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointers point to the same address. Moreover, the copy operators **will only copy the headers** and the pointer to the large matrix, not the data itself. 
++To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointers point to the same address. Moreover, the copy operators **will only copy the headers** and the pointer to the large matrix, not the data itself.
  
  .. code-block:: cpp
     :linenos:
  
     C = A;                                    // Assignment operator
  
- All the above objects, in the end point to the same single data matrix. Their headers are different, however making any modification using either one of them will affect all the other ones too. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part comes that you can create headers that refer only to a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries:
 -All the above objects, in the end, point to the same single data matrix. Their headers are different, however, and making a modification using any of them will affect all the other ones as well. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part is that you can create headers which refer to only a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries: 
++All the above objects, in the end, point to the same single data matrix. Their headers are different, however, and making a modification using any of them will affect all the other ones as well. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part is that you can create headers which refer to only a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries:
  
  .. code-block:: cpp
     :linenos:
  
     Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle
 -   Mat E = A(Range:all(), Range(1,3)); // using row and column boundaries 
 +   Mat E = A(Range:all(), Range(1,3)); // using row and column boundaries
  
- Now you may ask if the matrix itself may belong to multiple *Mat* objects who will take responsibility for its cleaning when it's no longer needed. The short answer is: the last object that used it. For this a reference counting mechanism is used. Whenever somebody copies a header of a *Mat* object a counter is increased for the matrix. Whenever a header is cleaned this counter is decreased. When the counter reaches zero the matrix too is freed. Because, sometimes you will still want to copy the matrix itself too, there exists the :basicstructures:`clone() <mat-clone>` or the :basicstructures:`copyTo() <mat-copyto>` function.
+ Now you may ask if the matrix itself may belong to multiple *Mat* objects who takes responsibility for cleaning it up when it's no longer needed. The short answer is: the last object that used it. This is handled by using a reference counting mechanism. Whenever somebody copies a header of a *Mat* object, a counter is increased for the matrix. Whenever a header is cleaned this counter is decreased. When the counter reaches zero the matrix too is freed. Sometimes you will want to copy the matrix itself too, so OpenCV provides the :basicstructures:`clone() <mat-clone>` and :basicstructures:`copyTo() <mat-copyto>` functions.
  
  .. code-block:: cpp
     :linenos:
@@@ -59,34 -61,34 +61,34 @@@ Now modifying *F* or *G* will not affec
  .. container:: enumeratevisibleitemswithsquare
  
     * Output image allocation for OpenCV functions is automatic (unless specified otherwise).
-    * No need to think about memory freeing with OpenCVs C++ interface.
-    * The assignment operator and the copy constructor (*ctor*)copies only the header.
-    * Use the :basicstructures:`clone()<mat-clone>` or the :basicstructures:`copyTo() <mat-copyto>` function to copy the underlying matrix of an image.
+    * You do not need to think about memory management with OpenCVs C++ interface.
+    * The assignment operator and the copy constructor only copies the header.
+    * The underlying matrix of an image may be copied using the :basicstructures:`clone()<mat-clone>` and :basicstructures:`copyTo() <mat-copyto>` functions.
  
  *Storing* methods
 -================= 
 +=================
  
- This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale. Here the colors at our disposal are black and white. The combination of these allows us to create many shades of gray.
 -This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale where the colors at our disposal are black and white. The combination of these allows us to create many shades of gray. 
++This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale where the colors at our disposal are black and white. The combination of these allows us to create many shades of gray.
  
- For *colorful* ways we have a lot more of methods to choose from. However, every one of them breaks it down to three or four basic components and the combination of this will give all others. The most popular one of this is RGB, mainly because this is also how our eye builds up colors in our eyes. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added.
 -For *colorful* ways we have a lot more methods to choose from. Each of them breaks it down to three or four basic components and we can use the combination of these to create the others. The most popular one is RGB, mainly because this is also how our eye builds up colors. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added. 
++For *colorful* ways we have a lot more methods to choose from. Each of them breaks it down to three or four basic components and we can use the combination of these to create the others. The most popular one is RGB, mainly because this is also how our eye builds up colors. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added.
  
However, they are many color systems each with their own advantages:
There are, however, many other color systems each with their own advantages:
  
  .. container:: enumeratevisibleitemswithsquare
  
     * RGB is the most common as our eyes use something similar, our display systems also compose colors using these.
-    * The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors. Using you may for example dismiss the last component, making your algorithm less sensible to light conditions of the input image.
 -   * The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors.  You might, for example, dismiss the last component, making your algorithm less sensible to the light conditions of the input image. 
 -   * YCrCb is used by the popular JPEG image format. 
++   * The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors.  You might, for example, dismiss the last component, making your algorithm less sensible to the light conditions of the input image.
 +   * YCrCb is used by the popular JPEG image format.
     * CIE L*a*b* is a perceptually uniform color space, which comes handy if you need to measure the *distance* of a given color to another color.
  
Now each of the building components has their own valid domains. This leads to the data type used. How we store a component defines just how fine control we have over its domain. The smallest data type possible is *char*, which means one byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or signed (values from -127 to +127). Although in case of three components this already gives 16 million possible colors to represent (like in case of RGB) we may acquire an even finer control by using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for each component. Nevertheless, remember that increasing the size of a component also increases the size of the whole picture in the memory.
Each of the building components has their own valid domains. This leads to the data type used. How we store a component defines the control we have over its domain. The smallest data type possible is *char*, which means one byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or signed (values from -127 to +127). Although in case of three components this already gives 16 million possible colors to represent (like in case of RGB) we may acquire an even finer control by using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for each component. Nevertheless, remember that increasing the size of a component also increases the size of the whole picture in the memory.
  
- Creating explicitly a *Mat* object
+ Creating a *Mat* object explicitly
  ==================================
  
- In the :ref:`Load_Save_Image` tutorial you could already see how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can achieve this via the << operator of *Mat*. However, be aware that this only works for two dimensional matrices.
 -In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices. 
++In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices.
  
- Although *Mat* is a great class as image container it is also a general matrix class. Therefore, it is possible to create and manipulate multidimensional matrices. You can create a Mat object in multiple ways:
+ Although *Mat* works really well as an image container, it is also a general matrix class. Therefore, it is possible to create and manipulate multidimensional matrices. You can create a Mat object in multiple ways:
  
  .. container:: enumeratevisibleitemswithsquare
  
  
      For two dimensional and multichannel images we first define their size: row and column count wise.
  
-     Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions made according to the following convention:
 -    Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions constructed according to the following convention: 
++    Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions constructed according to the following convention:
  
      .. code-block:: cpp
  
          :alt: Demo image of the matrix output
          :align: center
  
 -.. note:: 
 +.. note::
  
-    You can fill out a matrix with random values using the :operationsOnArrays:`randu() <randu>` function. You need to give the lower and upper value between what you want the random values:
+    You can fill out a matrix with random values using the :operationsOnArrays:`randu() <randu>` function. You need to give the lower and upper value for the random values:
  
     .. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
        :language: cpp
        :lines:  57-58
  
  
Print out formatting
- ====================
Output formatting
+ =================
  
- In the above examples you could see the default formatting option. Nevertheless, OpenCV allows you to format your matrix output format to fit the rules of:
 -In the above examples you could see the default formatting option. OpenCV, however, allows you to format your matrix output: 
++In the above examples you could see the default formatting option. OpenCV, however, allows you to format your matrix output:
  
  .. container:: enumeratevisibleitemswithsquare
  
@@@ -78,48 -78,42 +78,42 @@@ See the "15-puzzle" OpenCV sample for d
  .. code-block:: java
      :linenos:
  
-     public class MyActivity extends Activity implements HelperCallbackInterface
-     {
-     private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
-        @Override
-        public void onManagerConnected(int status) {
-          switch (status) {
-            case LoaderCallbackInterface.SUCCESS:
-            {
-               Log.i(TAG, "OpenCV loaded successfully");
-               // Create and set View
-               mView = new puzzle15View(mAppContext);
-               setContentView(mView);
-            } break;
-            default:
-            {
-               super.onManagerConnected(status);
-            } break;
-          }
-        }
-     };
-     /** Call on every application resume **/
-     @Override
-     protected void onResume()
-     {
-         Log.i(TAG, "called onResume");
-         super.onResume();
-         Log.i(TAG, "Trying to load OpenCV library");
-         if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
+     public class Sample1Java extends Activity implements CvCameraViewListener {
+         private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
+             @Override
+             public void onManagerConnected(int status) {
+                 switch (status) {
+                     case LoaderCallbackInterface.SUCCESS:
+                     {
+                         Log.i(TAG, "OpenCV loaded successfully");
+                         mOpenCvCameraView.enableView();
+                     } break;
+                     default:
+                     {
+                         super.onManagerConnected(status);
+                     } break;
+                 }
+             }
+         };
+         @Override
+         public void onResume()
          {
-             Log.e(TAG, "Cannot connect to OpenCV Manager");
+             super.onResume();
+             OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
          }
+         ...
      }
  
 -It this case application works with OpenCV Manager in asynchronous fashion. ``OnManagerConnected`` 
 -callback will be called in UI thread, when initialization finishes. Please note, that it is not 
 -allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback. 
 -Load your own native libraries that depend on OpenCV after the successful OpenCV initialization. 
 -Default ``BaseLoaderCallback`` implementation treat application context as Activity and calls 
 -``Activity.finish()`` method to exit in case of initialization failure. To override this behavior 
 -you need to override ``finish()`` method of ``BaseLoaderCallback`` class and implement your own 
 +It this case application works with OpenCV Manager in asynchronous fashion. ``OnManagerConnected``
 +callback will be called in UI thread, when initialization finishes. Please note, that it is not
 +allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback.
 +Load your own native libraries that depend on OpenCV after the successful OpenCV initialization.
 +Default ``BaseLoaderCallback`` implementation treat application context as Activity and calls
 +``Activity.finish()`` method to exit in case of initialization failure. To override this behavior
 +you need to override ``finish()`` method of ``BaseLoaderCallback`` class and implement your own
  finalization method.
  
  
@@@ -292,117 -286,64 +286,64 @@@ taken
  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 
 +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.
  
 -#. 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
-    :menuselection:`File --> New --> Android Project`.
- #. Set name, target, package and ``minSDKVersion`` accordingly.
- #. Create a new class :menuselection:`File -> New -> Class`. Name it for example:
-    *HelloOpenCVView*.
-    .. image:: images/dev_OCV_new_class.png
-         :alt: Add a new class.
-         :align: center
+    :menuselection:`File --> New --> Android Project`
  
-    * It should extend ``SurfaceView`` class.
-    * It also should implement ``SurfaceHolder.Callback``, ``Runnable``.
+ #. 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.
  
- #. Edit ``HelloOpenCVView`` class.
+ #. Allow Eclipse to create default activity. Lets name the activity ``HelloOpenCvActivity``.
  
   * Add an ``import`` line for ``android.content.context``.
#. Choose Blank Activity with full screen layout. Lets name the layout ``HelloOpenCvLayout``.
  
-    * Modify autogenerated stubs: ``HelloOpenCVView``, ``surfaceCreated``, ``surfaceDestroyed`` and
-      ``surfaceChanged``.
-      .. code-block:: java
-         :linenos:
-         package com.hello.opencv.test;
-         import android.content.Context;
-         public class HelloOpenCVView extends SurfaceView implements Callback, Runnable {
-         public HelloOpenCVView(Context context) {
-             super(context);
-             getHolder().addCallback(this);
-         }
-         public void surfaceCreated(SurfaceHolder holder) {
-             (new Thread(this)).start();
-         }
+ #. Import OpenCV library project to your workspace.
  
-         public void surfaceDestroyed(SurfaceHolder holder) {
-             cameraRelease();
-         }
-         public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
-             cameraSetup(width, height);
-         }
+ #. Reference OpenCV library within your project properties.
  
-    * Add ``cameraOpen``, ``cameraRelease`` and ``cameraSetup`` voids as shown below.
+    .. image:: images/dev_OCV_reference.png
+         :alt: Reference OpenCV library.
+         :align: center
  
   * Also, don't forget to add the public void ``run()`` as follows:
#. Edit your layout file as xml file and pass the following layout there:
  
-      .. code-block:: java
+     .. code-block:: xml
          :linenos:
  
-         public void run() {
-             // TODO: loop { getFrame(), processFrame(), drawFrame() }
-         }
+         <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             xmlns:tools="http://schemas.android.com/tools"
+             xmlns:opencv="http://schemas.android.com/apk/res-auto"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent" >
  
-         public boolean cameraOpen() {
-             return false; //TODO: open camera
-         }
+             <org.opencv.android.JavaCameraView
+                 android:layout_width="fill_parent"
+                 android:layout_height="fill_parent"
+                 android:visibility="gone"
+                 android:id="@+id/HelloOpenCvView"
+                 opencv:show_fps="true"
+                 opencv:camera_id="any" />
  
-         private void cameraRelease() {
-             // TODO release camera
-         }
-         private void cameraSetup(int width, int height) {
-             // TODO setup camera
-         }
+         </LinearLayout>
  
- #. Create a new ``Activity`` :menuselection:`New -> Other -> Android -> Android Activity` and name
-    it, for example: *HelloOpenCVActivity*. For this activity define ``onCreate``, ``onResume`` and
-    ``onPause`` voids.
+ #. Add the following permissions to the :file:`AndroidManifest.xml` file:
  
-    .. code-block:: java
+    .. code-block:: xml
        :linenos:
  
-       public void onCreate (Bundle savedInstanceState) {
-           super.onCreate(savedInstanceState);
-           mView = new HelloOpenCVView(this);
-           setContentView (mView);
-       }
+       </application>
  
-       protected void onPause() {
-           super.onPause();
-           mView.cameraRelease();
-       }
+       <uses-permission android:name="android.permission.CAMERA"/>
  
-       protected void onResume() {
-           super.onResume();
-           if( !mView.cameraOpen() ) {
-               // MessageBox and exit app
-               AlertDialog ad = new AlertDialog.Builder(this).create();
-               ad.setCancelable(false); // This blocks the "BACK" button
-               ad.setMessage("Fatal error: can't open camera!");
-               ad.setButton("OK", new DialogInterface.OnClickListener() {
-                   public void onClick(DialogInterface dialog, int which) {
-                       dialog.dismiss();
-                       finish();
-                   }
-               });
-               ad.show();
-           }
-       }
+       <uses-feature android:name="android.hardware.camera" android:required="false"/>
+       <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
+       <uses-feature android:name="android.hardware.camera.front" android:required="false"/>
+       <uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
  
- #. Add the following permissions to the :file:`AndroidManifest.xml` file:
+ #. Set application theme in AndroidManifest.xml to hide title and system buttons.
  
     .. code-block:: xml
        :linenos:
@@@ -1242,11 -1242,15 +1242,15 @@@ static void arithm_op(InputArray _src1
      Mat src1 = _src1.getMat(), src2 = _src2.getMat();
      bool haveMask = !_mask.empty();
      bool reallocate = false;
 -    
 -    bool src1Scalar = checkScalar(src1, src2.type(), kind1, kind2); 
 -    bool src2Scalar = checkScalar(src2, src1.type(), kind2, kind1); 
 +
++    bool src1Scalar = checkScalar(src1, src2.type(), kind1, kind2);
++    bool src2Scalar = checkScalar(src2, src1.type(), kind2, kind1);
      if( (kind1 == kind2 || src1.channels() == 1) && src1.dims <= 2 && src2.dims <= 2 &&
          src1.size() == src2.size() && src1.type() == src2.type() &&
          !haveMask && ((!_dst.fixedType() && (dtype < 0 || CV_MAT_DEPTH(dtype) == src1.depth())) ||
-                        (_dst.fixedType() && _dst.type() == _src1.type())) )
 -                       (_dst.fixedType() && _dst.type() == _src1.type())) && 
++                       (_dst.fixedType() && _dst.type() == _src1.type())) &&
+         ((src1Scalar && src2Scalar) || (!src1Scalar && !src2Scalar)) )
      {
          _dst.create(src1.size(), src1.type());
          Mat dst = _dst.getMat();
@@@ -332,7 -334,8 +334,8 @@@ public
  **Extend this if necessary later.
  **Note that the kernel need to be further refined.
  */
- static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, const Point anchor)
 -static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel, 
++static void GPUErode(const oclMat &src, oclMat &dst, oclMat &mat_kernel,
+                          Size &ksize, const Point anchor, bool rectKernel, bool useROI)
  {
      //Normalize the result by default
      //float alpha = ksize.height * ksize.width;
      }
  
      char compile_option[128];
-     sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s", anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], s);
 -    sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s %s %s", 
 -        anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], 
 -          rectKernel?"-D RECTKERNEL":"",
 -          useROI?"-D USEROI":"",
 -          s);
++    sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D ERODE %s %s %s",
++        anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1],
++        rectKernel?"-D RECTKERNEL":"",
++        useROI?"-D USEROI":"",
++        s);
      vector< pair<size_t, const void *> > args;
      args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data));
      args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data));
  
  
  //! data type supported: CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4
- static void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, Size &ksize, const Point anchor)
 -static void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel, 
++static void GPUDilate(const oclMat &src, oclMat &dst, oclMat &mat_kernel,
+                           Size &ksize, const Point anchor, bool rectKernel, bool useROI)
  {
      //Normalize the result by default
      //float alpha = ksize.height * ksize.width;
      Context *clCxt = src.clCxt;
      string kernelName;
      size_t localThreads[3] = {16, 16, 1};
-     size_t globalThreads[3] = {(src.cols + localThreads[0]) / localThreads[0] *localThreads[0], (src.rows + localThreads[1]) / localThreads[1] *localThreads[1], 1};
 -    size_t globalThreads[3] = {(src.cols + localThreads[0] - 1) / localThreads[0] *localThreads[0], 
++    size_t globalThreads[3] = {(src.cols + localThreads[0] - 1) / localThreads[0] *localThreads[0],
+                                (src.rows + localThreads[1] - 1) / localThreads[1] *localThreads[1], 1};
  
      if (src.type() == CV_8UC1)
      {
      }
  
      char compile_option[128];
-     sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s", anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], s);
 -    sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s %s %s", 
 -        anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1], 
++    sprintf(compile_option, "-D RADIUSX=%d -D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D DILATE %s %s %s",
++        anchor.x, anchor.y, (int)localThreads[0], (int)localThreads[1],
+         rectKernel?"-D RECTKERNEL":"",
+         useROI?"-D USEROI":"",
+         s);
      vector< pair<size_t, const void *> > args;
      args.push_back(make_pair(sizeof(cl_mem), (void *)&src.data));
      args.push_back(make_pair(sizeof(cl_mem), (void *)&dst.data));
@@@ -56,14 -56,13 +56,13 @@@ __kernel void BlendLinear_C1_D0
  {
      int idx = get_global_id(0);
      int idy = get_global_id(1);
-     if (idx < cols && idy < rows)
+     if (idx << 2 < cols && idy < rows)
      {
-         int pos = mad24(idy,istep,idx);
-         int wpos = mad24(idy,wstep,idx);
-         float w1 = weight1[wpos];
-         float w2 = weight2[wpos];
-         dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f);
+         int pos = mad24(idy,istep >> 2,idx);
+         int wpos = mad24(idy,wstep >> 2,idx);
+         float4 w1 = weight1[wpos], w2 = weight2[wpos];
 -        dst[pos] = convert_uchar4((convert_float4(img1[pos]) * w1 + 
++        dst[pos] = convert_uchar4((convert_float4(img1[pos]) * w1 +
+             convert_float4(img2[pos]) * w2) / (w1 + w2 + 1e-5f));
      }
  }
  
@@@ -81,15 -80,14 +80,14 @@@ __kernel void BlendLinear_C4_D0
  {
      int idx = get_global_id(0);
      int idy = get_global_id(1);
-     int x = idx / 4;
-     int y = idy;
-     if (x < cols && y < rows)
+     if (idx < cols && idy < rows)
      {
-         int pos = mad24(idy,istep,idx);
-         int wpos = mad24(idy,wstep,x);
+         int pos = mad24(idy,istep >> 2,idx);
+         int wpos = mad24(idy,wstep, idx);
          float w1 = weight1[wpos];
          float w2 = weight2[wpos];
-         dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f);
 -        dst[pos] = convert_uchar4((convert_float4(img1[pos]) * w1 + 
++        dst[pos] = convert_uchar4((convert_float4(img1[pos]) * w1 +
+             convert_float4(img2[pos]) * w2) / (w1 + w2 + 1e-5f));
      }
  }
  
@@@ -35,14 -35,14 +35,14 @@@ class NewOpenCVTests(unittest.TestCase)
  # Tests to run first; check the handful of basic operations that the later tests rely on
  
  class Hackathon244Tests(NewOpenCVTests):
--    
++
      def test_int_array(self):
          a = np.array([-1, 2, -3, 4, -5])
          absa0 = np.abs(a)
          self.assert_(cv2.norm(a, cv2.NORM_L1) == 15)
          absa1 = cv2.absdiff(a, 0)
          self.assertEqual(cv2.norm(absa1, absa0, cv2.NORM_INF), 0)
--        
++
      def test_imencode(self):
          a = np.zeros((480, 640), dtype=np.uint8)
          flag, ajpg = cv2.imencode("img_q90.jpg", a, [cv2.IMWRITE_JPEG_QUALITY, 90])
@@@ -50,7 -50,7 +50,7 @@@
          self.assertEqual(ajpg.dtype, np.uint8)
          self.assertGreater(ajpg.shape[0], 1)
          self.assertEqual(ajpg.shape[1], 1)
--    
++
      def test_projectPoints(self):
          objpt = np.float64([[1,2,3]])
          imgpt0, jac0 = cv2.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), np.float64([]))
@@@ -59,7 -59,7 +59,7 @@@
          self.assertEqual(imgpt1.shape, imgpt0.shape)
          self.assertEqual(jac0.shape, jac1.shape)
          self.assertEqual(jac0.shape[0], 2*objpt.shape[0])
--        
++
      def test_estimateAffine3D(self):
          pattern_size = (11, 8)
          pattern_points = np.zeros((np.prod(pattern_size), 3), np.float32)
@@@ -71,7 -71,7 +71,7 @@@
              out[2,2]=1
          self.assertLess(cv2.norm(out, np.float64([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]])), 1e-3)
          self.assertEqual(cv2.countNonZero(inliers), pattern_size[0]*pattern_size[1])
--        
++
      def test_fast(self):
          fd = cv2.FastFeatureDetector(30, True)
          img = self.get_sample("samples/cpp/right02.jpg", 0)
          for kpt in keypoints:
              self.assertNotEqual(kpt.response, 0)
  
 -        
+     def check_close_angles(self, a, b, angle_delta):
+         self.assert_(abs(a - b) <= angle_delta or
+                      abs(360 - abs(a - b)) <= angle_delta)
+     def check_close_pairs(self, a, b, delta):
+         self.assertLessEqual(abs(a[0] - b[0]), delta)
+         self.assertLessEqual(abs(a[1] - b[1]), delta)
+     def check_close_boxes(self, a, b, delta, angle_delta):
+         self.check_close_pairs(a[0], b[0], delta)
+         self.check_close_pairs(a[1], b[1], delta)
+         self.check_close_angles(a[2], b[2], angle_delta)
+     def test_geometry(self):
+         npt = 100
+         np.random.seed(244)
+         a = np.random.randn(npt,2).astype('float32')*50 + 150
+         img = np.zeros((300, 300, 3), dtype='uint8')
+         be = cv2.fitEllipse(a)
+         br = cv2.minAreaRect(a)
+         mc, mr = cv2.minEnclosingCircle(a)
 -        
++
+         be0 = ((150.2511749267578, 150.77322387695312), (158.024658203125, 197.57696533203125), 37.57804489135742)
+         br0 = ((161.2974090576172, 154.41793823242188), (199.2301483154297, 207.7177734375), -9.164555549621582)
+         mc0, mr0 = (160.41790771484375, 144.55152893066406), 136.713500977
++
+         self.check_close_boxes(be, be0, 5, 15)
+         self.check_close_boxes(br, br0, 5, 15)
+         self.check_close_pairs(mc, mc0, 5)
+         self.assertLessEqual(abs(mr - mr0), 5)
  
  if __name__ == '__main__':
-     print "testing", cv.__version__
+     print "testing", cv2.__version__
      random.seed(0)
      unittest.main()
@@@ -156,11 -156,11 +156,11 @@@ Regression& Regression::addKeypoints(Te
  
  Regression& Regression::addMatches(TestBase* test, const std::string& name, const std::vector<cv::DMatch>& array, double eps, ERROR_TYPE err)
  {
 -    int len = (int)array.size();      
 +    int len = (int)array.size();
-     cv::Mat queryIdx(len, 1, CV_32SC1, (void*)&array[0].queryIdx, sizeof(cv::DMatch));
-     cv::Mat trainIdx(len, 1, CV_32SC1, (void*)&array[0].trainIdx, sizeof(cv::DMatch));
-     cv::Mat imgIdx  (len, 1, CV_32SC1, (void*)&array[0].imgIdx,   sizeof(cv::DMatch));
-     cv::Mat distance(len, 1, CV_32FC1, (void*)&array[0].distance, sizeof(cv::DMatch));
+     cv::Mat queryIdx(len, 1, CV_32SC1, len ? (void*)&array[0].queryIdx : 0, sizeof(cv::DMatch));
+     cv::Mat trainIdx(len, 1, CV_32SC1, len ? (void*)&array[0].trainIdx : 0, sizeof(cv::DMatch));
+     cv::Mat imgIdx  (len, 1, CV_32SC1, len ? (void*)&array[0].imgIdx : 0,   sizeof(cv::DMatch));
+     cv::Mat distance(len, 1, CV_32FC1, len ? (void*)&array[0].distance : 0, sizeof(cv::DMatch));
  
      return Regression::add(test, name + "-queryIdx", queryIdx, DBL_EPSILON, ERROR_ABSOLUTE)
                                  (name + "-trainIdx", trainIdx, DBL_EPSILON, ERROR_ABSOLUTE)
index 0000000,f8df785..1d2153a
mode 000000,100755..100755
--- /dev/null
@@@ -1,0 -1,8 +1,7 @@@
 -
+ #!/bin/sh
+ cd `dirname $0`/..
+ mkdir -p build_hardfp
+ cd build_hardfp
+ cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake $@ ../../..
index 0000000,f4210fa..5caf5a4
mode 000000,100755..100755
--- /dev/null
@@@ -1,0 -1,8 +1,7 @@@
 -
+ #!/bin/sh
+ cd `dirname $0`/..
+ mkdir -p build_softfp
+ cd build_softfp
+ cmake -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake $@ ../../..
@@@ -4,4 -4,4 +4,3 @@@ add_android_project(${sample} "${CMAKE_
  if(TARGET ${sample})
    add_dependencies(opencv_android_examples ${sample})
  endif()
--
@@@ -4,4 -4,4 +4,3 @@@ add_android_project(${sample} "${CMAKE_
  if(TARGET ${sample})
    add_dependencies(opencv_android_examples ${sample})
  endif()
--