I tested by resizing the final SoftwareBitmap and it seems to work with a small PictureBox height (tested with 32, which did not work with original SoftwareBitmap )
I tested *2, but maybe it can be better with other sizes (width cannot be too big or I got memory errors...)
or other parameters for the transformation
Add :
Dim scaledSoftwareBitmap As Windows.Graphics.Imaging.SoftwareBitmap
Add after "softwareBmp = Await decoder.GetSoftwareBitmapAsync()" :
Dim transform = New Windows.Graphics.Imaging.BitmapTransform() With {
.ScaledWidth = CUInt(PictureBox1.Width * 2),
.ScaledHeight = CUInt(PictureBox1.Height * 2),
.InterpolationMode = Windows.Graphics.Imaging.BitmapInterpolationMode.NearestNeighbor
}
Dim pixelData As Windows.Graphics.Imaging.PixelDataProvider = Await decoder.GetPixelDataAsync(Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8, Windows.Graphics.Imaging.BitmapAlphaMode.Premultiplied, transform, Windows.Graphics.Imaging.ExifOrientationMode.RespectExifOrientation, Windows.Graphics.Imaging.ColorManagementMode.ColorManageToSRgb)
scaledSoftwareBitmap = New Windows.Graphics.Imaging.SoftwareBitmap(Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8, CInt(transform.ScaledWidth), CInt(transform.ScaledHeight))
Dim pixels As Byte() = pixelData.DetachPixelData()
Dim buffer As Windows.Storage.Streams.IBuffer = pixels.AsBuffer()
scaledSoftwareBitmap.CopyFromBuffer(buffer)
Replace :
'Dim ocrResult = Await ocrEng.RecognizeAsync(softwareBmp)
Dim ocrResult = Await ocrEng.RecognizeAsync(scaledSoftwareBitmap)