Is there any way to add images as byte[] to the FREngine.IEngine for OCR processing rather than giving the path of image file to the "AddImageFile" method of FREngine.FRDocument object?.
this is for Windows web service, .NET
Is there any way to add images as byte[] to the FREngine.IEngine for OCR processing rather than giving the path of image file to the "AddImageFile" method of FREngine.FRDocument object?.
this is for Windows web service, .NET
0人中0人がこの記事が役に立ったと言っています
コメント
7件のコメント
Please consider using the IFRDocument::AddImageFileFromStream method. This method opens an image file from the input stream implemented by the user, and adds the pages corresponding to the opened file to the document. For more information about this method please refer to the Help file: API Reference→Document-Related Objects→Document Organization Objects→FRDocument Object, section "Methods" and API Reference→Supplementary Objects→IReadStream.
Hi Oksnana, I did try using IReadStream but no luck, program goes into infinite loop. Definitely I am doing something wrong, I am pasting my code here can you please help me : am breaking into two comments because of chars restrictions public void foo() {FREngine.IEngine engine = _enginesPool.GetEngine(); FREngine.FRDocument frDocument = engine.CreateFRDocument(); byte[] myBytes = File.ReadAllBytes(argImagesPath); CustomReadStream crs = new CustomReadStream(myBytes); frDocument.AddImageFileFromStream(crs, null, null, null, "0");}
class CustomReadStream : IReadStream { public CustomReadStream(byte[] argImageBytes) {currentPos = 0; imageBytes = new byte[argImageBytes.Length]; argImageBytes.CopyTo(imageBytes, 0);} public int Read(out Array data, int count) { data = imageBytes; buf = new byte[imageBytes.Length]; imageBytes.CopyTo(buf, 0); return imageBytes.Length; }
public void Close() { imageBytes = null; buf = null; } uint currentPos = 0; byte[] imageBytes = null; byte[] buf = null; }
Hi,
Please sorry for the delay!
First of all, please check what FineReader Engine release you use. The case is that the implementation of the IReadStream interface was changed in our Help file to more optimal beginning from the 5th release of the program, the build number - 11.1.10.100. And now the current version of FineReader Engine 11 is the 8th release, the build number - 11.1.19.48. Please contact your Sales Manager to update your FineReader Engine package.
Below please find our sample C# code snippet illustrating how to implement the IReadStream interface and use the IFRDocument::AddImageFileFromStream() method:
Then you can continue processing using the FRDocument object in the way you prefer.
can you please suggest , how to implement this in JAVA
I have tried but failed to implement , following is my code
public class AbbyyInputStream implements IReadStream {
InputStream stream;
byte[] bytes;
public AbbyyInputStream(MultipartFile imageFile) throws IOException {
super();
this.bytes = imageFile.getBytes();
this.stream = imageFile.getInputStream();
}
@Override
public void Close() {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public int Read(Ref<byte[]> data, int arg1) {
data = new Ref<byte[]>(new byte[bytes.length]);
try {
return stream.read(data.get(), 0, arg1);
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
}
Hi,
As you request, we provide you functional example of the same code in java:
サインインしてコメントを残してください。