Testing openGl with OpenCv on Tx2.

I am using latest Jetpack 4.2.1 and compiled opencv with opengl.
Opencv is compiled without any error and following were the parameters

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
-D OPENCV_EXTRA_MODULES_PATH=…/…/opencv3.4/opencv_contrib-3.4.1/modules
-D WITH_CUDA=ON -D CUDA_ARCH_BIN=“6.2” -D CUDA_ARCH_PTX=""
-D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON
-D ENABLE_NEON=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF
-D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF
-D WITH_QT=ON -D WITH_OPENGL=ON …

I made a simple test to check opengl. The mat blow display blue correctly while opengl window stays black. I am not able to resolve it although there are no compilation or run time error.

int main(int argc, char* argv)
{
Mat testImage(480, 640, CV_8UC3, cv::Scalar(0xBB));
cv::namedWindow(“OpenGL”, cv::WINDOW_OPENGL | cv::WINDOW_AUTOSIZE);

cuda::GpuMat testImageGpu;
testImageGpu.upload(testImage);

cv::imshow("OpenGL", testImageGpu);
cv::imshow("Window", testImage);
cv::waitKey(5000);
return 0;

}

Since you are using 3 channels mats, try initializing with:

Mat testImage(480, 640, CV_8UC3, cv::Scalar(0xBB, 0x00, 0x00));

Hi,
Please also refer to
https://devtalk.nvidia.com/default/topic/1047817/jetson-agx-xavier/black-images-with-qt5-and-opengl/post/5392977/#5392977

The solution provided in the link is to use qt4 while making opencv but i require qt5? So is there any solution to that ?

Hi,
It is more like that qt5 does not work well with OpenCV. You might see if other users can share experience on this.