• Stars
    star
    820
  • Rank 55,603 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A (very) simple UI lib built on top of OpenCV drawing primitives

cvui

A (very) simple UI lib built on top of OpenCV drawing primitives. Other UI libs, such as imgui, require a graphical backend (e.g. OpenGL) to work, so if you want to use imgui in a OpenCV app, you must make it OpenGL enabled, for instance. It is not the case with cvui, which uses only OpenCV drawing primitives to do all the rendering (no OpenGL or Qt required).

image

Features

  • Lightweight and simple to use user interface;
  • Header-only with no external dependencies (except OpenCV);
  • Based on OpenCV drawing primitives only (OpenGL or Qt are not required);
  • Friendly and C-like API (no classes/objects, etc);
  • Easily render components without worrying about their position (using rows/columns);
  • Simple (yet powerful) mouse API;
  • Modest number of UI components (11 in total);
  • Available in C++ and Python (pure implementation, no bindings).

Build

cvui is a header-only lib that does not require a build. Just add cvui.h (or cvui.py) to your project and you are ready to go. The only dependency is OpenCV (version 2.x or 3.x), which you are probably using already.

Usage

Check the online documentation or the examples folder to learn how to use cvui. The general usage in C++ and Python is shown below.

Usage in C++:

#include <opencv2/opencv.hpp>

// One (and only one) of your C++ files must define CVUI_IMPLEMENTATION
// before the inclusion of cvui.h to ensure its implementaiton is compiled.
#define CVUI_IMPLEMENTATION
#include "cvui.h"

#define WINDOW_NAME "CVUI Hello World!"

int main(int argc, const char *argv[])
{
	// Create a frame where components will be rendered to.
	cv::Mat frame = cv::Mat(200, 500, CV_8UC3);

	// Init cvui and tell it to create a OpenCV window, i.e. cv::namedWindow(WINDOW_NAME).
	cvui::init(WINDOW_NAME);

	while (true) {
		// Fill the frame with a nice color
		frame = cv::Scalar(49, 52, 49);

		// Render UI components to the frame
		cvui::text(frame, 110, 80, "Hello, world!");
		cvui::text(frame, 110, 120, "cvui is awesome!");

		// Update cvui stuff and show everything on the screen
		cvui::imshow(WINDOW_NAME, frame);

		if (cv::waitKey(20) == 27) {
			break;
		}
	}

	return 0;
}

Usage in Python:

import numpy as np
import cv2
import cvui

WINDOW_NAME = 'CVUI Hello World!'

# Create a frame where components will be rendered to.
frame = np.zeros((200, 500, 3), np.uint8)

# Init cvui and tell it to create a OpenCV window, i.e. cv2.namedWindow(WINDOW_NAME).
cvui.init(WINDOW_NAME)

while True:
	# Fill the frame with a nice color
	frame[:] = (49, 52, 49)

	# Render UI components to the frame
	cvui.text(frame, 110, 80, 'Hello, world!')
	cvui.text(frame, 110, 120, 'cvui is awesome!')

	# Update cvui stuff and show everything on the screen
	cvui.imshow(WINDOW_NAME, frame)

	if cv2.waitKey(20) == 27:
		break

License

Copyright (c) 2016 Fernando Bevilacqua. Licensed under the MIT license.

Change log

See all changes in the CHANGELOG file.

More Repositories

1

flixel-studio

Embeddable, in-game editor for HaxeFlixel. Turn the existing Flixel debugger into a full-featured editor!
Haxe
100
star
2

Codebot

Free and open source (MIT license) web-based IDE focused on game development.
JavaScript
93
star
3

opengl-demos

A list of small OpenGL applications to demonstrate concepts of Computer Graphics
C
44
star
4

Achieve

Library to manage and implement achievements in a game.
ActionScript
33
star
5

setup-opencv-action

Github Action to download and setup OpenCV
JavaScript
25
star
6

Jarena

A game approach to teaching OPP and Java.
Java
12
star
7

phd-thesis

My PhD thesis titled "Game-calibrated and user-tailored remote detection of emotions"
TeX
10
star
8

template

My personal template to create new repos, with built-in docs and support for Github Actions.
8
star
9

payload-info-action

Github Action to extract info from the webhook payload object using jq filters.
JavaScript
6
star
10

face-tracking-games

Source code used in the paper "Variations of Facial Actions While Playing Games with Inducing Boredom and Stress", published at VSGames 2016
JavaScript
6
star
11

besearcher

Besearcher (bot researcher) is a tool to help researchers automate and keep track of software-based experiments.
PHP
6
star
12

Aura

A tool with limited AI capabilities to manage computers in academic labs.
PHP
5
star
13

P2PMultiplayerGame

Simple non-authoritative P2P multiplayer game implemented in AS3 using Flixel and AS3Mul.
ActionScript
5
star
14

dotfiles

My personal dot files
Shell
4
star
15

deployer

A simple command-line tool whose aim is to facilitate the continous delivery of PHP apps
PHP
4
star
16

showhide.js

Small and extremely simple javascript lib to show/hide elements conditionally based on HTML data attributes
JavaScript
3
star
17

image-filters

JavaScript
2
star
18

codebot-websites

Source code used for the website and blog of Codebot
PHP
2
star
19

phd-experiment2

Source code of the 2nd experiment conducted during my PhD
JavaScript
2
star
20

As3GameGears

The code powering the website As3GameGears.com
PHP
2
star
21

reslide

Share and remotely control PDF-based presentations, all in the browser, without plugins or network restrictions.
JavaScript
2
star
22

pigeon

Easy to use and hassle-free PHP microservice for sending e-mails via a REST API
PHP
2
star
23

experiment-gec01

Code that powers the online experiment that checks the effect of colors on emotions of stress and boredom
JavaScript
1
star
24

dovyski

1
star
25

aula-cc

Teste para a aula de introdução a informática
Python
1
star
26

Progbot

A webapp to manage programming assignments
PHP
1
star
27

dovyski.github.io

The source and content of my personal website/blog
CSS
1
star
28

Kingade

Kids in Game Development
ActionScript
1
star
29

BDFextractor

A command-line tool to extract information from BDF/EDF files
C++
1
star
30

master-thesis

My master thesis "Tool for real-time generation of coastlines for pseudo-infinite virtual worlds for 3D games"
TeX
1
star