Fix build with OpenCL and add namespace to OpenCL code

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-10-06 07:51:03 +02:00
parent 571a8fe1d7
commit 0aad8b8619
4 changed files with 16 additions and 4 deletions

View File

@ -727,6 +727,9 @@ tesseract_CPPFLAGS += -I$(top_srcdir)/src/ccstruct
tesseract_CPPFLAGS += -I$(top_srcdir)/src/ccutil
tesseract_CPPFLAGS += -I$(top_srcdir)/src/dict
tesseract_CPPFLAGS += -I$(top_srcdir)/src/viewer
if OPENCL
tesseract_CPPFLAGS += -I$(top_srcdir)/src/opencl
endif
tesseract_CPPFLAGS += $(AM_CPPFLAGS)
if VISIBILITY
tesseract_CPPFLAGS += -DTESS_IMPORTS

View File

@ -75,7 +75,7 @@ int OtsuThreshold(Image src_pix, int left, int top, int width, int height, std::
// or to be a convincing background we must have a large fraction of H.
// In between we assume this channel contains no thresholding information.
int hi_value = best_omega_0 < H * 0.5;
(*thresholds)[ch] = best_t;
thresholds[ch] = best_t;
if (best_omega_0 > H * 0.75) {
any_good_hivalue = true;
hi_values[ch] = 0;

View File

@ -47,10 +47,14 @@
# endif
# include <cstdio>
# include <cstdlib>
# include <cstring> // for memset, strcpy, ...
# include <vector>
# include "errcode.h" // for ASSERT_HOST
# include "image.h" // for Image
namespace tesseract {
GPUEnv OpenclDevice::gpuEnv;
@ -2193,7 +2197,7 @@ static double getLineMasksMorphMicroBench(GPUEnv *env, TessScoreEvaluationInputD
# endif
OpenclDevice::gpuEnv = *env;
OpenclDevice::initMorphCLAllocations(wpl, input.height, input.pix);
Image pix_vline = nullptr, *pix_hline = nullptr, *pix_closed = nullptr;
Image pix_vline = nullptr, pix_hline = nullptr, pix_closed = nullptr;
OpenclDevice::pixGetLinesCL(nullptr, input.pix, &pix_vline, &pix_hline, &pix_closed, true,
closing_brick, closing_brick, max_line_width, max_line_width,
min_line_length, min_line_length);
@ -2252,8 +2256,6 @@ static double getLineMasksMorphMicroBench(GPUEnv *env, TessScoreEvaluationInputD
* Device Selection
*****************************************************************************/
# include <cstdlib>
// encode score object as byte string
static ds_status serializeScore(ds_device *device, uint8_t **serializedScore,
unsigned int *serializedScoreSize) {
@ -2453,4 +2455,6 @@ bool OpenclDevice::selectedDeviceIsOpenCL() {
return (device.type == DS_DEVICE_OPENCL_DEVICE);
}
} // namespace
#endif

View File

@ -30,6 +30,9 @@
# include <CL/cl.h>
# endif
namespace tesseract {
class Image;
struct TessDeviceScore;
// device type
@ -170,5 +173,7 @@ public:
static bool selectedDeviceIsOpenCL();
};
}
#endif // USE_OPENCL
#endif // TESSERACT_OPENCL_OPENCLWRAPPER_H_