Commit Graph

52 Commits

Author SHA1 Message Date
zdenop
cdc2863b48 Merge pull request #466 from stweil/opencl
Fix some typos (found by codespell)
2016-11-22 09:11:24 +01:00
Stefan Weil
a7d2758876 opencl: Fix typo in name of local variable
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-22 08:25:43 +01:00
Stefan Weil
a0fc4320b7 Fix an unfixed merge conflict
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-22 08:24:44 +01:00
Ray Smith
9c7e99b041 Merged with commit 4ca6ba985b 2016-11-21 08:27:02 -08:00
Ray Smith
5913d7344f Added missing license headers 2016-11-18 15:53:11 -08:00
Stefan Weil
4ca6ba985b opencl: Fix type of parameter for clGetProgramInfo
CL_PROGRAM_NUM_DEVICES expects a cl_uint.

Passing size_t results in a wrong value for numDevices on hosts where
sizeof(cl_uint) != sizeof(size_t).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-12 22:12:54 +01:00
Stefan Weil
ec5b1bdfa3 opencl: Fix type of parameter for clGetContextInfo
CL_CONTEXT_NUM_DEVICES expects a cl_uint.

Passing size_t results in a wrong value for numDevices on hosts where
sizeof(cl_uint) != sizeof(size_t). This results in errors like these:

  Tesseract Open Source OCR Engine v3.05.00dev with Leptonica
  OpenCL error code is -44 at   when clCreateKernel kernel_HistogramRectAllChannels .
  OpenCL error code is -44 at   when clCreateKernel kernel_HistogramRectAllChannelsReduction .
  OpenCL error code is -48 at   when clSetKernelArg imageBuffer .
  ...

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-12 22:12:49 +01:00
Ray Smith
2c837dffc3 Result of clang tidy on recent merge 2016-11-07 10:46:33 -08:00
Stefan Weil
a1b9e98df5 opencl: Remove unused function getNumDeviceWithEmptyScore
This fixes compiler warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-07 09:41:05 +01:00
Stefan Weil
10886d3f91 opencl: Add missing argument for L_WARNING
gcc report:

In file included from /usr/include/leptonica/alltypes.h:36:0,
                 from /usr/include/leptonica/allheaders.h:34,
                 from openclwrapper.h:2,
                 from openclwrapper.cpp:11:
