Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

License

NotificationsYou must be signed in to change notification settings

Dovyski/cvui

Repository files navigation

A (very) simple UI lib built on top of OpenCV drawing primitives. Other UI libs, such asimgui, 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 usesonly 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 addcvui.h (orcvui.py) to your project and you are ready to go. The only dependency is OpenCV (version2.x or3.x), which you are probably using already.

Usage

Check theonline documentation or theexamples 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.#defineCVUI_IMPLEMENTATION#include"cvui.h"#defineWINDOW_NAME"CVUI Hello World!"intmain(int argc,constchar *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 colorframe =cv::Scalar(49,52,49);// Render UI components to the framecvui::text(frame,110,80,"Hello, world!");cvui::text(frame,110,120,"cvui is awesome!");// Update cvui stuff and show everything on the screencvui::imshow(WINDOW_NAME, frame);if (cv::waitKey(20) ==27) {break;}}return0;}

Usage in Python:

importnumpyasnpimportcv2importcvuiWINDOW_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)whileTrue:# Fill the frame with a nice colorframe[:]= (49,52,49)# Render UI components to the framecvui.text(frame,110,80,'Hello, world!')cvui.text(frame,110,120,'cvui is awesome!')# Update cvui stuff and show everything on the screencvui.imshow(WINDOW_NAME,frame)ifcv2.waitKey(20)==27:break

License

Copyright (c) 2016 Fernando Bevilacqua. Licensed under theMIT license.

Change log

See all changes in theCHANGELOG file.


[8]ページ先頭

©2009-2025 Movatter.jp