]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/dual-camera-demo.git/commitdiff
Camera images now scale to all display resolutions
authorJosh Elliott <jelliott@ti.com>
Mon, 21 Apr 2014 13:01:17 +0000 (08:01 -0500)
committerJosh Elliott <jelliott@ti.com>
Mon, 21 Apr 2014 13:01:17 +0000 (08:01 -0500)
loopback.cpp
loopback.h
mainwindow.cpp

index 057271c41b38f5f3295b1cb6d1912926629c84cf..09dee7312e5820e9ea0f771f83cdfb24c6e97162 100644 (file)
@@ -286,16 +286,17 @@ static int fbdev_init_device(struct fbdev_device_info *device)
     printf("%s di resolution: %dx%d\n",device->name,
            device->di.xres, device->di.yres);
 
-    /* Make sure camera display overlay isnt bigger than actual screen size */
-    if (device->di.xres >= 800) {
-        /* Set the input resolution of framebuffer */
-        device->varinfo.xres = 800;
-        device->varinfo.yres = 480;
-    }
-
-    /* Keep the virtual resolution the same as camera image */
+    /* Store display resolution so GUI can be configured */
+    status.display_xres = device->di.xres;
+    status.display_yres = device->di.yres;
+
+    /* Set the input resolution of the video framebuffer to be the size
+     * of the camera image.  Later, the output size will be matched to
+     * the display to allow for up/down scaling */
+    device->varinfo.xres = 800;
+    device->varinfo.yres = 600;
     device->varinfo.xres_virtual = 800;
-    device->varinfo.yres_virtual = 480;
+    device->varinfo.yres_virtual = 600;
 
     device->varinfo.bits_per_pixel = 16;
     device->varinfo.nonstd = OMAPFB_COLOR_YUY422;
@@ -320,13 +321,11 @@ static int fbdev_init_device(struct fbdev_device_info *device)
 
     device->pi.pos_x = 0;
     device->pi.pos_y = 0;
-    /* Set the the display plane output size.  This allows for up/down scaling via DSS */
-    if (device->varinfo.xres >= 800) {
-        /* If the display width > 800, keep display at 800 */
-        device->pi.out_width = 800;
-        device->pi.out_height = 480;
-    }
-
+    /* Set the the display plane output size to the detected resolution
+     * of the lcd/monitor.  This will cause the 800x600 camera image to
+     * be up/downscaled to fit the screen */
+    device->pi.out_width = device->di.xres;
+    device->pi.out_height = device->di.yres;
     device->pi.enabled = 1;
 
     if (ioctl(device->fd, OMAPFB_SETUP_PLANE, &device->pi)) {
@@ -478,13 +477,14 @@ static int display_frame(struct v4l2_device_info *v4l2_device, struct fbdev_devi
         return -1;
     }
 
+    /* Wait for VSYNC */
+    ioctl(fbdev_device->fd, OMAPFB_WAITFORGO);
+
     /* Copy the contents of the v4l2 capture buffer to framebuffer */
     memcpy(fbdev_device->buf_start,
     v4l2_device->buffers[v4l2_device->buf.index].start,
     fb_size);
 
-    ioctl(fbdev_device->fd, OMAPFB_WAITFORGO);
-
     /* Queue buffer for the v4l2 capture device */
     ret = ioctl(v4l2_device->fd, VIDIOC_QBUF,
             &v4l2_device->buf);
index d47a4ed9346049e15d425b0a98c85865fe873331..3d6dbea836c465d984c200e82e08f20ce157f895 100644 (file)
@@ -5,6 +5,7 @@ struct control {
     int main_cam;
     int num_cams;
     int num_jpeg;
+    int display_xres, display_yres;
     bool pip;
     bool jpeg;
     bool exit;
index d72d788dfd7100400385b5116724d41d81116084..92e8646f86c61ac64e5ef61ad21e2c1c377f16b7 100644 (file)
@@ -26,15 +26,37 @@ MainWindow::MainWindow(QWidget *parent) :
     if(init_loopback() < 0) {
         /* TODO: make sure exit occurs properly */
     }
-    else if(status.num_cams == 1) {
+
+    /* Configure GUI */
+    this->setFixedSize(status.display_xres, status.display_yres);
+    ui->frame->setGeometry(0, 0, status.display_xres, status.display_yres);
+    ui->frame_pip->setGeometry(0, 0, status.display_xres/2, status.display_yres/2);
+    ui->capture->setGeometry(status.display_xres/2 - 210,
+                             status.display_yres - 50,
+                             91, 41);
+    ui->switch_2->setGeometry(status.display_xres/2 - 100,
+                              status.display_yres - 50,
+                              91, 41);
+    ui->pip->setGeometry(status.display_xres/2 + 10,
+                         status.display_yres - 50,
+                         91, 41);
+    ui->exit->setGeometry(status.display_xres/2 + 120,
+                          status.display_yres - 50,
+                          91, 41);
+
+    if(status.num_cams == 1) {
         /* Reconfigure GUI to reflect single camera mode */
         ui->pip->setHidden(true);
         ui->pip->setDisabled(true);
         ui->switch_2->setHidden(true);
         ui->switch_2->setDisabled(true);
         ui->frame_pip->setHidden(true);
-        ui->capture->setGeometry(300,430,91,41);
-        ui->exit->setGeometry(410,430,91,41);
+        ui->capture->setGeometry(status.display_xres/2 - 100,
+                                 status.display_yres - 50,
+                                 91, 41);
+        ui->exit->setGeometry(status.display_xres/2 + 10,
+                              status.display_yres - 50,
+                              91, 41);
     }
 
     /* Start the camera loopback thread */