Added SharedMatrix

This commit is contained in:
Elena Gvozdeva
2014-03-27 17:40:50 +04:00
parent fa2d79a15b
commit 037ac27ec8
8 changed files with 198 additions and 77 deletions

View File

@@ -9,14 +9,14 @@ Goal
.. _hppiSobel: http://software.intel.com/en-us/node/474701
.. _hppiMatrix: http://software.intel.com/en-us/node/501660
The tutorial demonstrates the `Intel® IPP Asynchronous C/C++ <http://software.intel.com/en-us/intel-ipp-preview>`_ library usage with OpenCV.
The tutorial demonstrates the `Intel® IPP Asynchronous C/C++ <http://software.intel.com/en-us/intel-ipp-preview>`_ library usage with OpenCV.
The code example below illustrates implementation of the Sobel operation, accelerated with Intel® IPP Asynchronous C/C++ functions.
In this code example, :ippa_convert:`hpp::getMat <>` and :ippa_convert:`hpp::getHpp <>` functions are used for data conversion between hppiMatrix_ and ``Mat`` matrices.
Code
====
You may also find the source code in the :file:`samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp`
You may also find the source code in the :file:`samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp`
file of the OpenCV source library or :download:`download it from here
<../../../../samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp>`.
@@ -24,7 +24,7 @@ file of the OpenCV source library or :download:`download it from here
:language: cpp
:linenos:
:tab-width: 4
Explanation
===========
@@ -38,17 +38,17 @@ Explanation
and IPP Async:
.. code-block:: cpp
Ptr<hppiMatrix> src, dst;
hppiMatrix* src,* dst;
hppAccel accel = 0;
hppAccelType accelType;
hppStatus sts;
hppiVirtualMatrix * virtMatrix;
#. Load input image or video. How to open and read video stream you can see in the :ref:`videoInputPSNRMSSIM` tutorial.
.. code-block:: cpp
if( useCamera )
{
printf("used camera\n");
@@ -65,25 +65,25 @@ Explanation
printf("can not open camera or video file\n");
return -1;
}
#. Create accelerator instance using `hppCreateInstance <http://software.intel.com/en-us/node/501686>`_:
.. code-block:: cpp
accelType = sAccel == "cpu" ? HPP_ACCEL_TYPE_CPU:
sAccel == "gpu" ? HPP_ACCEL_TYPE_GPU:
HPP_ACCEL_TYPE_ANY;
//Create accelerator instance
sts = hppCreateInstance(accelType, 0, &accel);
CHECK_STATUS(sts, "hppCreateInstance");
#. Create an array of virtual matrices using `hppiCreateVirtualMatrices <http://software.intel.com/en-us/node/501700>`_ function.
.. code-block:: cpp
virtMatrix = hppiCreateVirtualMatrices(accel, 1);
#. Prepare a matrix for input and output data:
.. code-block:: cpp
@@ -95,14 +95,14 @@ Explanation
cvtColor( image, gray, COLOR_BGR2GRAY );
result.create( image.rows, image.cols, CV_8U);
#. Convert ``Mat`` to hppiMatrix_ using :ippa_convert:`getHpp <>` and call hppiSobel_ function.
.. code-block:: cpp
//convert Mat to hppiMatrix
src = getHpp(gray);
dst = getHpp(result);
src = getHpp(gray, accel);
dst = getHpp(result, accel);
sts = hppiSobel(accel,src, HPP_MASK_SIZE_3X3,HPP_NORM_L1,virtMatrix[0]);
CHECK_STATUS(sts,"hppiSobel");
@@ -113,7 +113,7 @@ Explanation
// Wait for tasks to complete
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
CHECK_STATUS(sts, "hppWait");
We use `hppiConvert <http://software.intel.com/en-us/node/501746>`_ because hppiSobel_ returns destination
matrix with ``HPP_DATA_TYPE_16S`` data type for source matrix with ``HPP_DATA_TYPE_8U`` type.
You should check ``hppStatus`` after each call IPP Async function.
@@ -126,7 +126,17 @@ Explanation
imshow("rez", result);
waitKey(15);
#. Delete hpp matrices.
.. code-block:: cpp
sts = hppiFreeMatrix(src);
CHECK_DEL_STATUS(sts,"hppiFreeMatrix");
sts = hppiFreeMatrix(dst);
CHECK_DEL_STATUS(sts,"hppiFreeMatrix");
#. Delete virtual matrices and accelerator instance.
.. code-block:: cpp
@@ -143,12 +153,10 @@ Explanation
CHECK_DEL_STATUS(sts, "hppDeleteInstance");
}
We shouldn't delete hppiMatrix_ because we use :ptr:`Ptr <>` and so `hppiFreeMatrix <http://software.intel.com/en-us/node/501699>`_ will be called implicitly.
Result
=======
After compiling the code above we can execute it giving an image or video path and accelerator type as an argument.
After compiling the code above we can execute it giving an image or video path and accelerator type as an argument.
For this tutorial we use baboon.png image as input. The result is below.
.. image:: images/How_To_Use_IPPA_Result.jpg

View File

@@ -204,7 +204,7 @@ Here you will learn the about the basic building blocks of the library. A must r
+
.. tabularcolumns:: m{100pt} m{300pt}
.. cssclass:: toctableopencv
=============== ======================================================
|IPPIma| **Title:** :ref:`howToUseIPPAconversion`
@@ -213,15 +213,16 @@ Here you will learn the about the basic building blocks of the library. A must r
*Author:* |Author_ElenaG|
You will see how to use the IPP Async with OpenCV.
=============== ======================================================
.. |IPPIma| image:: images/How_To_Use_IPPA.jpg
:height: 90pt
:width: 90pt
.. |Author_ElenaG| unicode:: Elena U+0020 Gvozdeva
.. |Author_ElenaG| unicode:: Elena U+0020 Gvozdeva
=============== ======================================================
.. raw:: latex
\pagebreak