1 #ifndef __OPENCV_CORE_IPPASYNC_HPP__
2 #define __OPENCV_CORE_IPPASYNC_HPP__
6 #include "opencv2/core.hpp"
7 #include <ipp_async_op.h>
8 #include <ipp_async_accel.h>
15 //convert OpenCV data type to hppDataType
16 inline int toHppType(const int cvType)
18 int depth = CV_MAT_DEPTH(cvType);
19 int hppType = depth == CV_8U ? HPP_DATA_TYPE_8U :
20 depth == CV_16U ? HPP_DATA_TYPE_16U :
21 depth == CV_16S ? HPP_DATA_TYPE_16S :
22 depth == CV_32S ? HPP_DATA_TYPE_32S :
23 depth == CV_32F ? HPP_DATA_TYPE_32F :
24 depth == CV_64F ? HPP_DATA_TYPE_64F : -1;
25 CV_Assert( hppType >= 0 );
29 //convert hppDataType to OpenCV data type
30 inline int toCvType(const int hppType)
32 int cvType = hppType == HPP_DATA_TYPE_8U ? CV_8U :
33 hppType == HPP_DATA_TYPE_16U ? CV_16U :
34 hppType == HPP_DATA_TYPE_16S ? CV_16S :
35 hppType == HPP_DATA_TYPE_32S ? CV_32S :
36 hppType == HPP_DATA_TYPE_32F ? CV_32F :
37 hppType == HPP_DATA_TYPE_64F ? CV_64F : -1;
38 CV_Assert( cvType >= 0 );
42 inline void copyHppToMat(hppiMatrix* src, Mat& dst, hppAccel accel, int cn)
51 sts = hppiInquireMatrix(src, &type, &width, &height);
53 CV_Assert( sts == HPP_STATUS_NO_ERROR);
55 int matType = CV_MAKETYPE(toCvType(type), cn);
57 CV_Assert(width%cn == 0);
61 dst.create((int)height, (int)width, (int)matType);
63 size_t newSize = (size_t)(height*(hpp32u)(dst.step));
65 sts = hppiGetMatrixData(accel,src,(hpp32u)(dst.step),dst.data,&newSize);
67 CV_Assert( sts == HPP_STATUS_NO_ERROR);
70 //create cv::Mat from hppiMatrix
71 inline Mat getMat(hppiMatrix* src, hppAccel accel, int cn)
74 copyHppToMat(src, dst, accel, cn);
78 //create hppiMatrix from cv::Mat
79 inline hppiMatrix* getHpp(const Mat& src, hppAccel accel)
81 int htype = toHppType(src.type());
82 int cn = src.channels();
85 hppAccelType accelType = hppQueryAccelType(accel);
87 if (accelType!=HPP_ACCEL_TYPE_CPU)
90 hppQueryMatrixAllocParams(accel, src.cols*cn, src.rows, htype, &pitch, &size);
91 if (pitch!=0 && size!=0)
92 if ((int)(src.data)%4096==0 && pitch==(hpp32u)(src.step))
94 return hppiCreateSharedMatrix(htype, src.cols*cn, src.rows, src.data, pitch, size);
98 return hppiCreateMatrix(htype, src.cols*cn, src.rows, src.data, (hpp32s)(src.step));;