Getting screen size on OpenCV

后端 未结 6 2029
独厮守ぢ
独厮守ぢ 2021-02-19 09:04

How do I get the computer screen resolution on OpenCV? I need to show two images side by side using the whole screen width, OpenCV requires the exact window size I wanna create.

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-19 09:38

    This is not an answer to how to get the screen width and height, but it will let you solve your problem of displaying two images using the full screen size.

    1) Create a window like this:

    namedWindow("hello", WINDOW_NORMAL);
    

    This will allow you to set the window size yourself, you can set easily maximize it and it will take the whole screen. It will also remember the settings the next time you run the program. You can also set flags to keep the aspect ratio if you desire.

    2) If you need to get the exact number of pixels, you can get the window size using this:

    getWindowImageRect("hello");
    

    That way, you can easily combine the two images into one and display the result on screen. I'm doing it myself.

提交回复
热议问题