- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have started using ippiErodeBorder_8u_C1R and ippiDilateBorder_8u_C1R and I call these APIs in a loop ,however I get access violation exception during iteration.IPP2018 version is used here.Below is the code,can someone please point out the error?
The exception comes from ippiErodeBorder_8u_C1R
int iSpecSize;
int iBufferSize;
imageSize = 416 x 416
kernelSize = 3x3
ippResult = ippcv_l.ippiMorphologyBorderGetSize_8u_C1R(imageSize, kernelSize, &iSpecSize, &iBufferSize);
iSpecSize = 137
iBufferSize = 2640
nBytesPerImageLine = 1664
offsetBinaryMaskWithBorder = 420
imageSizeWithBorder.width = 419
pKernelMask = byte[3,3] all filled with 1
byte[,] pImageAsBinaryMask = new byte[416,416];
byte[,] pImageAsBinaryMaskWithBorder = new byte[419,419];
ipcvMorphState* pSpec = (ipcvMorphState*)ipps.ippsMalloc_8u(iSpecSize);
byte* pBuffer = ipps.ippsMalloc_8u(iBufferSize);
ippResult = ippcv_l.ippiMorphologyBorderInit_8u_C1R(imageSize, pKernelMask, kernelSize, pSpec, pBuffer);
// Apply erosion filter
ippResult = ippcv_l.ippiErodeBorder_8u_C1R(pImageAsBinaryMask, nBytesPerImageLine, pImageAsBinaryMaskWithBorder + offsetBinaryMaskWithBorder,imageSizeWithBorder.width * sizeof(float),
imageSize,IppiBorderType.ippBorderRepl, 0, pSpec, pBuffer);
ippResult = ippcv_l.ippiDilateBorder_8u_C1R(pImageAsBinaryMask, nBytesPerImageLine, pImageAsBinaryMaskWithBorder + offsetBinaryMaskWithBorder, imageSizeWithBorder.width * sizeof(float),
imageSize, IppiBorderType.ippBorderRepl, 0, pSpec, pBuffer);
ipps.ippsFree(pBuffer);
ipps.ippsFree(pSpec);
Regards,
Leo
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Leo.
Looks like that output image in your code is bigger than input. Input 416x416 and output is 419x419. It is non-standart situation but it is not a problem because you provide correct 'imageSize' to function. But step 'imageSizeWithBorder.width * sizeof(float)' is too big that causes crash. Please mul by sizeof(Ipp8u) or malloc 4x time more image.
I've redesigned your code with correct steps and pSpec.
#include "ipp.h" #include "ippcv.h" void main() { int iSpecSize; int iBufferSize; IppiSize imageSize = { 416, 416 }; IppiSize kernelSize = { 3, 3 }; IppStatus ippResult; ippResult = ippiMorphologyBorderGetSize_8u_C1R(imageSize, kernelSize, &iSpecSize, &iBufferSize); int nBytesPerImageLine = 416; int offsetBinaryMaskWithBorder = 420; IppiSize imageSizeWithBorder = { 419, 419 }; Ipp8u pKernelMask[3 * 3] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; Ipp8u* pImageAsBinaryMask ; Ipp8u* pImageAsBinaryMaskWithBorder ; pImageAsBinaryMask = ippsMalloc_8u(416 * 416); pImageAsBinaryMaskWithBorder = ippsMalloc_8u(419 * 419); IppiMorphState* pSpec = (IppiMorphState*)ippsMalloc_8u(iSpecSize); Ipp8u* pBuffer = ippsMalloc_8u(iBufferSize); ippResult = ippiMorphologyBorderInit_8u_C1R(imageSize, pKernelMask, kernelSize, pSpec, pBuffer); ippResult = ippiErodeBorder_8u_C1R(pImageAsBinaryMask, nBytesPerImageLine, pImageAsBinaryMaskWithBorder + offsetBinaryMaskWithBorder, imageSizeWithBorder.width * sizeof(Ipp8u), imageSize, ippBorderRepl, 0, pSpec, pBuffer); ippResult = ippiDilateBorder_8u_C1R(pImageAsBinaryMask, nBytesPerImageLine, pImageAsBinaryMaskWithBorder + offsetBinaryMaskWithBorder, imageSizeWithBorder.width * sizeof(Ipp8u), imageSize, ippBorderRepl, 0, pSpec, pBuffer); ippsFree(pBuffer); ippsFree(pSpec); }
Thanks for using IPP library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks ,that worked.
Regards,
Leo

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page