Skip to content

highgui: wayland: imshow() doesn't create window automatically if no namedWindow() #25497

@Kumataro

Description

@Kumataro

System Information

OpenCV version: 4.x branch ( 2cd3304 )
Operating System / Platform: Ubuntu 24.04
Compiler & compiler version: GCC 13.2

Detailed description

We can use imshow() with window which is not created by namedWindow().

https://docs.opencv.org/4.x/d7/dfc/group__highgui.html#ga453d42fe4cb60e5723281a89973ee563

If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE.

It works well with GTK3 highgui-backed.
However it doesn't work well with Wayland highgui-backend.

Steps to reproduce

opencv-log.png is copied from opencv/docs folder.

// 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;
}

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions