1 #ifndef __OPENCV_CORE_IPPASYNC_HPP__
2 #define __OPENCV_CORE_IPPASYNC_HPP__
4 #include "opencv2/core.hpp"
5 #include <ipp_async_op.h>
6 #include <ipp_async_accel.h>
10 void DefaultDeleter<hppiMatrix>::operator () (hppiMatrix* p) const
17 //convert OpenCV data type to hppDataType
18 inline int toHppType(const int cvType)
20 int depth = CV_MAT_DEPTH(cvType);
21 int hppType = depth == CV_8U ? HPP_DATA_TYPE_8U :
22 depth == CV_16U ? HPP_DATA_TYPE_16U :
23 depth == CV_16S ? HPP_DATA_TYPE_16S :
24 depth == CV_32S ? HPP_DATA_TYPE_32S :
25 depth == CV_32F ? HPP_DATA_TYPE_32F :
26 depth == CV_64F ? HPP_DATA_TYPE_64F : -1;
27 CV_Assert( hppType >= 0 );
31 //convert hppDataType to OpenCV data type
32 inline int toCvType(const int hppType)
34 int cvType = hppType == HPP_DATA_TYPE_8U ? CV_8U :
35 hppType == HPP_DATA_TYPE_16U ? CV_16U :
36 hppType == HPP_DATA_TYPE_16S ? CV_16S :
37 hppType == HPP_DATA_TYPE_32S ? CV_32S :
38 hppType == HPP_DATA_TYPE_32F ? CV_32F :
39 hppType == HPP_DATA_TYPE_64F ? CV_64F : -1;
40 CV_Assert( cvType >= 0 );
44 inline void copyHppToMat(hppiMatrix* src, Mat& dst, hppAccel accel, int cn)
52 sts = hppiInquireMatrix(src, &type, &width, &height);
54 CV_Assert( sts == HPP_STATUS_NO_ERROR);
56 int matType = CV_MAKETYPE(toCvType(type), cn);
58 CV_Assert(width%cn == 0);
62 dst.create((int)height, (int)width, (int)matType);
64 size_t newSize = (size_t)(height*(hpp32u)(dst.step));
66 sts = hppiGetMatrixData(accel,src,(hpp32u)(dst.step),dst.data,&newSize);
68 CV_Assert( sts == HPP_STATUS_NO_ERROR);
71 //create cv::Mat from hppiMatrix
72 inline Mat getMat(hppiMatrix* src, hppAccel accel, int cn)
75 copyHppToMat(src, dst, accel, cn);
79 //create hppiMatrix from cv::Mat
80 inline Ptr<hppiMatrix> getHpp(const Mat& src)
82 int htype = toHppType(src.type());
83 int cn = src.channels();
86 hppiMatrix *dst = hppiCreateMatrix(htype, src.cols*cn, src.rows, src.data, (hpp32s)(src.step));
88 return Ptr<hppiMatrix>(dst);