View on GitHub

CV-Sandbox

Just a random assortment of computer vision projects.

Windows Ubuntu
Demonstration of Project 5 working in Windows Demonstration of Project 5 working in Ubuntu

Project 5: GLFW + OpenCV + ImGui

This project demonstrates the use of GLFW to create a window with an OpenGL context. Like all projects so far, this one exists in a single C++ source code file.

Table of Contents

Usage

Three sliders control basic settings used in the render pipeline:

The Gist

This project is a continuation of Project 4 and builds off of my ImGui setup from Project 3.

Like Projects 1 and 4, it opens the default fox image in the media directory with OpenCV. The contents of that image are placed in a cv::Mat.

	// Load the image
	// Get an image name 
	string filename = MEDIA_DIRECTORY;
	// MEDIA_DIRECTORY is defined in the root-level CMake script
	filename += "RedFox.png";
	// Load the image
	const Mat image = imread(filename);

To render a cv::Mat on the ImGui window, I converted it to a GLuint using the static GLuint matToTexture() function introduced in project 4.

	GLuint image_texture = matToTexture(image, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP);

Then, it can be rendered in a window using the ImGui::Image() function.

	mGui::Image((void*)(intptr_t)image_texture, imageSize);

Resources

Code samples