无法将转换为字节的图像传递给请求。因此,我无法使用 detectdocumenttextresult 和 detectdocumenttextresponse
这是我尝试在 c# 中转换的 java 代码
string document = "input.png";
ByteBuffer imageBytes;
using (Stream inputStream = new FileStream(document, FileMode.Open, FileAccess.Read)) {
imageBytes = ByteBuffer.wrap(IOUtils.toByteArray(inputStream));
}
AmazonTextract client = AmazonTextractClientBuilder.defaultClient();
DetectDocumentTextRequest request = (new DetectDocumentTextRequest()).withDocument(new Document()
.withBytes(imageBytes));
DetectDocumentTextResult result = client.detectDocumentText(request);
/* 这是我无法将数据传递给请求的 c# 代码*/
AmazonTextractClient Atc = new AmazonTextractClient(credentials, config);
Image img = Image.FromFile("D:\\Images\\1.Jpeg");
byte[] ImageBytes = (byte[])(new ImageConverter()).ConvertTo(img, typeof(byte[]));
DetectDocumentTextRequest request = new DetectDocumentTextRequest();
request.Document.Bytes.Read(ImageBytes, 0 , ImageBytes.Length);
DetectDocumentTextResponse res = Atc.DetectDocumentText(request);