openclwrapper.cpp: In static member function 'static PIX* OpenclDevice::pixReadMemTiffCl(const l_uint8*, size_t, l_int32)':
/usr/include/leptonica/environ.h:442:68: warning: format '%d' expects a matching 'int' argument [-Wformat=]
              (void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
                                                                    ^
/usr/include/leptonica/environ.h:427:61: note: in definition of macro 'IF_SEV'
       ((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
                                                             ^
opencl/openclwrapper.cpp:1162:3: note: in expansion of macro 'L_WARNING'
   L_WARNING("tiff page %d not found", procName);
   ^

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-05 20:57:30 +01:00
Stefan Weil
90dad1f2ae opencl: Fix wrong implementation of function getNumDeviceWithEmptyScore
gcc report:

opencl_device_selection.h: In function 'ds_status getNumDeviceWithEmptyScore(ds_profile*, unsigned int*)':
opencl_device_selection.h:589:13: warning: value computed is not used [-Wunused-value]
       *num++;
             ^

This is caused by a buggy implementation which increases the value of num
instead of *num.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-05 20:57:30 +01:00
Stefan Weil
1a0aadabd3 opencl: Move declaration of MORPH_BC from .h to .cpp file
It is only used locally in opencl/openclwrapper.cpp.

For all other files which include openclwrapper.h, the compiler
complained about an unused static variable:

opencl/openclwrapper.h:175:16: warning:
 ‘MORPH_BC’ defined but not used [-Wunused-variable]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-11-01 20:15:29 +01:00
Stefan Weil
aea20224a1 opencl: Clean handling of lmask32, rmask32
Both arrays are only used in openclwrapper.cpp, so move them into that
file.

The first element of both arrays was unused. Remove it and fix the code
which reads the array elements accordingly. Sort this code, too.

These changes reduce the code size a little bit:

   text	   data	    bss	    dec	    hex	filename
2461743	   6676	2742784	5211203	 4f8443	1/api/tesseract (old)
2461599	   6676	2742784	5211059	 4f83b3	2/api/tesseract (new)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-31 09:56:59 +01:00
Stefan Weil
ab8209cbcb opencl: Fix mismatched new[] / free
valgrind report: Mismatched free() / delete / delete []

gpuInfo->mpArryDevsID is created by "new cl_device_id[1]",
so it must be destroyed by delete[].

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-29 16:51:48 +02:00
Stefan Weil
f67381a707 opencl: Fix compiler warning [-Wwrite-strings]
gcc report:

opencl/openclwrapper.cpp:3245:22: warning:
 deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-28 20:04:36 +02:00
Stefan Weil
bccf1c10f1 opencl: Fix delete operation
gcc report:

opencl/openclwrapper.cpp:3169:12: warning: deleting 'void*' is undefined

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-28 20:04:36 +02:00
Stefan Weil
3ac54b935c opencl: Fix compiler warning [-Wconversion-null]
gcc report:

opencl/openclwrapper.cpp:84:23: warning:
 converting to non-pointer type 'char' from NULL [-Wconversion-null]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-10-28 20:04:36 +02:00
Wootton, Michael
f46dfdc29d Fix a padding problem in ThresholdRectToPixOCL 2016-10-27 22:26:39 +02:00
Wootton, Michael
5db760215f Fix openCL crash at startup after device profiling 2016-10-27 22:16:22 +02:00
zdenop
0497dc0e3e Merge pull request #17 from tesseract-ocr/gcode_issue1351
Issue 1351: OpenCL build - kernel_ThresholdRectToPix() not accounting for padding bits in the output pix?!
2016-08-29 17:28:42 +02:00
Zdenko Podobný
60176fc5ae replace __CYGWIN32__ with __CYGWIN__ 2016-03-25 14:58:24 +01:00
Dennis Schridde
6072814fea Compatibility with Leptonica 1.73
http://www.leptonica.org/source/version-notes.html:
       Naming changes (to avoid collisions):
         #defines MALLOC --> LEPT_MALLOC, CALLOC --> LEPT_CALLOC, etc.
         ByteBuffer --> L_ByteBuffer

Introduction of the TESSERACT_LIBLEPT_PREREQ macro allows backward compatibility with Leptonica <1.73.
2016-01-31 12:21:20 +01:00
Stefan Weil
511e7f7908 Fix case of include file name
Windows.h works on Windows, but not for cross builds on Linux hosts
with case sensitive file systems which only provide windows.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-11-05 06:38:01 +01:00
Stefan Weil
a21621bc4f opencl: Fix typos in comments and strings
All of them were found by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2015-11-04 21:58:42 +01:00
James R. Barlow
18ac7ae7ef Get OpenCL to compile on OS X
However, the output of the OpenCL build is garbage....
2015-08-26 02:03:07 -07:00
James R. Barlow
65f1a96e3a Fix various clang compilation errors
Also fixed a writable strings warning/error.
warning: ISO C++11 does not allow conversion from
      string literal to 'char *' [-Wwritable-strings]

Several were of this form and fixed as the compiler suggested:
openclwrapper.cpp:2411:33: error: non-constant-expression cannot be narrowed
      from type 'int' to 'size_t' (aka 'unsigned long') in initializer list
      [-Wc++11-narrowing]
    size_t local_work_size[] = {block_size};
                                ^~~~~~~~~~
openclwrapper.cpp:2411:33: note: insert an explicit cast to silence this issue
    size_t local_work_size[] = {block_size};
                                ^~~~~~~~~~
                                static_cast<size_t>( )

Should have low impact on other platforms/compilers. The change makes
the code more correct.
2015-08-26 01:00:05 -07:00
James R. Barlow
8476d0bc6b Fix missing "allheaders.h" when compiling with --enable-opencl on OS X 2015-08-26 00:47:59 -07:00
Zdenko Podobný
0c3c3eaba8 fix VS2010 build 2015-08-24 14:54:13 +02:00
gargrahul
5c6a57b727 Fixes for OpenCL issues reported on Apple Mac. Still get -54 on Apple Mac while running on OpenCL CPU, however it is ignored now. 2015-08-24 15:57:18 +05:30
Zdenko Podobný
66a76a9477 Revert "temporary add config/*, configure and Makefile.in for release"
This reverts commits ec9581d8f2, 1afe382c4e, 4b2cfabcc1
2015-07-31 21:44:43 +02:00
Zdenko Podobný
ec9581d8f2 temporary add configure and Makefile.in for release 2015-07-11 09:42:43 +02:00
Ray Smith
bb8cf7b3ae Yet another clang format fix 2015-07-09 14:56:22 -07:00
Ray Smith
a303ab9d00 Misc fixes, mostly clang formatting, but some bug fixes in matrix, werd, and tesstrain_utils. Also updates unicharset to match traineddata files. 2015-07-09 14:28:20 -07:00
Zdenko Podobný
d00d833b9b fix OpenCL on mac thank to mevikas (https://code.google.com/p/tesseract-ocr/issues/detail?id=1479) 2015-06-29 12:39:29 +02:00
zhivko.tabakov@gmail.com
07be522e43 Issue 1351: OpenCL build - kernel_ThresholdRectToPix() not accounting for padding bits in the output pix?!
https://code.google.com/p/tesseract-ocr/issues/detail?id=1351

What steps will reproduce the problem?
1.Use tesseract build with OpenCL.
2.Pass full color image with width which is not multiple of 32.
3.Recognition is way too slow and does not recognize anything.
I read the article on http://www.sk-spell.sk.cx/tesseract-meets-the-opencl-first-test and decided to give OCL a try. The initial result was as per point 3 above. After some debugging I figured the problem is that the OCL version of threshold rect generation does not account for padding bits in the output pix lines. To prove my discovery I made a quick fix in oclkernels.h replacing the definition of kernel_ThresholdRectToPix

Just a reminder: it is necessary to force OCL kernel recompilation after changing this source (e.g. delete “kernel - <device>.bin” from the exec folder).
The fix is working but I am not sure about it since the original source apparently works for other people (as per the article). If I am right the OS/GPU are irrelevant since the bug is algorithmic, but mine are Windows/AMD. Also similar fix is applicable to kernel_ThresholdRectToPix_OneChan(), but there the input array might have some padding bytes as well, so its indexing will need further adjustments. I can come with some prove/fix for it either - I have not played with it yet.
Disclaimer: I have no prior experience with image processing and tesseract source or with GPU computing and OpenCL (but please do explain if I am wrong).
2015-05-13 21:23:23 +01:00
Zdenko Podobný
5755a5cecb fix opencl build on OSX (issue 1272) 2014-08-18 09:37:21 +02:00
Zdenop
689c8e5667 fix VS2010 build 2014-08-15 23:00:20 +02:00
zdenop
41bd040ef5 fix issue 1043
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1116 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-06-08 21:26:02 +00:00
rajesh.katikam@gmail.com
3ff108cf45 OpenCL fix for PixMemTiff
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1114 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-06-02 05:42:05 +00:00
zdenop@gmail.com
cbc540a944 fix VS2010 opencl build
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1021 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-27 21:34:41 +00:00
zdenop@gmail.com
ac5a8a871b fix windows builds (mingw and VS2010)
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1017 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-26 22:39:20 +00:00
zdenop
644c817f85 fix opencl endl; fix leptonica warning
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1016 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-26 17:38:37 +00:00
zdenop@gmail.com
71ae509354 fix for mingw32/g++ 4.8.1
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@998 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-22 08:10:15 +00:00
theraysmith@gmail.com
fec09faab9 Some formatting changes only to make it a bit more consistent with the rest of the code
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@991 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-17 18:51:27 +00:00
zdenop
26f8f58042 fix android issues
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@990 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-15 22:47:37 +00:00
zdenop
3d1e1cc23d fix opencl build
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@986 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-13 22:41:52 +00:00
theraysmith@gmail.com
8f08a64b65 Fix for opencl on mac?
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@968 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2014-01-09 18:08:58 +00:00
zdenop
8b3e590123 fix OpenCL build on OSX 10.9; add info about OpenCL to 'tesseract -v'
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@921 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2013-12-14 08:35:14 +00:00
rajesh.katikam@gmail.com
b8d7a1d139 Fixed all the crashes observed on 24 bit and 8 bit images.
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@919 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2013-12-10 10:52:54 +00:00
zdenop
38b25b5777 fix issue 1018, 1031
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@918 d0cd1f9f-072b-0410-8dd7-cf729c803f20
2013-12-06 22:07:46 +00:00