Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

.net developing Pre-sales advice

zhan_z_
Beginner
437 Views

I want to buy an Intel® Integrated Performance Primitives (Intel® IPP) for image processing.But my software is under .net framework.Does ipp support .net software?

And how? Are there some examples for me?

I try to make a c++ wrapper of ipp by CLR.But I falied.

Please help me to use it.

Best regard.

This is my wrapper by CLR:

#include "ipp.h"
#pragma comment(lib, "ippi.lib")
#pragma comment(lib, "ippcv.lib")
#pragma managed(pop)

using namespace System;


namespace IPPInterpolationWrapper {

    public ref class IPPInterpolation
    {
    public:
        int x;
        int zzz;
        IppStatus ippiWarpAffine_16u_C1R1(const Ipp16u* pSrc,
            IppiSize srcSize, 
            int srcStep,
            IppiRect srcROI,
            Ipp16u* pDst, 
            int dstStep, 
            IppiRect dstROI, 
            double coeffs00,
            double coeffs01,
            double coeffs02,
            double coeffs10,
            double coeffs11,
            double coeffs12,
            int interpolation);
    };
}

 

IppStatus IPPInterpolationWrapper::IPPInterpolation::ippiWarpAffine_16u_C1R1(const Ipp16u* pSrc,
    IppiSize srcSize, 
    int srcStep, 
    IppiRect srcROI, 
    Ipp16u* pDst, 
    int dstStep, 
    IppiRect dstROI,
    double coeffs00,
    double coeffs01,
    double coeffs02,
    double coeffs10,
    double coeffs11,
    double coeffs12,
    int interpolation)
{
    IppiWarpSpec* pSpec = 0;
    Ipp8u* pInitBuf = 0;
    int specSize = 0, initSize = 0, bufSize = 0; Ipp8u* pBuffer = 0;
    const Ipp32u numChannels = 1;  //此参数修改通道数
    IppiPoint dstOffset = { 0, 0 };
    IppStatus status = ippStsNoErr;
    IppiBorderType borderType = ippBorderTransp;
    IppiWarpDirection direction = ippWarpForward;
    IppiSize dstRoiSize = { dstROI.width, dstROI.height };
    double cf[2][3];
    IppiSize srcRoiSize;
    Ipp16u* pSrcRoi = (Ipp16u*)((Ipp8u*)pSrc + srcROI.y * srcStep) + srcROI.x *
        numChannels;
    Ipp16u* pDstRoi = (Ipp16u*)((Ipp8u*)pDst + dstROI.y * dstStep) + dstROI.x *
        numChannels;
    IppiInterpolationType interp;
    int borderSize = 0;
    Ipp64f valB = 0.0, valC = 0.5; /* Catmull-Rom filter */
    if (srcROI.x < 0 || srcROI.y < 0 || srcROI.x >= srcSize.width || srcROI.y >=
        srcSize.height)
        return ippStsRectErr;
    if (dstROI.x < 0 || dstROI.y < 0)
        return ippStsRectErr;
    /* Clip the source roi */
    if (srcROI.x + srcROI.width > srcSize.width) srcROI.width = srcSize.width -
        srcROI.x;
    if (srcROI.y + srcROI.height > srcSize.height) srcROI.height = srcSize.height -
        srcROI.y;
    srcRoiSize.width = srcROI.width;
    srcRoiSize.height = srcROI.height;
    switch (interpolation)
    {
    case IPPI_INTER_NN:
        interp = ippNearest;
        break;
    case IPPI_INTER_LINEAR:
        interp = ippLinear;
        break;
    case IPPI_INTER_CUBIC:
        interp = ippCubic;
        borderSize = 1;
        break;
    default:
        return ippStsInterpolationErr;
    }
    /* compute new coefficients with taking into account ROI offsets*/
    cf[0][0] = coeffs00; cf[0][1] = coeffs01; cf[0][2] = coeffs02 +
        coeffs00 * srcROI.x + coeffs01 * srcROI.y - dstROI.x;
    cf[1][0] = coeffs10; cf[1][1] = coeffs11; cf[1][2] = coeffs12 +
        coeffs10 * srcROI.x + coeffs11 * srcROI.y - dstROI.y;
    /* define border type depending on the source ROI */
    if (srcROI.x >= borderSize) borderType = (IppiBorderType)(borderType |
        ippBorderInMemLeft);
    if (srcROI.y >= borderSize) borderType = (IppiBorderType)(borderType |
        ippBorderInMemTop);
    if (srcROI.x + srcROI.width <= srcSize.width - borderSize) borderType =
        (IppiBorderType)(borderType | ippBorderInMemRight);
    if (srcROI.y + srcROI.height <= srcSize.height - borderSize) borderType =
        (IppiBorderType)(borderType | ippBorderInMemBottom);
    /* Spec and init buffer sizes */
    status = ippiWarpAffineGetSize(srcRoiSize, dstRoiSize, ipp16u, cf, interp, direction,
        borderType, &specSize, &initSize);
    if (status < ippStsNoErr) return status;
    /* Memory allocation */
    pSpec = (IppiWarpSpec*)ippsMalloc_8u(specSize);
    if (pSpec == nullptr)
    {
        return ippStsNoMemErr;
    }
    /* Memory allocation */
    pInitBuf = ippsMalloc_8u(initSize);
    if (pInitBuf == nullptr)
    {
        ippsFree(pSpec);
        return ippStsNoMemErr;
    }
    /* Filter initialization */
    switch (interpolation)
    {
    case IPPI_INTER_NN:
        status = ippiWarpAffineNearestInit(srcRoiSize, dstRoiSize, ipp16u, cf, direction,
            numChannels, borderType, 0, 0, pSpec);
        break;
    case IPPI_INTER_LINEAR:
        status = ippiWarpAffineLinearInit(srcRoiSize, dstRoiSize, ipp16u, cf, direction,
            numChannels, borderType, 0, 0, pSpec);
        break;
    case IPPI_INTER_CUBIC:
        status = ippiWarpAffineCubicInit(srcRoiSize, dstRoiSize, ipp16u, cf, direction,
            numChannels, valB, valC, borderType, 0, 0, pSpec, pInitBuf);
        break;
    }
    ippsFree(pInitBuf);
    if (status < ippStsNoErr)
    {
        ippsFree(pSpec);
        return status;
    }
    /* work buffer size */
    status = ippiWarpGetBufferSize(pSpec, dstRoiSize, &bufSize);
    if (status < ippStsNoErr)
    {
        ippsFree(pSpec);
        return status;
    }
    pBuffer = ippsMalloc_8u(bufSize);
    if (pBuffer == nullptr)
    {
        ippsFree(pSpec);
        return ippStsNoMemErr;
    }
    /* Warp processing */
    switch (interpolation)
    {
    case IPPI_INTER_NN:
        status = ippiWarpAffineNearest_16u_C1R(pSrcRoi, srcStep, pDstRoi, dstStep,
            dstOffset, dstRoiSize, pSpec, pBuffer);
        break;
    case IPPI_INTER_LINEAR:
        status = ippiWarpAffineLinear_16u_C1R(pSrcRoi, srcStep, pDstRoi, dstStep,
            dstOffset, dstRoiSize, pSpec, pBuffer);
        break;
    case IPPI_INTER_CUBIC:
        status = ippiWarpAffineCubic_16u_C1R(pSrcRoi, srcStep, pDstRoi, dstStep,
            dstOffset, dstRoiSize, pSpec, pBuffer);
        break;
    }
    ippsFree(pSpec);
    ippsFree(pBuffer);
    return status;
}

