Evemtics 2021-09-01 18:23 采纳率: 0%
浏览 141
已结题

gstreamer创建管道如何使得输出分辨率自适应显示器分辨率?

gstreamer创建管道如何使得输出分辨率自适应显示器分辨率?
在nvidia jetson nano上使用csi相机时,我创建了一条gstreamer管道:

std::string gstreamer_pipeline (int capture_width, int capture_height, int display_width, int display_height, int framerate, int flip_method)
{
return "nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=(int)" + std::to_string(capture_width) + ", height=(int)" + std::to_string(capture_height) + ", format=(string)NV12, framerate=(fraction)" + std::to_string(framerate) +"/1 ! nvvidconv flip-method=" + std::to_string(flip_method) + " ! video/x-raw, width=(int)" + std::to_string(display_width) + ", height=(int)" +std::to_string(display_height) + ", format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink";
}

img
这里只能通过提前设置输出分辨率大小,或者在屏幕上的显示和输入的分辨率大小一致,请问有什么创建管道的方式使得无论在什么分辨率的显示器上都能全屏显示么?

  • 写回答

2条回答 默认 最新

  • Evemtics 2021-09-01 19:51
    关注

    操作1:从驱动读取屏幕大小
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <linux/fb.h>
    #include <sys/mman.h>
    #include <math.h>
    #include <sys/ioctl.h>
    int w,h ;
    int main(int argc , char *argv[]){
    int fd;
    struct fb_var_screeninfo fb_var;
    fd = open("/dev/fb0",O_RDWR);
    ioctl (fd,FBIOGET_VSCREENINFO,&fb_var);
    w = fb_var.xres;
    h = fb_var.yres;
    return 0;
    }

    操作2:通过xcb库读取屏幕大小
    #include <stdio.h>
    #include <xcb/xcb.h>
    int main (){
    /* Open the connection to the X server. Use the DISPLAY environment variable */
    int i, screenNum;
    xcb_connection_t connection = xcb_connect (NULL, &screenNum);
    /
    Get the screen whose number is screenNum */
    const xcb_setup_t *setup = xcb_get_setup (connection);
    xcb_screen_iterator_t iter = xcb_setup_roots_iterator (setup);
    // we want the screen at index screenNum of the iterator
    for (i = 0; i < screenNum; ++i) {
    xcb_screen_next (&iter);
    }
    xcb_screen_t *screen = iter.data;
    /* report */
    printf ("\n");
    printf ("Informations of screen %ld:\n", screen->root);
    printf (" width.........: %d\n", screen->width_in_pixels);
    printf (" height........: %d\n", screen->height_in_pixels);
    printf (" white pixel...: %ld\n", screen->white_pixel);
    printf (" black pixel...: %ld\n", screen->black_pixel);
    printf ("\n");
    return 0;
    }

    参考链接: Ubuntu Linux下通过c++获取屏幕大小_weixin_33755554的博客-CSDN博客 为什么80%的码农都做不了架构师?>>> ... https://blog.csdn.net/weixin_33755554/article/details/91741622

    评论

报告相同问题?

问题事件

  • 系统已结题 9月9日
  • 赞助了问题酬金 9月1日
  • 创建了问题 9月1日

悬赏问题

  • ¥15 阿里云函数计算自定义层部署LibreOffice
  • ¥15 打开软件提示错误:failed to get wglChoosePixelFormatARB
  • ¥30 电脑误删了手机的照片怎么恢复?
  • ¥15 (标签-python|关键词-char)
  • ¥15 python+selenium,在新增时弹出了一个输入框
  • ¥15 苹果验机结果的api接口哪里有??单次调用1毛钱及以下。
  • ¥20 学生成绩管理系统设计
  • ¥15 来一个cc穿盾脚本开发者
  • ¥15 CST2023安装报错
  • ¥15 使用diffusionbert生成文字 结果是PAD和UNK怎么办