此方法已在适用于 Linux 和 Windows 的 FRE 中实现。
此方法在客户端实现。该方法从源的图像处理队列中返回下一个图像文档。
GetNextImageDocument 方法的实现中可以包含等待下一个图像文档的时间。但我们不建议将等待时间设置得过长,因为 FineReader Engine 不是多线程的。在等待下一个文档时,Engine 将无法处理来自识别进程的消息,也无法接收页面处理完成的通知。如果您确实需要指定较长的等待时间,GetNextImageDocument 方法可以返回 0。在这种情况下,Engine 将继续处理来自识别进程的消息并提供已识别的图像,过一段时间后会检查图像队列是否为空。如果队列不为空 (即 IImageSource::IsEmpty 返回 FALSE) ,Engine 将再次调用 GetNextImageDocument 方法。但是,如果 GetNextImageDocument 方法返回 0,且已没有更多页面需要处理,FineReader Engine 会将控制权返回给用户:IBatchProcessor::GetNextProcessedPage 方法将返回 0。
- 队列中的所有 ImageDocument 对象在处理结束前都必须保持有效。为确保正常运行,ImageDocument 对象应通过 Engine 对象创建。如果它们是通过 FRDocument 对象创建的,则可能会因 FRDocument 对象在调用 GetNextImageDocument 方法期间被销毁而导致错误。
- 由于该方法是在客户端实现的,因此存在以下限制:
HRESULT GetNextImageDocument( IImageDocument** Result );
IImageDocument GetNextImageDocument();
Function GetNextImageDocument() As IImageDocument
Result
[out, retval] 指向 IImageDocument* 指针变量的指针,用于提供对队列中下一个图像文档的访问。
[仅限 C++] 如果此方法返回的值不是 S_OK,则表示客户端发生了错误。
此 方法 的客户端实现必须确保捕获并处理该 方法 内部抛出的所有异常,且不得让任何异常传播到该 方法 外部。异常传播到 方法 外部可能会导致不可预知的结果 (例如程序终止) 。
// 自定义图像源的示例实现,用于维护图像文件队列
public class ImageSourceCallback : FREngine.IImageSource
{
public ImageSourceCallback( string imageFilesDirectory )
{
imageFiles = ImageSourceHelper.LoadFilesNames( imageFilesDirectory );
nextFileIndex = 0;
}
public bool IsEmpty()
{
return nextFileIndex >= imageFiles.Length;
}
public FREngine.IFileAdapter GetNextImageFile()
{
if( !IsEmpty() ) {
return new FileAdapterCallback( imageFiles[nextFileIndex++] );
}
return null;
}
public FREngine.IImageDocument GetNextImageDocument()
{
...
}
private string[] imageFiles;
private int nextFileIndex;
}
public class FileAdapterCallback : FREngine.IFileAdapter
{
...
}
public class ImageSourceHelper
{
...
}
IImageSource
GetNextImageFile
IsEmpty
ImageDocument