0 Kudos
1 Solution
SergeyKostrov
Valued Contributor II
437 Views
>>...I try to make a c++ wrapper of ipp by CLR.But I falied... What was an error? Did you check dependencies of your test application with MS Depends utility? Take into account that it could be a simple DLL dependency issue since some IPP's DLLs loaded at run-time and MS Depends utility doesn't show these "waterfall" DLLs.

View solution in original post

0 Kudos
4 Replies
SergeyKostrov
Valued Contributor II
438 Views
>>...I try to make a c++ wrapper of ipp by CLR.But I falied... What was an error? Did you check dependencies of your test application with MS Depends utility? Take into account that it could be a simple DLL dependency issue since some IPP's DLLs loaded at run-time and MS Depends utility doesn't show these "waterfall" DLLs.
0 Kudos
Jing_Xu
Employee
437 Views

How failed? Any error messages?

0 Kudos
zhan_z_
Beginner
437 Views

Sergey Kostrov wrote:

>>...I try to make a c++ wrapper of ipp by CLR.But I falied...

What was an error? Did you check dependencies of your test application with MS Depends utility?

Take into account that it could be a simple DLL dependency issue since some IPP's DLLs loaded at run-time and MS Depends utility doesn't show these "waterfall" DLLs.

 

Thank you very much! Under your advise  I just change the linking type as "Single-threaded static Library". Now this DLL can run well. But I can't get the desired result.I'm using ippiWarpAffineLinear_16u_C1R to do Affine Transform. 

 

int srcStep = ((srcBitsPerPixel * srcWidth) + 31) / 32 * 4;

int dstStep = ((srcBitsPerPixel * dstWidth) + 31) / 32 * 4;

IppiPoint dstOffset;

dstOffset.x = 0;

dstOffset.y = 0;

IppiSize dstRoiSize;

dstRoiSize.width = srcWidth;

dstRoiSize.height = srcHeight;

IppiWarpSpec* pSpec = 0;

int bufSize = 0;

Ipp8u* pBuffer;

 

 

/* work buffer size */

int status = ippiWarpGetBufferSize(pSpec, dstRoiSize, &bufSize); //this line error, with a status -8. Which means a null pointer. 

if (status < ippStsNoErr)

{

ippsFree(pSpec);

return status;

}

pBuffer = ippsMalloc_8u(bufSize);

if (pBuffer == nullptr)

{

ippsFree(pSpec);

return ippStsNoMemErr;

}

// Warp proce

status = ippiWarpAffineLinear_16u_C1R((Ipp16u *)pSrcPixelData, srcStep, (Ipp16u *)pDstPixelData, dstStep,

dstOffset, dstRoiSize, pSpec, pBuffer);

}

0 Kudos
zhan_z_
Beginner
437 Views

Sergey Kostrov wrote:

>>...I try to make a c++ wrapper of ipp by CLR.But I falied...

What was an error? Did you check dependencies of your test application with MS Depends utility?

Take into account that it could be a simple DLL dependency issue since some IPP's DLLs loaded at run-time and MS Depends utility doesn't show these "waterfall" DLLs.

 

 

I just post a new problem to describe my problems.Could you pay attention to it.? Link:https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/737380

0 Kudos
Reply