Luc*_*ijo 13 opencv resolution screen
如何在OpenCV上获得计算机屏幕分辨率?我需要使用整个屏幕宽度并排显示两个图像,OpenCV需要我想要创建的确切窗口大小.
您可以在有或没有opencv的情况下使用此解决方案跨平台解决方案:
#if WIN32
#include <windows.h>
#else
#include <X11/Xlib.h>
#endif
//...
void getScreenResolution(int &width, int &height) {
#if WIN32
width = (int) GetSystemMetrics(SM_CXSCREEN);
height = (int) GetSystemMetrics(SM_CYSCREEN);
#else
Display* disp = XOpenDisplay(NULL);
Screen* scrn = DefaultScreenOfDisplay(disp);
width = scrn->width;
height = scrn->height;
#endif
}
int main() {
int width, height;
getScreenResolution(width, height);
printf("Screen resolution: %dx%d\n", width, height);
}
Run Code Online (Sandbox Code Playgroud)
在Linux中,试试这个
#include <stdio.h>
int main()
{
char *command="xrandr | grep '*'";
FILE *fpipe = (FILE*)popen(command,"r");
char line[256];
while ( fgets( line, sizeof(line), fpipe))
{
printf("%s", line);
}
pclose(fpipe);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在Windows中
http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/
小智 5
使用 opencv 代替操作系统函数:
cv.namedWindow("dst", cv.WND_PROP_FULLSCREEN)
cv.setWindowProperty("dst",cv.WND_PROP_FULLSCREEN,cv.WINDOW_FULLSCREEN)
(a,b,screenWidth,screenHeight) = cv.getWindowImageRect('dst')
Run Code Online (Sandbox Code Playgroud)
所以我在全屏模式下创建一个窗口并询问其宽度和高度
它应该适用于任何操作系统,但它仅适用于 Windows。在 Linux 下,窗口不是全屏的。
归档时间: |
|
查看次数: |
9804 次 |
最近记录: |