I want to use OpenCL for face recognition enhancement.
I am using code OpenCV-2.x from OpenCV documentation:
VideoCapture vcap(...);
ocl::OclCascadeClassifier fd("haar_ff.xml");
ocl::oclMat frame, frameGray;
Mat frameCpu;
vector<Rect> faces;
for(;;){
// processing loop
vcap >> frameCpu;
frame = frameCpu;
ocl::cvtColor(frame, frameGray, BGR2GRAY);
ocl::equalizeHist(frameGray, frameGray);
fd.detectMultiScale(frameGray, faces, ...);
// draw rectangles
// show image
That code compiles well, but program don't work with error:
OpenCV Error: Assertion failed (localThreads[0] * localThreads[1] * localThreads[2] <= kernelWorkGroupSize) in openCLVerifyKernel,
file /root/Downloads/opencv-2.4.9/modules/ocl/src/cl_operations.cpp, line 349
terminate called after throwing an instance of 'cv::Exception'
what(): /root/Downloads/opencv-2.4.9/modules/ocl/src/cl_operations.cpp:349:
error: (-215) localThreads[0] * localThreads[1] * localThreads[2] <= kernelWorkGroupSize in function openCLVerifyKernel
My board is imx6q Saber Lite with Ubuntu Xenial for i.MX6/7 boards August 2016 (kernel 4.1.15) image.
I can't find how to resolve this problem. And if it's not possible at all to use OpenCL, there is a question: how can I speed up a face recognition on imx6q Saber Lite?
Hi Ivan,
Looks like OpenCV is not using floating point, needs to install again, OpenCV works on Sabre board.
OpenCV works, only that code doesn't work.
I recompiled Ot with options in qmake.conf:
IMX6_CFLAGS = -mthumb -O3 -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mvectorize-with-neon-quad -mfpu=neon -mfloat-abi=hard -DLINUX=1 -DEGL_API_FB=1
And I recompiled OpenCV with options:
cmake CMAKE_BUILD_TYPE=RELEASE -DWITH_TBB=ON -DWITH_OPENGL=ON -DENABLE_NEON=ON -DENABLE_VFPV3=ON
But the same error.
I found out operation frame=frameCpu in code gives error.
imx6q only supports OpenCL 1.1 Embedded Profile not the Full Profile therefore it cant' be enabled for OpenCV. Ideally OpenCV requires a SOC with OpenCL 1.2 Full Profile support. If you can move to imx6q plus then OpenGL 1.2 support should be available.
The only optimization would be to ENABLE_NEON=ON and ENABLE_VFPV3=ON .