Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to load OpenCL runtime in OpenCV for Python

I am trying to run the first example here, but I am getting this error. I am using Ubuntu 13.10.

Failed to load OpenCL runtime
OpenCV Error: Unknown error code -220 (OpenCL function is not available: [clGetPlatformIDs]) in opencl_check_fn, file /home/cristi/opencv/modules/core/src/opencl/runtime/opencl_core.cpp, line 204
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/cristi/opencv/modules/imgproc/src/color.cpp, line 3159
Traceback (most recent call last):
  File "/home/cristi/opencv1/src/video.py", line 11, in <module>
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: /home/cristi/opencv/modules/imgproc/src/color.cpp:3159: error: (-215) scn == 3 || scn == 4 in function cvtColor


Process finished with exit code 1

Also, this is the line that is causing the trouble (line 11 in my code):

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

What should I do?

like image 546
cgf Avatar asked Dec 02 '22 20:12

cgf


2 Answers

As for the OpenCL failure, try installing required packages:

sudo apt-get install ocl-icd-opencl-dev

Worked for me. My guess is that OCL is a part of the opencv_core module, and if it failed to initialise, then many other components might behave strange.

like image 69
a-Jays Avatar answered Dec 05 '22 10:12

a-Jays


You might want to install/update the driver: http://streamcomputing.eu/blog/2011-12-29/opencl-hardware-support/

Updating the driver help to solve my problem with OpenCL

like image 44
ClessA Avatar answered Dec 05 '22 10:12

ClessA