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 files): + POPCNT SSE4_2 FP16 AVX
AVX (5 files): + POPCNT SSE4_2 AVX
AVX2 (30 files): + POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (6 files): + POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ (ver 10.0.1.10010046)
C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-dead_strip
Linker flags (Debug): -Wl,-dead_strip
ccache: NO
Precompiled headers: NO
Extra dependencies:
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: -
Unavailable: alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java js matlab ovis python3 sfm viz
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: NO
GUI:
Cocoa: YES
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 2.0.4-62)
WEBP: build (ver encoder: 0x020f)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.0.10)
JPEG 2000: build Jasper (ver 1.900.1)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: NO
FFMPEG: NO
avcodec: NO
avformat: NO
avutil: NO
swscale: NO
avresample: NO
GStreamer: NO
AVFoundation: YES
Parallel framework: GCD
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2020.0.0 Gold [2020.0.0]
at: /Users/rnd/Downloads/opencv-4.3.0/build/3rdparty/ippicv/ippicv_mac/icv
Intel IPP IW: sources (2020.0.0)
at: /Users/rnd/Downloads/opencv-4.3.0/build/3rdparty/ippicv/ippicv_mac/iw
Lapack: YES (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Accelerate.framework -lm -ldl)
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (no extra features)
Include path: NO
Link libraries: -framework OpenCL
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.10)
Libraries: /usr/lib/libpython2.7.dylib (ver 2.7.10)
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include (ver 1.8.0rc1)
install path: lib/python2.7/site-packages/cv2/python-2.7
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers
Java wrappers: NO
Java tests: NO
Install to: /usr/local
-----------------------------------------------------------------
I also ran the OpenCV_test_calib3d, which contains this function. The test passed until the findChessboardCornersSB test is executed, here I get the same error as in my own code:
[----------] 1 test from Calib3d_ChessboardDetector2
[ RUN ] Calib3d_ChessboardDetector2.accuracy
[ 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_May_14_2020_20_18_44_
GPU hang occurred, msgtracer returned -1