v4l2ucpインストール

v4l2インターフェイスによってUVCカメラの動作パラメータを設定するツールです。
今回はガイドカメラに必要なパラメータのみを設定できるように改造します。

v4l2ucp プロジェクトサイト

必要なライブラリをインストール。
$ sudo apt-get install libv4l-0 libv4l-dev

ソースをダウンロードして展開
$ wget http://jaist.dl.sourceforge.net/project/v4l2ucp/v4l2ucp/2.0/v4l2ucp-2.0.2.tar.bz2
$ tar -xvf v4l2ucp-2.0.2.tar.bz2

ガイドカメラとして必要なパラメータのみを表示するパッチ。

v4l2ucp_filter.patch
diff -u v4l2ucp-2.0.2.org/src/mainWindow.cpp v4l2ucp-2.0.2/src/mainWindow.cpp
--- v4l2ucp-2.0.2.org/src/mainWindow.cpp        2010-01-23 23:52:12.000000000 +0900
+++ v4l2ucp-2.0.2/src/mainWindow.cpp    2015-07-06 10:19:18.176883713 +0900
@@ -144,6 +144,17 @@
     grid->setLayout(gridLayout);
     //sv->setWidget(grid);

+    QLabel *l = new QLabel((const char *)cap.driver, grid);
+    gridLayout->addWidget(l, 0, 0);
+    l = new QLabel((const char *)cap.card, grid);
+    gridLayout->addWidget(l, 0, 1);
+    l = new QLabel((const char *)cap.bus_info, grid);
+    gridLayout->addWidget(l, 0, 2);
+    str.sprintf("0x%08x", cap.capabilities);
+    l = new QLabel(str, grid);
+    gridLayout->addWidget(l, 0, 3);
+
+/*
     QLabel *l = new QLabel("driver", grid);
     gridLayout->addWidget(l, 0, 0);
     l = new QLabel((const char *)cap.driver, grid);
@@ -182,6 +193,7 @@
     gridLayout->addWidget(l);
     l = new QLabel(grid);
     gridLayout->addWidget(l);
+

     str.sprintf("0x%08x", cap.capabilities);
     l = new QLabel("capabilities", grid);
@@ -192,6 +204,7 @@
     gridLayout->addWidget(l);
     l = new QLabel(grid);
     gridLayout->addWidget(l);
+*/


     struct v4l2_queryctrl ctrl;
@@ -237,9 +250,31 @@
         v4l2_close(fd);
 }

+
+void MainWindow::query_filter(struct v4l2_queryctrl *ctrl)
+{
+    switch(ctrl->id) {
+        case V4L2_CID_BRIGHTNESS:
+        case V4L2_CID_CONTRAST:
+        case V4L2_CID_GAMMA:
+        case V4L2_CID_EXPOSURE:
+        case V4L2_CID_AUTOGAIN:
+        case V4L2_CID_GAIN:
+        case V4L2_CID_SHARPNESS:
+        case V4L2_CID_EXPOSURE_AUTO:
+        case V4L2_CID_EXPOSURE_ABSOLUTE:
+        case V4L2_CID_EXPOSURE_AUTO_PRIORITY:
+            break;
+        default:
+            ctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
+    }
+}
+
 void MainWindow::add_control(struct v4l2_queryctrl &ctrl, int fd, QWidget *parent, QGridLayout *layout)
 {
     QWidget *w = NULL;
+
+    query_filter(&ctrl);

     if(ctrl.flags & V4L2_CTRL_FLAG_DISABLED)
         return;
@@ -273,6 +308,8 @@
         return;
     }

+    layout->setHorizontalSpacing(0);
+    layout->setVerticalSpacing(0);
     layout->addWidget(w);
     if(ctrl.flags & V4L2_CTRL_FLAG_GRABBED) {
         w->setEnabled(false);
diff -u v4l2ucp-2.0.2.org/src/mainWindow.h v4l2ucp-2.0.2/src/mainWindow.h
--- v4l2ucp-2.0.2.org/src/mainWindow.h  2009-09-11 05:02:50.000000000 +0900
+++ v4l2ucp-2.0.2/src/mainWindow.h      2015-06-18 16:03:17.521252543 +0900
@@ -60,4 +60,5 @@

     MainWindow(QWidget *parent=0, const char *name=0);
     void add_control(struct v4l2_queryctrl &ctrl, int fd, QWidget *parent, QGridLayout *);
+    void query_filter(struct v4l2_queryctrl *ctrl);
 };
diff -u v4l2ucp-2.0.2.org/src/v4l2ctrl.c v4l2ucp-2.0.2/src/v4l2ctrl.c
--- v4l2ucp-2.0.2.org/src/v4l2ctrl.c    2009-11-12 04:23:24.000000000 +0900
+++ v4l2ucp-2.0.2/src/v4l2ctrl.c        2015-07-06 11:03:53.800210389 +0900
@@ -26,7 +26,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <linux/types.h>
-#include <linux/videodev.h>
+#include <linux/videodev2.h>
 #include <libv4l2.h>

 #define FORMATW "%u:%31s:%d\n"

パッチ当て
$ cd
$ patch --ignore-whitespace -p1 -d v4l2ucp-2.0.2 < v4l2ucp_filter.patch

patching file src/mainWindow.cpp
patching file src/mainWindow.h
patching file src/v4l2ctrl.c

makeする。
$ cd v4l2ucp-2.0.2
$ mkdir build
$ cd build
$ cmake ..
$ make

v4l2ucp-2.0.2/build/src/v4l2ctrl が実行ファイル
$ sudo cp src/v4l2ucp /usr/local/bin/


当方で個人的に改造したソースを放流しています。
詳しくは norikyuバージョン を参照してください。

オリジナル 基板頒布

オープンソースの架台制御ソフト、OnStepのハードウェア実装基板などの話題です。


頒布状況 2024/4/2
○ OnStep基板 Rev2.1
○ OnStep基板 Rev3.0
○ GBC-SHC 基板 Rev1.0
頒布ご希望の方はこちら、基板頒布のお知らせ をご覧ください。

このブログを検索

Blog Archive

QooQ