Skip to content

CL/GL interop code doesn't print cl status codes on failure #22854

@kallaballa

Description

@kallaballa

System Information

OpenCV version: 4.x
Operating System / Platform: openSUSE Tumbleweed (20221102) / Linux
Compiler & compiler version: g++ (SUSE Linux) 12.2.1 20221020 [revision 0aaef83351473e8f4eb774f8f999bbe87a4866d7]

Detailed description

When a CL/GL interop function like convertToGLTexture2D fails it doesn't report the cl status. e.g.:

if (status != CL_SUCCESS)
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLTexture failed");

I would like to change that to (for every instance):

    if (status != CL_SUCCESS)
        CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromGLTexture failed: " + std::to_string(status));

Steps to reproduce

    cv::ogl::Texture2D tex(cv::Size(WIDTH, HEIGHT), cv::ogl::Texture2D::RGBA, false);
    GLuint texId = tex.texId();
    glDeleteTextures(1, &texId);
    cv::UMat um;
    convertFromGLTexture2D(tex, um);

results in:

OpenCV(4.6.0-dev) Error: Unknown error code -220 (OpenCL: clCreateFromGLTexture failed) in convertFromGLTexture2D, file /home/elchaschab/devel/opencv/modules/core/src/opengl.cpp, line 1843
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.6.0-dev) /home/elchaschab/devel/opencv/modules/core/src/opengl.cpp:1843: error: (-220:Unknown error code -220) OpenCL: clCreateFromGLTexture failed in function 'convertFromGLTexture2D'

No CL status.

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions