'cvui'에 해당되는 글 1건

  1. 2019.07.01 OpenCV Graphic User Interface(GUI) with cvui
반응형

cvui is 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).


OpenCV는 실시간 이미지 프로세싱에 중점을 둔 라이브러리로, 기본적인 GUI 지원은 상당히 빈약하기 때문에 대부분 MFC나 QT등의 라이브러리를 이용해 따로 GUI를 구현 합니다. 보통 이런 라이브러리들은 공부하고 실제 사용하는데 상당히 오랜 시간이 걸리므로 쉽고 간단히 사용할 수 있는 cvui의 사용법을 알아 보도록 하겠습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <opencv2/opencv.hpp>
 
#define CVUI_IMPLEMENTATION
#include "cvui.h"
 
using namespace cv;
 
int main(int argc, char** argv)
{
    Mat img = imread("image.jpg");
    Mat canny;
    double threshold1 = 50.0;
    double threshold2 = 150.0;
    bool checked = false;
 
    if (img.empty())
        return -1;
 
    cvui::init("Canny");
 
    while (true)
    {
        if (checked)
        {
            cvtColor(img, canny, CV_BGR2GRAY);
            Canny(canny, canny, threshold1, threshold2);
            cvtColor(canny, canny, CV_GRAY2BGR);
 
            cvui::trackbar(canny, 10160195&threshold1, (double)5.0, (double)100.0);
            cvui::trackbar(canny, 10210195&threshold2, (double)50.0, (double)200.0);
        }
        else
        {
            img.copyTo(canny);
        }
 
        cvui::text(canny, 1010"cvui example"1.00xff0000);
        if (cvui::button(canny, 1060"Exit"))
            break;
        cvui::checkbox(canny, 10110"Canny edge detection"&checked);
 
        cvui::update();
 
        imshow("Canny", canny);
 
        waitKey(10);
    }
 
    return 0;
}
cs







반응형
Posted by J-sean
: