Merge pull request #12189 from alalek:ippa_cleanup_3.4

This commit is contained in:
Alexander Alekhin 2018-08-30 20:29:42 +00:00
commit 32a02544de
15 changed files with 3 additions and 566 deletions

View File

@ -1,45 +0,0 @@
# Main variables:
# IPP_A_LIBRARIES and IPP_A_INCLUDE to use IPP Async
# HAVE_IPP_A for conditional compilation OpenCV with/without IPP Async
# IPP_ASYNC_ROOT - root of IPP Async installation
if(X86_64)
find_path(
IPP_A_INCLUDE_DIR
NAMES ipp_async_defs.h
PATHS $ENV{IPP_ASYNC_ROOT}
PATH_SUFFIXES include
DOC "Path to Intel IPP Async interface headers")
find_file(
IPP_A_LIBRARIES
NAMES ipp_async_preview.lib
PATHS $ENV{IPP_ASYNC_ROOT}
PATH_SUFFIXES lib/intel64
DOC "Path to Intel IPP Async interface libraries")
else()
find_path(
IPP_A_INCLUDE_DIR
NAMES ipp_async_defs.h
PATHS $ENV{IPP_ASYNC_ROOT}
PATH_SUFFIXES include
DOC "Path to Intel IPP Async interface headers")
find_file(
IPP_A_LIBRARIES
NAMES ipp_async_preview.lib
PATHS $ENV{IPP_ASYNC_ROOT}
PATH_SUFFIXES lib/ia32
DOC "Path to Intel IPP Async interface libraries")
endif()
if(IPP_A_INCLUDE_DIR AND IPP_A_LIBRARIES)
set(HAVE_IPP_A TRUE)
else()
set(HAVE_IPP_A FALSE)
message(WARNING "Intel IPP Async library directory (set by IPP_A_LIBRARIES_DIR variable) is not found or does not have Intel IPP Async libraries.")
endif()
mark_as_advanced(FORCE IPP_A_LIBRARIES IPP_A_INCLUDE_DIR)

View File

@ -28,17 +28,6 @@ if(WITH_IPP)
endif()
endif()
# --- IPP Async ---
if(WITH_IPP_A)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPPAsync.cmake")
if(IPP_A_INCLUDE_DIR AND IPP_A_LIBRARIES)
ocv_include_directories(${IPP_A_INCLUDE_DIR})
link_directories(${IPP_A_LIBRARIES})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${IPP_A_LIBRARIES})
endif()
endif(WITH_IPP_A)
# --- CUDA ---
if(WITH_CUDA)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake")

View File

@ -106,9 +106,6 @@
#cmakedefine HAVE_IPP_ICV
#cmakedefine HAVE_IPP_IW
/* Intel IPP Async */
#cmakedefine HAVE_IPP_A
/* JPEG-2000 codec */
#cmakedefine HAVE_JASPER

View File

@ -227,7 +227,6 @@ SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = __cplusplus=1 \
HAVE_IPP_A=1 \
CVAPI(x)=x \
CV_DOXYGEN= \
CV_EXPORTS= \

View File

