2 일 동안 답변을 검색했지만 그럴 수 없었습니다. 그것이 내가 여기에 게시하는 이유입니다. 나는 이것을 tutorial에 따라왔다. Microsoft OCR : Windows Phone 8 용 비트 맵을 픽셀 배열로 변환하십시오. Silverlight
은 내가이 줄에 오류 메시지를 받았습니다 그래서 난bitmap.SetSource(imgStream.AsStream);
로 변경 오류 bitmap.SetSource(imgStream);
을 얻었다. 픽셀을 배열로 변환 할 수 없습니다. 거기에 더 PixelBuffer
없고 내가 사용할 수 없기 때문에
var ocrResult = await ocrEngine.RecognizeAsync((uint)bitmap.PixelHeight, (uint)bitmap.PixelWidth, bitmap.PixelBuffer.ToArray());
Pixels
그래서 내가 인터넷에서 검색하여 stackoverflow.com이 link을 발견했다. 그래서 복사
public static byte[] ToByteArray(this WriteableBitmap bmp)
{
// Init buffer
int w = bmp.PixelWidth;
int h = bmp.PixelHeight;
int[] p = bmp.Pixels;
int len = p.Length;
byte[] result = new byte[4 * w * h];
// Copy pixels to buffer
for (int i = 0, j = 0; i < len; i++, j += 4)
{
int color = p[i];
result[j + 0] = (byte)(color >> 24); // A
result[j + 1] = (byte)(color >> 16); // R
result[j + 2] = (byte)(color >> 8); // G
result[j + 3] = (byte)(color); // B
}
return result;
}
그리고 byte[] hello = ByteArrayChange.ToByteArray(bitmap);
var ocrResult = await ocrEngine.RecognizeAsync((uint)bitmap.PixelHeight, (uint)bitmap.PixelWidth, hello);
내가 장치와 코드를 실행에 다음 코드를 붙여 그것은 Application_UnhandledException
에 App.Xaml.cs
에
참고 예외를 준 : 내가 개발하고 있어요 Windows Phone 8/8.1 (Silverlight)