# opencv-patch **Repository Path**: jiejietop/opencv-patch ## Basic Information - **Project Name**: opencv-patch - **Description**: opencv 补丁仓库 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-15 - **Last Updated**: 2023-03-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # opencv 补丁 ## opencv 4.1.1 0001-fix-opencv-v4.1.1-gl-version-bug.patch : 修复opencv在Xavier上依赖gl的问题。 参考连接: [https://jkjung-avt.github.io/opencv3-on-tx2/](https://jkjung-avt.github.io/opencv3-on-tx2/) ```bash From 1f9209e89b4e7a60f85ab0f1df80e575ade3554d Mon Sep 17 00:00:00 2001 From: jiejie Date: Wed, 15 Jun 2022 12:23:01 +0800 Subject: [PATCH] fix opencv v4.1.1 gl version bug --- modules/core/src/opengl.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index b8decd508a..5ff3c717b6 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -45,6 +45,13 @@ #ifdef HAVE_OPENGL # include "gl_core_3_1.hpp" # ifdef HAVE_CUDA +# if (defined(__arm__) || defined(__aarch64__)) \ + && !defined(OPENCV_SKIP_CUDA_OPENGL_ARM_WORKAROUND) +# include +# ifndef GL_VERSION +# define GL_VERSION 0x1F02 +# endif +# endif # include # endif #else // HAVE_OPENGL @@ -1682,9 +1689,14 @@ Context& initializeContextFromGL() if (found < 0) CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't create context for OpenGL interop"); - Context& ctx = Context::getDefault(false); - initializeContextFromHandle(ctx, platforms[found], context, device); - return ctx; + cl_platform_id platform = platforms[found]; + std::string platformName = PlatformInfo(&platform).name(); + + OpenCLExecutionContext clExecCtx = OpenCLExecutionContext::create(platformName, platform, context, device); + clReleaseDevice(device); + clReleaseContext(context); + clExecCtx.bind(); + return const_cast(clExecCtx.getContext()); #endif } -- 2.25.1 ```