@ -1,7 +1,7 @@
How to use the OpenCV parallel_for_ to parallelize your code {#tutorial_how_to_use_OpenCV_parallel_for_}
==================================================================
@prev_tutorial{tutorial_how_to_use_ippa_conversion}
@prev_tutorial{tutorial_interoperability_with_OpenCV_1}
Goal
----

View File

@ -1,146 +0,0 @@
Intel® IPP Asynchronous C/C++ library in OpenCV {#tutorial_how_to_use_ippa_conversion}
===============================================
@prev_tutorial{tutorial_interoperability_with_OpenCV_1}
@next_tutorial{tutorial_how_to_use_OpenCV_parallel_for_}
Goal
----
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, @ref cv::hpp::getMat and @ref cv::hpp::getHpp
functions are used for data conversion between
[hppiMatrix](http://software.intel.com/en-us/node/501660) and Mat matrices.
Code
----
You may also find the source code in the
`samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp` file of the OpenCV source library or
download it from [here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/core/ippasync/ippasync_sample.cpp).
@include cpp/tutorial_code/core/ippasync/ippasync_sample.cpp
Explanation
-----------
-# Create parameters for OpenCV:
@code{.cpp}
VideoCapture cap;
Mat image, gray, result;
@endcode
and IPP Async:
@code{.cpp}
hppiMatrix* src,* dst;
hppAccel accel = 0;
hppAccelType accelType;
hppStatus sts;
hppiVirtualMatrix * virtMatrix;
@endcode
-# Load input image or video. How to open and read video stream you can see in the
@ref tutorial_video_input_psnr_ssim tutorial.
@code{.cpp}
if( useCamera )
{
printf("used camera\n");
cap.open(0);
}
else
{
printf("used image %s\n", file.c_str());
cap.open(file.c_str());
}
if( !cap.isOpened() )
{
printf("can not open camera or video file\n");
return -1;
}
@endcode
-# Create accelerator instance using
[hppCreateInstance](http://software.intel.com/en-us/node/501686):
@code{.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");
@endcode
-# Create an array of virtual matrices using
[hppiCreateVirtualMatrices](http://software.intel.com/en-us/node/501700) function.
@code{.cpp}
virtMatrix = hppiCreateVirtualMatrices(accel, 1);
@endcode
-# Prepare a matrix for input and output data:
@code{.cpp}
cap >> image;
if(image.empty())
break;
cvtColor( image, gray, COLOR_BGR2GRAY );
result.create( image.rows, image.cols, CV_8U);
@endcode
-# Convert Mat to [hppiMatrix](http://software.intel.com/en-us/node/501660) using @ref cv::hpp::getHpp
and call [hppiSobel](http://software.intel.com/en-us/node/474701) function.
@code{.cpp}
//convert Mat to hppiMatrix
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");
sts = hppiConvert(accel, virtMatrix[0], 0, HPP_RND_MODE_NEAR, dst, HPP_DATA_TYPE_8U);
CHECK_STATUS(sts,"hppiConvert");
// Wait for tasks to complete
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
CHECK_STATUS(sts, "hppWait");
@endcode
We use [hppiConvert](http://software.intel.com/en-us/node/501746) because
[hppiSobel](http://software.intel.com/en-us/node/474701) 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.
-# Create windows and show the images, the usual way.
@code{.cpp}
imshow("image", image);
imshow("rez", result);
waitKey(15);
@endcode
-# Delete hpp matrices.
@code{.cpp}
sts = hppiFreeMatrix(src);
CHECK_DEL_STATUS(sts,"hppiFreeMatrix");
sts = hppiFreeMatrix(dst);
CHECK_DEL_STATUS(sts,"hppiFreeMatrix");
@endcode
-# Delete virtual matrices and accelerator instance.
@code{.cpp}
if (virtMatrix)
{
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
CHECK_DEL_STATUS(sts,"hppiDeleteVirtualMatrices");
}
if (accel)
{
sts = hppDeleteInstance(accel);
CHECK_DEL_STATUS(sts, "hppDeleteInstance");
}
@endcode
Result
------
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.
![](images/How_To_Use_IPPA_Result.jpg)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -2,7 +2,7 @@ Interoperability with OpenCV 1 {#tutorial_interoperability_with_OpenCV_1}
==============================
@prev_tutorial{tutorial_file_input_output_with_xml_yml}
@next_tutorial{tutorial_how_to_use_ippa_conversion}
@next_tutorial{tutorial_how_to_use_OpenCV_parallel_for_}
Goal
----

View File

@ -93,15 +93,6 @@ understanding how to manipulate the images on a pixel level.
Look here to shed light on all this questions.
- @subpage tutorial_how_to_use_ippa_conversion
*Compatibility:* \> OpenCV 2.0
*Author:* Elena Gvozdeva
You will see how to use the IPP Async with OpenCV.
- @subpage tutorial_how_to_use_OpenCV_parallel_for_
*Compatibility:* \>= OpenCV 2.4.3

View File

@ -142,8 +142,6 @@ of them, you need to download and install them on your system.
- [Intel Integrated Performance Primitives (*IPP*)](http://software.intel.com/en-us/articles/intel-ipp/) may be used to improve the performance
of color conversion, Haar training and DFT functions of the OpenCV library. Watch out, since
this is not a free service.
- [Intel IPP Asynchronous C/C++](http://software.intel.com/en-us/intel-ipp-preview) is currently focused delivering Intel Graphics
support for advanced image processing and computer vision functions.
- OpenCV offers a somewhat fancier and more useful graphical user interface, than the default one
by using the [Qt framework](http://qt.nokia.com/downloads). For a quick overview of what this has to offer, look into the
documentations *highgui* module, under the *Qt New Functions* section. Version 4.6 or later of
@ -204,10 +202,6 @@ libraries). If you do not need the support for some of these, you can just freel
![](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
`<your Program Files(x86) directory>/Intel/IPP Preview */ipp directory`. Here \* denotes the
particular preview name.
-# In case of the [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page#Download) library it is again a case of download and extract to the
`D:/OpenCV/dep` directory.
-# Same as above with [OpenEXR](http://www.openexr.com/downloads.html).

View File

@ -45,7 +45,7 @@
#ifndef OPENCV_CORE_IPPASYNC_HPP
#define OPENCV_CORE_IPPASYNC_HPP
#ifdef HAVE_IPP_A
#ifdef HAVE_IPP_A // this file will be removed in OpenCV 4.0
#include "opencv2/core.hpp"
#include <ipp_async_op.h>

View File

@ -1,171 +0,0 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_IPP_A
#include "opencv2/core/ippasync.hpp"
using namespace cv;
using namespace std;
using namespace opencv_test;
namespace opencv_test {
namespace ocl {
PARAM_TEST_CASE(IPPAsync, MatDepth, Channels, hppAccelType)
{
int type;
int cn;
int depth;
hppAccelType accelType;
Mat matrix, result;
hppiMatrix * hppMat;
hppAccel accel;
hppiVirtualMatrix * virtMatrix;
hppStatus sts;
virtual void SetUp()
{
type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1));
depth = GET_PARAM(0);
cn = GET_PARAM(1);
accelType = GET_PARAM(2);
}
void generateTestData()
{
Size matrix_Size = randomSize(2, 100);
const double upValue = 100;
matrix = randomMat(matrix_Size, type, -upValue, upValue);
}
void Near(double threshold = 0.0)
{
EXPECT_MAT_NEAR(matrix, result, threshold);
}
};
TEST_P(IPPAsync, accuracy)
{
sts = hppCreateInstance(accelType, 0, &accel);
if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus = %d\n",sts);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
virtMatrix = hppiCreateVirtualMatrices(accel, 2);
for (int j = 0; j < test_loop_times; j++)
{
generateTestData();
hppMat = hpp::getHpp(matrix,accel);
hppScalar a = 3;
sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
result = hpp::getMat(virtMatrix[1], accel, cn);
Near(5.0e-6);
sts = hppiFreeMatrix(hppMat);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
}
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
sts = hppDeleteInstance(accel);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
}
PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
{
int cn;
int type;
hppAccelType accelType;
Mat matrix, result;
hppiMatrix* hppMat;
hppAccel accel;
hppiVirtualMatrix * virtMatrix;
hppStatus sts;
virtual void SetUp()
{
cn = GET_PARAM(0);
accelType = GET_PARAM(1);
type=CV_MAKE_TYPE(CV_8U, GET_PARAM(0));
}
void generateTestData()
{
Size matrix_Size = randomSize(2, 100);
hpp32u pitch, size;
const int upValue = 100;
sts = hppQueryMatrixAllocParams(accel, (hpp32u)(matrix_Size.width*cn), (hpp32u)matrix_Size.height, HPP_DATA_TYPE_8U, &pitch, &size);
matrix = randomMat(matrix_Size, type, 0, upValue);
}
void Near(double threshold = 0.0)
{
EXPECT_MAT_NEAR(matrix, result, threshold);
}
};
TEST_P(IPPAsyncShared, accuracy)
{
sts = hppCreateInstance(accelType, 0, &accel);
if (sts!=HPP_STATUS_NO_ERROR) printf("hppStatus = %d\n",sts);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
virtMatrix = hppiCreateVirtualMatrices(accel, 2);
for (int j = 0; j < test_loop_times; j++)
{
generateTestData();
hppMat = hpp::getHpp(matrix,accel);
hppScalar a = 3;
sts = hppiAddC(accel, hppMat, a, 0, virtMatrix[0]);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
sts = hppiSubC(accel, virtMatrix[0], a, 0, virtMatrix[1]);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
result = hpp::getMat(virtMatrix[1], accel, cn);
Near(0);
sts = hppiFreeMatrix(hppMat);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
}
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
sts = hppDeleteInstance(accel);
CV_Assert(sts==HPP_STATUS_NO_ERROR);
}
INSTANTIATE_TEST_CASE_P(IppATest, IPPAsyncShared, Combine(Values(1, 2, 3, 4),
Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
INSTANTIATE_TEST_CASE_P(IppATest, IPPAsync, Combine(Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(1, 2, 3, 4),
Values( HPP_ACCEL_TYPE_CPU, HPP_ACCEL_TYPE_GPU)));
}
}
#endif

View File

@ -36,9 +36,6 @@ endif()
if(NOT BUILD_opencv_viz OR NOT VTK_USE_FILE)
ocv_list_filterout(cpp_samples "/viz/")
endif()
if(NOT HAVE_IPP_A)
ocv_list_filterout(cpp_samples "/ippasync/")
endif()
ocv_list_filterout(cpp_samples "real_time_pose_estimation/")
foreach(sample_filename ${cpp_samples})
if(sample_filename MATCHES "/viz/")

View File

@ -1,168 +0,0 @@
#include <stdio.h>
#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "cvconfig.h"
using namespace std;
using namespace cv;
#ifdef HAVE_IPP_A
#include "opencv2/core/ippasync.hpp"
#define CHECK_STATUS(STATUS, NAME)\
if(STATUS!=HPP_STATUS_NO_ERROR){ printf("%s error %d\n", NAME, STATUS);\
if (virtMatrix) {hppStatus delSts = hppiDeleteVirtualMatrices(accel, virtMatrix); CHECK_DEL_STATUS(delSts,"hppiDeleteVirtualMatrices");}\
if (accel) {hppStatus delSts = hppDeleteInstance(accel); CHECK_DEL_STATUS(delSts, "hppDeleteInstance");}\
return -1;}
#define CHECK_DEL_STATUS(STATUS, NAME)\
if(STATUS!=HPP_STATUS_NO_ERROR){ printf("%s error %d\n", NAME, STATUS); return -1;}
#endif
static void help()
{
printf("\nThis program shows how to use the conversion for IPP Async.\n"
"This example uses the Sobel filter.\n"
"You can use cv::Sobel or hppiSobel.\n"
"Usage: \n"
"./ipp_async_sobel [--camera]=<use camera,if this key is present>, \n"
" [--file_name]=<path to movie or image file>\n"
" [--accel]=<accelerator type: auto (default), cpu, gpu>\n\n");
}
const char* keys =
{
"{c camera | | use camera or not}"
"{fn file_name|../data/baboon.jpg | image file }"
"{a accel |auto | accelerator type: auto (default), cpu, gpu}"
};
//this is a sample for hppiSobel functions
int main(int argc, const char** argv)
{
help();
VideoCapture cap;
CommandLineParser parser(argc, argv, keys);
Mat image, gray, result;
#ifdef HAVE_IPP_A
hppiMatrix* src,* dst;
hppAccel accel = 0;
hppAccelType accelType;
hppStatus sts;
hppiVirtualMatrix * virtMatrix;
bool useCamera = parser.has("camera");
string file = parser.get<string>("file_name");
string sAccel = parser.get<string>("accel");
parser.printMessage();
if( useCamera )
{
printf("used camera\n");
cap.open(0);
}
else
{
printf("used image %s\n", file.c_str());
cap.open(file.c_str());
}
if( !cap.isOpened() )
{
printf("can not open camera or video file\n");
return -1;
}
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");
accelType = hppQueryAccelType(accel);
sAccel = accelType == HPP_ACCEL_TYPE_CPU ? "cpu":
accelType == HPP_ACCEL_TYPE_GPU ? "gpu":
accelType == HPP_ACCEL_TYPE_GPU_VIA_DX9 ? "gpu dx9": "?";
printf("accelType %s\n", sAccel.c_str());
virtMatrix = hppiCreateVirtualMatrices(accel, 1);
for(;;)
{
cap >> image;
if(image.empty())
break;
cvtColor( image, gray, COLOR_BGR2GRAY );
result.create( image.rows, image.cols, CV_8U);
double execTime = (double)getTickCount();
//convert Mat to hppiMatrix
src = hpp::getHpp(gray,accel);
dst = hpp::getHpp(result,accel);
sts = hppiSobel(accel,src, HPP_MASK_SIZE_3X3,HPP_NORM_L1,virtMatrix[0]);
CHECK_STATUS(sts,"hppiSobel");
sts = hppiConvert(accel, virtMatrix[0], 0, HPP_RND_MODE_NEAR, dst, HPP_DATA_TYPE_8U);
CHECK_STATUS(sts,"hppiConvert");
// Wait for tasks to complete
sts = hppWait(accel, HPP_TIME_OUT_INFINITE);
CHECK_STATUS(sts, "hppWait");
execTime = ((double)getTickCount() - execTime)*1000./getTickFrequency();
printf("Time : %0.3fms\n", execTime);
imshow("image", image);
imshow("rez", result);
waitKey(15);
sts = hppiFreeMatrix(src);
CHECK_DEL_STATUS(sts,"hppiFreeMatrix");
sts = hppiFreeMatrix(dst);
CHECK_DEL_STATUS(sts,"hppiFreeMatrix");
}
if (!useCamera)
waitKey(0);
if (virtMatrix)
{
sts = hppiDeleteVirtualMatrices(accel, virtMatrix);
CHECK_DEL_STATUS(sts,"hppiDeleteVirtualMatrices");
}
if (accel)
{
sts = hppDeleteInstance(accel);
CHECK_DEL_STATUS(sts, "hppDeleteInstance");
}
printf("SUCCESS\n");
#else
printf("IPP Async not supported\n");
#endif
return 0;
}