opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
78.96k stars 55.81k forks source link

ORB OpenCL in opencv 3.1-dev is different with opencv3.1 release, and something is wrong there. #7798

Open chyojn opened 7 years ago

chyojn commented 7 years ago
System information (version)
Detailed description

compare with opencv 3.1 release version's ORB: the detected keypoint info has no difference with 3.1, both has same x, y, angle, and size, but the extracted descriptor is different. if I compile the latest 3.1.0-dev without opencl support, the extracted descriptor is same with 3.1 version's descriptor.

Steps to reproduce

the ORB feature can be test by this: https://github.com/BloodAxe/OpenCV-Features-Comparison. If I use the 3.1.0-dev with opencl support, the orb's precision and recall are very low: Average Recall ORB Brightness change 0.527154 ORB Gaussian blur 0.333556 ORB Rotation 0.0643926 ORB Scaling 0.101222 Average Precision ORB Brightness change 0.672338 ORB Gaussian blur 0.490562 ORB Rotation 0.0712741 ORB Scaling 0.174263

If I use the 3.1.0-dev WITHOUT opencl support, the orb's precision and recall are much higher: Average Recall ORB Brightness change 0.622231 ORB Gaussian blur 0.419333 ORB Rotation 0.487047 ORB Scaling 0.393111 Average Precision ORB Brightness change 0.802267 ORB Gaussian blur 0.608733 ORB Rotation 0.649895 ORB Scaling 0.63038

alalek commented 7 years ago

Please run OpenCV features2d accuracy test (it will be good to run core/imgproc tests too) and add results into this issue. Also please dump OpenCL device information (from tests stdout log).

chyojn commented 7 years ago

both imgproc and features have some failed test case when I enable the opencl:

opencv_test_imgproc_ocl.txt opencv_test_features2d_ocl.txt

opencv_test_imgproc_no_ocl.txt opencv_test_features2d_no_ocl.txt

My hardware is macbook air 13'.

I build the opencv with the cmake options (with opencl):

cmake .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/opt/opencv3_head -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DBUILD_JASPER=OFF -DBUILD_JPEG=OFF -DBUILD_TIFF=OFF -DBUILD_OPENEXR=OFF -DBUILD_PNG=OFF -DBUILD_ZLIB=OFF -DCMAKE_OSX_DEPLOYMENT_TARGET= -DJPEG_INCLUDE_DIR=/usr/local/opt/jpeg/include -DJPEG_LIBRARY=/usr/local/opt/jpeg/lib/libjpeg.dylib -DBUILD_opencv_java=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_TESTS=ON -DBUILD_PERF_TESTS=ON -DWITH_1394=OFF -DWITH_EIGEN=ON -DWITH_FFMPEG=OFF -DWITH_GPHOTO2=OFF -DWITH_GSTREAMER=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=ON -DWITH_OPENGL=OFF -DWITH_QUICKTIME=OFF -DWITH_QT=OFF -DWITH_TBB=OFF -DWITH_VTK=OFF -DWITH_CUDA=OFF -DOPENCV_EXTRA_MODULES_PATH=/Users/xxx/Work/opencv_contrib/modules -DBUILD_opencv_matlab=OFF -DBUILD_opencv_dnn=OFF -DWITH_OPENCL=ON -DENABLE_SSSE3=ON -DENABLE_SSE41=ON -DENABLE_SSE42=ON -DENABLE_AVX=ON

alalek commented 7 years ago

Thanks for update! Looks like there is OpenCL-related issues. Usually I suggest to update OpenCL runtime, but unfortunately there is no easy way to update it on Apple hardware. Could you check this patch with your app: #7787 (it should stop using OpenCL implicitly (for Mat) in ORB)?

chyojn commented 7 years ago

after patch 7787, test_features2d passed, but test_imgproc still have some failed case.

opencv_test_features2d_ocl_7787.txt opencv_test_imgproc_ocl_7787.txt

alalek commented 7 years ago

Actually we observe similar failures in imgproc test on Mac mini device:

OpenCL Platforms: 
    Apple
        CPU: Intel(R) Core(TM) i7-4578U CPU @ 3.00GHz (OpenCL 1.2 )
        iGPU: Iris (OpenCL 1.2 )
...
[  FAILED  ] 7 tests, listed below:
[  FAILED  ] OCL_ImgProc/CvtColor8u.BGR5552BGR/0, where GetParam() = (CV_8U, false)
[  FAILED  ] OCL_Filter/MorphFilter3x3_cols16_rows2.Mat/1, where GetParam() = (8UC1, 0, 0x0, BORDER_CONSTANT, 1, true, 1)
[  FAILED  ] OCL_Filter/MorphFilter3x3_cols16_rows2.Mat/2, where GetParam() = (8UC1, 0, 0x0, BORDER_CONSTANT, 2, false, 1)
[  FAILED  ] OCL_Filter/MorphFilter3x3_cols16_rows2.Mat/3, where GetParam() = (8UC1, 0, 0x0, BORDER_CONSTANT, 2, true, 1)
[  FAILED  ] OCL_Filter/MorphFilter3x3_cols16_rows2.Mat/4, where GetParam() = (8UC1, 0, 0x0, BORDER_CONSTANT, 3, false, 1)
[  FAILED  ] OCL_Filter/MorphFilter3x3_cols16_rows2.Mat/5, where GetParam() = (8UC1, 0, 0x0, BORDER_CONSTANT, 3, true, 1)
[  FAILED  ] OCL_Filter/MorphFilter3x3_cols16_rows2.Mat/7, where GetParam() = (8UC1, 3, 0x0, BORDER_CONSTANT, 1, true, 1)

These tests are failed for unknown strange reason. We are not able to reproduce these failures on other OpenCL devices (AMD iGPUs / Intel(R) HD Graphics 530. Moreover opencv_test_core just hangs on Mac mini. My current suggestion is just disable OpenCL on Apple platform due strange OpenCL runtime behavior.

skylook commented 7 years ago

I can confirm that with same code, orb in opencv 2.4.x performs much better than opencv 3.1.x. Even though I donot use opencl.