File: highgui_wayland_ubuntu.markdown

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (106 lines) | stat: -rw-r--r-- 2,942 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Using Wayland highgui-backend in Ubuntu {#tutorial_wayland_ubuntu}
=======================================

@tableofcontents

@prev_tutorial{tutorial_intelperc}

|    |    |
| -: | :- |
| Original author | Kumataro |
| Compatibility | OpenCV >= 4.10 |
| ^ | Ubuntu 24.04 |

Goal
-----
This tutorial is to use Wayland highgui-backend in Ubuntu 24.04.

Wayland highgui-backend is experimental implementation.

Setup
-----
- Setup Ubuntu 24.04.
- `sudo apt install build-essential git cmake` to build OpenCV.
- `sudo apt install libwayland-dev wayland-protocols libxkbcommon-dev` to enable Wayland highgui-backend.
- (Option) `sudo apt install ninja-build` (or remove `-GNinja` option for cmake command).
- (Option) `sudo apt install libwayland-egl1` to enable Wayland EGL library.

Get OpenCV from GitHub
----------------------

```bash
mkdir work
cd work
git clone --depth=1 https://github.com/opencv/opencv.git
```

@note
`--depth=1` option is to limit downloading commits. If you want to see more commit history, please remove this option.

Build/Install OpenCV with Wayland highgui-backend
-------------------------------------------------

Run `cmake` with `-DWITH_WAYLAND=ON` option to configure OpenCV.

```bash
cmake -S opencv -B build4-main -DWITH_WAYLAND=ON -GNinja
```

If succeeded, Wayland Client/Cursor/Protocols and Xkbcommon versions are shown. Wayland EGL is option.

```plaintext
--
--   GUI:                           Wayland
--     Wayland:                     (Experimental) YES
--       Wayland Client:            YES (ver 1.22.0)
--       Wayland Cursor:            YES (ver 1.22.0)
--       Wayland Protocols:         YES (ver 1.34)
--       Xkbcommon:                 YES (ver 1.6.0)
--       Wayland EGL(Option):       YES (ver 18.1.0)
--     GTK+:                        NO
--     VTK support:                 NO
```

Run `cmake --build` to build, and `sudo cmake --install` to install into your system.

```bash
cmake --build build4-main
sudo cmake --install build4-main
sudo ldconfig
```

Simple Application to try Wayland highgui-backend
-------------------------------------------------
Try this code, so you can see name of currentUIFrramework() and OpenCV logo window with Wayland highgui-backend.


```bash
// g++ main.cpp -o a.out -I /usr/local/include/opencv4 -lopencv_core -lopencv_highgui -lopencv_imgcodecs
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <iostream>
#include <string>

int main(void)
{
  std::cout << "cv::currentUIFramework() returns " << cv::currentUIFramework() << std::endl;

  cv::Mat src;
  src = cv::imread("opencv-logo.png");

  cv::namedWindow("src");

  int key = 0;
  do
  {
      cv::imshow("src", src );
      key = cv::waitKey(50);
  } while( key != 'q' );
  return 0;
}
```

Limitation/Known problem
------------------------
- cv::moveWindow() is not implementated. ( See. https://github.com/opencv/opencv/issues/25478 )