OpenCL error CL_INVALID_VALUE in findChessboardCornersSB

asked 2020-07-07 04:23:37 -0500

laura gravatar image

updated 2020-07-08 08:55:49 -0500

I am trying to run a chessboard detection with the following code:

std::vector<cv::Point2f> Checker::FindCorners(const cv::Mat& img) {
  std::vector<cv::Point2f> corners;

  int flag = 0;
  flag |= cv::CALIB_CB_EXHAUSTIVE;
  flag |= cv::CALIB_CB_ACCURACY;

  auto found = cv::findChessboardCornersSB(img, inner_corners, corners, flag);      
  return corners;
}

When findChessboardCornersSB is executed, I got the following error in the output:

 [ERROR:1] global
 /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp
 (3874) createFromBinary OpenCL error
 CL_INVALID_VALUE (-30) during call:
clCreateProgramWithBinary

The code does not crash and I got the expected result, still I want to solve this error. Can anyone tell me why this error shows and how to solve it?

UPDATE 1: I did some testing on my own and the error does not show on first run after a restart. When I run the code for a second time this error shows or a GPU hang occurred:

[ INFO:0] global /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp (891) haveOpenCL Initialize OpenCL runtime...
[ INFO:0] global /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp (433) OpenCLBinaryCacheConfigurator Successfully initialized OpenCL cache directory: /var/folders/cz/vt505sw56pq74syh09ncswy00000gn/T/opencv/4.3/opencl_cache/
[ INFO:0] global /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp (457) prepareCacheDirectoryForContext Preparing OpenCL cache configuration for context: Intel--Iris--1_2_Aug_20_2019_17_28_41_
OpenCV(4.3.0) Error: Assertion failed (!f.fail()) in read, file /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp, line 725
[ERROR:1] global /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp (3874) createFromBinary OpenCL error CL_INVALID_VALUE (-30) during call: clCreateProgramWithBinary
OpenCV(4.3.0) Error: Assertion failed (!f.fail()) in write, file /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp, line 815
[ WARN:0] global /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp (3708) compileWithCache Can't save OpenCL binary into cache: /var/folders/cz/vt505sw56pq74syh09ncswy00000gn/T/opencv/4.3/opencl_cache/Intel--Iris--1_2_Aug_20_2019_17_28_41_/imgproc--boxFilter_d3e542270fa2ea1fc3744043dad50cb4.bin
OpenCV(4.3.0) /Users/rnd/Downloads/opencv-4.3.0/modules/core/src/ocl.cpp:815: error: (-215:Assertion failed) !f.fail() in function 'write'

GPU hang occurred, msgtracer returned -1

I also ran the code on another PC and this PC shows the same issue.

UPDATE 2: I am running the code on MacOS Mojave, version 10.14.6. The system has an 2.6GHz Intel Core i5 CPU and a Intel Iris 1536 MB GPU I ran cv::getBuildInformation() and it shows the following output:

    General configuration for OpenCV 4.3.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /Users/rnd/Downloads/opencv_contrib-4.3.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2020-07-06T13:07:33Z
    Host:                        Darwin 18.7.0 x86_64
    CMake:                       3.17.3
    CMake generator:             Xcode
    CMake build tool:            /usr/bin/xcodebuild
    Xcode:                       10.3

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3 SSSE3 SSE4_1
      requested:                 DETECT
    Dispatched code generation:  SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_2 (2 files):          + POPCNT SSE4_2
      FP16 (1 ...
(more)
edit retag flag offensive close merge delete

Comments

Can you add the output of cv::getBuildInformation() and some information about your computer in the question?

See this pull request. It uses OpenCL (GPU computing) for some processing. Looks like there is an issue with OpenCL code path. So it automatically fallbacks to the regular CPU code.

You should try to run the OpenCV test suite to see if the OpenCL tests pass on your computer. There is this wiki for more information about OpenCV test. Or you can directly run the corresponding binaries with test in the names. You may need to download the OpenCV extra data for test images.

Eduardo gravatar imageEduardo ( 2020-07-07 14:34:33 -0500 )edit

Thank you Eduardo for your reply. I have updated my original questions with the answers you asked for.

laura gravatar imagelaura ( 2020-07-08 08:54:44 -0500 )edit

Unfortunately, I don't have much experience with OpenCL.

Can you try to run also the core tests: ./opencv_test_core? If you have errors with OpenCL related tests, maybe you have an issue with the OpenCL driver.

FYI:

  • there is this environment variable OPENCV_TEST_DATA_PATH to set the path to the OpenCV extra data folder: <path>/opencv_extra/testdata
    • you can use --gtest_filter= to filter the tests, e.g. ./opencv_test_calib3d --gtest_filter=Calib3d_ChessboardDetector2*
Eduardo gravatar imageEduardo ( 2020-07-08 10:44:37 -0500 )edit