Alexey
Alexey

Reputation: 5978

Drawing in OpenCV with OpenGL

OpenCV library, when compiled with GPU and OpenGL support, allows for displaying images with OpenGL. For example, video_reader.cpp (located in gpu samples) uses OpenGL to render display graphics directly from cv::gpu::GpuMat.

cv::gpu::GpuMat d_frame;
namedWindow("OpenGL", WINDOW_OPENGL);
cv::gpu::VideoReader_GPU d_reader(fname);
d_reader.dumpFormat(std::cout);
if (!d_reader.read(d_frame))
    break;
cv::imshow("GPU", d_frame);

This is a very useful feature. However, it is not documented in the documentation on-line. For example, for namedWindow the flag WINDOW_OPENGL is not listed in the docs. Where can I find the documentation for OpenGL -related functionality of OpenCV?

Upvotes: 1

Views: 5024

Answers (3)

kallaballa
kallaballa

Reputation: 377

Especially the second link gives you two easy options for rendering.

Upvotes: 2

Elliot Woods
Elliot Woods

Reputation: 844

The function

cv::imshow(const & string, cv::InputArray)

does not natively support gpu matrices, but supports GPU matrices by casting.

i.e. anything which supports a cv::Mat on its input should also support cv::gpu::GpuMat. I presume this means that when you call the function, it will automatically download the matrix to a cv::Mat and go from there, i.e. your imshow function call is not drawing directly gpu->gpu, but going gpu->cpu->gpu.

Upvotes: 0

BW0
BW0

Reputation: 767

The documentation is not very complete for 2.4.5. I don't think there is any more documentation than what you see on http://docs.opencv.org.

There are older documentation, such as http://opencv.willowgarage.com/documentation/cpp/ for 2.1, but I didn't find it having the documentation for the flag that you wanted.

Upvotes: 2

Related Questions