Ask Your Question
0

How to compile/run sample programs, specifically opengl_interop

asked 2018-08-31 16:26:22 -0600

jaguardo gravatar image

I complied using this:

g++ -ggdb opengl_interop.cpp -o opengl_interop `pkg-config --cflags --libs opencv` -lGL -lGLU -lX11

and then run

./opengl_interop -c

result

Usage: opengl_interop [params] 

-c, --camera (value:true)
    use camera or not
-f, --file
    movie file name
-h, --help (value:false)
    print help info
[ INFO:0] Initialize OpenCL runtime...
OpenCV(3.4.1) Error: Unknown error code -222 (OpenCL: Can't create context for OpenGL interop) in initializeContextFromGL, file /OpenCV/modules/core/src/opengl.cpp, line 1683 Exception: OpenCV(3.4.1) /OpenCV/modules/core/src/opengl.cpp:1683: error: (-222) OpenCL: Can't create context for OpenGL interop in function initializeContextFromGL

I've tried a few other programs that require the same interoperability and I'm not able to get them to work either.

edit retag flag offensive close merge delete

Comments

I started debugging the opengl.cpp file and

 Context& initializeContextFromGL()

fails at this line:

 status = clGetGLContextInfoKHR(properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, sizeof(cl_device_id), (void*)&device, NULL);

This line is not successful, so the next if statement if(status != CL_SUCCESS) causes the function to exit the for loop it is in and the cl context is never created and leads to:

    if (found < 0)
    CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't create context for OpenGL interop");
jaguardo gravatar imagejaguardo ( 2018-09-01 09:11:14 -0600 )edit

I believe maybe there is a difference between

 CL_PLATFORM_EXTENSIONS

and

 CL_DEVICE_EXTENSIONS

The OpenCV code looks for platform. Which when I look in the clinfo list, I do not have "cl_khr_gl_sharing" listed for my platform. Whereas maybe it should look for the device info, because I have that extension listed for my device extensions.

This line is what I am wondering about:

             if (!strstr((const char*)extensionStr, "cl_khr_gl_sharing"))
            continue;
jaguardo gravatar imagejaguardo ( 2018-09-01 09:40:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-09-03 20:44:48 -0600

jaguardo gravatar image

updated 2018-09-03 20:46:52 -0600

Looks like there is a bug for ATI/AMD cards: https://github.com/opencv/opencv/issu... (Basically the ATI/AMD cards seem to store the extensions on the device, OpenCV seems to check for them on the platform... so the program drops out when it can not confirm the correct extension.)

Wondering if anyone else can confirm?

I tried to follow the recommendation in the bug report:

Commenting out the extension check in lines 1640-1641 //if (!strstr((const char*)extensionStr, "cl_khr_gl_sharing")) // continue;

I then tried the sample again and received:

OpenCV(3.4.1) Error: Assertion failed (anchor.inside(Rect(0, 0, ksize.width, ksize.height))) in normalizeAnchor, file OpenCV/modules/imgproc/src/filterengine.hpp, line 363 Exception: OpenCV(3.4.1) OpenCV/modules/imgproc/src/filterengine.hpp:363: error: (-215) anchor.inside(Rect(0, 0, ksize.width, ksize.height)) in function normalizeAnchor

I'm not sure if the error (-215) refers to an OpenCL or an OpenCV error? I can't find an -215 error for OpenCL.

edit flag offensive delete link more

Comments

@sturkmen , btw: why did you need to change the anchor for the d3d samples, but not for gl here ?

berak gravatar imageberak ( 2018-09-03 23:41:07 -0600 )edit
1
sturkmen gravatar imagesturkmen ( 2018-09-04 01:12:33 -0600 )edit

oh, thanks, i missed it.

so, updating to current 3.4 should fix the anchor problem above ?

berak gravatar imageberak ( 2018-09-04 01:18:44 -0600 )edit
2

no need to update library just change the line in the sample

//cv::blur(m, m, cv::Size(15, 15), cv::Point(-7, -7));  
cv::blur(m, m, cv::Size(15, 15), cv::Point(-1, -1));
sturkmen gravatar imagesturkmen ( 2018-09-04 01:38:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-31 16:26:22 -0600

Seen: 386 times

Last updated: Sep 03 '18