在启用 OpenCL 选项的情况下使用 Tesseract 时出错

Error while using Tesseract with OpenCL option enabled

我在我的项目中使用启用了 OpenCL 选项的 Tesseract。执行 GetUTF8Text() 方法时,出现以下错误:

DS] Profile read from file (tesseract_opencl_profile_devices.dat).
[DS] Device[1] 1:Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz score is 14049349632.000000
[DS] Device[2] 1:HD Graphics 5000 score is 14049349632.000000
[DS] Device[3] 0:(null) score is 21474836480.000000
[DS] Selected Device[1]: "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz" (OpenCL)
OpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .
OpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .
OpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_ThresholdRectToPix .
OpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannels .
OpenCL error code is -54 at   when clEnqueueNDRangeKernel kernel_HistogramRectAllChannelsReduction .

使用的库版本:

tesseract 3.04.00
 leptonica-1.71
  zlib 1.2.5

 OpenCL info:
  Found 1 platforms.
  Platform name: Apple.
  Version: OpenCL 1.2 (Dec 14 2014 22:29:47).
  Found 2 devices.
    Device 1 name: Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz.
    Device 2 name: HD Graphics 5000.

有没有人遇到过这个问题?

看起来 Tessaract 将工作组大小为 16x16 的内核排入队列,这是 GPU 上图像处理的相当典型的图块大小。但是,Apple 的 CPU OpenCL 实现有一个限制,工作组大小只能是一维的(即第二个维度必须是 1),因此这个工作组大小将无效。您得到的错误代码 (-54) 对应于 CL_INVALID_WORK_GROUP_SIZE.

如果您可以将 Tesseract 改为 运行 在 GPU 上(HD Graphics 5000),您应该没问题。