Skip to content

Commit 1906a37

Browse files
authored
doc cv::imshow supports Linux framebuffer and Windows (nihui#155)
1 parent d9989ed commit 1906a37

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
:heavy_check_mark: ***NEW FEATURE*** [`cv::putText` supports full-width CJK characters](#cvputtext-supports-full-width-cjk-characters)
2828

29+
:heavy_check_mark: ***NEW FEATURE*** [`cv::imshow` supports Linux framebuffer and Windows](#cvimshow-supports-linux-framebuffer-and-windows)
30+
2931
|opencv 4.10.0 package size|The official opencv|opencv-mobile|
3032
|:-:|:-:|:-:|
3133
|source zip|95.2 MB|8.25 MB|
@@ -542,6 +544,60 @@ int main()
542544
}
543545
```
544546

547+
## `cv::imshow` supports Linux framebuffer and Windows
548+
549+
In Linux, `cv::imshow` can display images on the screen (`/dev/fb0`) via the [Linux Framebuffer API](https://www.kernel.org/doc/html/latest/fb/api.html). `cv::imshow` can work without desktop environment (gnome, KDE Plasma, xfce, etc.) or window manager (X or wayland), making it suitable for embedded scenarios. The first argument to `cv::imshow` must be **`fb`**.
550+
551+
In Windows, `cv::imshow` will use the Windows API to create a simple window for displaying.
552+
553+
<table>
554+
<tr><td>
555+
556+
display image
557+
558+
```cpp
559+
#include <opencv2/core/core.hpp>
560+
#include <opencv2/highgui/highgui.hpp>
561+
562+
int main()
563+
{
564+
cv::Mat bgr = cv::imread("im.jpg", 1);
565+
566+
cv::imshow("fb", bgr);
567+
568+
return 0;
569+
}
570+
```
571+
572+
</td><td>
573+
574+
realtime camera preview
575+
576+
```cpp
577+
#include <opencv2/core/core.hpp>
578+
#include <opencv2/highgui/highgui.hpp>
579+
580+
int main()
581+
{
582+
cv::VideoCapture cap;
583+
cap.set(cv::CAP_PROP_FRAME_WIDTH, 320);
584+
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 240);
585+
cap.open(0);
586+
587+
cv::Mat bgr;
588+
while (1)
589+
{
590+
cap >> bgr;
591+
cv::imshow("fb", bgr);
592+
}
593+
594+
return 0;
595+
}
596+
```
597+
598+
</td></tr>
599+
</table>
600+
545601
# opencv modules included
546602

547603
|module|comment|

0 commit comments

Comments
 (0)