- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can someone tell me how to call a function that uses a buffer, for example
ResizeGetBufSize.
I am using Visual Basic 2008 and mycode is:
Dim buffsize As Integer
nChannel = 1
myStatus = ip.ippiResizeGetBufSize(srcRect, dstRect, nChannel, Interpolation.IPPI_INTER_NN, buffsize)
This produces the error:
ippStsNullPtrErr {-8}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I should state that my objective is to create an app that reads a JPG, resizes it, compresses it, and then saves the new JPG as a different file. Speed is of the utmost importance in this app.
Terry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IppiRect srcRoi={0,0,img_srg_width,img_srg_height};
IppiRect dstRoi={0,0,img_dst_width,img_dst_height};
// calculation of work buffer size
int bufsize=0;
ippiResizeGetBufSize( srcRoi, dstRoi, 3, IPPI_INTER_LANCZOS , &bufsize );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From what I can see, I'd say the last parameter (buffsize) is passed by value and not by reference.
Since I never use IPP in VB/C# directly, I don't know where you find the wrapper (provided by intel or done by yourself).
buffsize being unitilialized, its value is 0 leading to that error when passed by value. You would get a crash or memory corruption if buffsize was initialized to any other value.
Please check the wrapper to ensure how the last parameter is passed to IPP.
Regards,
Matthieu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to re-iterate that the purpose of my app is to read a JPG, resize it, and save it with a quality factor of 75. This seems like an easy task but I am not very well versed in the IPP.
I can use this code no problem:
myStatus = ip.ippiResize_8u_C3R(bmpsrcdata.Scan0, srcROI, bmpsrcdata.Stride, srcRect, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, xFactor, yFactor, Interpolation.IPPI_INTER_NN)
This works, however, when I save the destination image, the imageshows my reduced image on top of my full image. Also, the file size is about 3.5 MB. The original image size is only 223 KB so no compression (quality) is applied. Also, the code shown below produces an error:
Dim stt As IppStatus = ip.ippiQualityIndex_8u32f_C3R(bmpsrcdata.Scan0, bmpsrcdata.Stride, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, 75)
Here is my VB.Net code:
Dim xFactor As Double
Dim yFactor As Double
Dim nChannel As Integer
Dim buffsize As Integer
Dim myStatus As IppStatus = IppStatus.ippStsNoErr
Dim bmpsrcdata As BitmapData = getBmpData(bmpsrc)
bmpdst = New Bitmap(bmpsrc)
Dim bmpdstdata As BitmapData = getBmpData(bmpdst)
Dim srcROI As IppiSize = New IppiSize(bmpsrc.Width, bmpsrc.Height)
Dim dstROI As IppiSize = New IppiSize(bmpdst.Width, bmpdst.Height)
'*******************************
' Set Image Scaling Factors.
'*******************************
If doHalf = True Then
xFactor = 0.5
yFactor = 0.5
Else
xFactor = dstWidth / dstROI.width
yFactor = dstHeight / dstROI.height
End If
Dim srcRect As IppiRect = New IppiRect(0, 0, bmpsrcdata.Width, bmpsrcdata.Height)
Dim dstRect As IppiRect = New IppiRect(0, 0, bmpdstdata.Width, bmpdstdata.Height)
nChannel = 1
buffsize = 0
GoTo here
myStatus = IppStatus.ippStsNoErr
m_start = ipp.core.ippGetCpuClocks()
myStatus = ip.ippiResize_8u_C3R(bmpsrcdata.Scan0, srcROI, bmpsrcdata.Stride, srcRect, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, xFactor, yFactor, Interpolation.IPPI_INTER_NN)
m_stop = ipp.core.ippGetCpuClocks()
If (myStatus <> IppStatus.ippStsNoErr) Then
msg("Resize", myStatus)
End If
bmpsrc.UnlockBits(bmpsrcdata)
bmpdst.UnlockBits(bmpdstdata)
'***************************************
' Adjust JPG Quality (Compression).
'***************************************
bmpsrcdata = getBmpData(bmpsrc)
bmpdstdata = getBmpData(bmpdst)
dstROI = New IppiSize(bmpdst.Width, bmpdst.Height)
Try
Dim stt As IppStatus = ip.ippiQualityIndex_8u32f_C3R(bmpsrcdata.Scan0, bmpsrcdata.Stride, bmpdstdata.Scan0, bmpdstdata.Stride, dstROI, 75)
Catch ex As Exception
Dim a As Integer
End Try
bmpsrc.UnlockBits(bmpsrcdata)
bmpdst.UnlockBits(bmpdstdata)
bmpsrc.Save("C:\Test_SRC.jpg")
bmpdst.Save("C:\Test_DST.jpg")
Invalidate()
Any help would be greatly appreciated. I think I am very close but just have difficulties finishing up.
Terry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First thing, you declare your destination image as a copy of the source image : bmpdst = New Bitmap(bmpsrc) this is why you see the reduced image on top of the source image. You have to create a new Bitmap using another form of the constructor (if I recall correctly : width, Height and imageFormat) where width and height are the destination width and height and imageFormat something like BGR24bits. Then you'll only get the reduced image.
Second thing, ippiQualityIndex_8u32f_C3R is not designed to save a file with a quality of xx%. It computes the quality index of an image given the original image (or so I think, I don't use this function).
If you want to save a JPEG file with a given quality in .NET, you have to use another form of the Save function. Here's what I found with a google search on microsoft web site
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders.MimeType == mimeType)
return encoders;
}
return null;
}
private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression )
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, lCompression );
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save( szFileName, ici, eps );
}
That is C#, but the 3rd result was the VB translation : link
If you want to save JPEG images with IPP you'll have to go through the samples.
Regards,
Matthieu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
IPP resize function speed up resize operation itself. It will not reduce time you spent reading 1.5 millions of images from hard drive and write them back.
Regards,
Vladimir

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