LoginSignup
7
2

More than 1 year has passed since last update.

OpenCVのオプション変更、ssh接続する人はccmakeもいいかも!

Posted at

この記事はOpenCV Advent Calendar 2021の1日目の記事です。
他の記事は目次にまとめられています。

今日は大晦日ですが、気にせず参りましょう!

■ はじめに(モチベーション)

◯linux desktop上で行われる普通のOpenCVオプション変更

OpenCVをcmakeでコンパイルするときに、cmakeのオプション変更はどうやっているだろうか?コマンドラインごりごりはともかく… 普通のやり方だとこんな感じではないだろうか?

desktop
$ cmake -S opencv-4.5.5/ -B build
$ cd build
$ cmake-gui .
$ make -j8
$ sudo make install -j8
$ sudo ldconfig

これが全部linux desktop上ならばまあ普通の作業だ。qt baseの設定画面が表示される。

image.png

◯ssh termianl上で行われる普通のOpenCVオプション変更(めんどい)

しかし、ssh接続で作業をしたい人からすると、途中でGUI/X上でcmake-guiを動かす必要があり、とたんに切り替え作業が発生する。 思考が分断されるうう

ssh
$ cmake -S opencv-4.5.5 -B build
desktop
$ cd <sshで作業していたフォルダ>
$ cd build
$ cmake-gui . 
<GUI上でConfigurationを設定>
ssh
$ make -j8
$ sudo make install -j8
$ sudo ldconfig

ましてや、全てのlinuxにGUIがあるとは限らない のです。この設定変更のためだけに、X11やらなにやらをインストール?無駄ですよね……

ましてや、他でcmake-guiを実行してコピーしてくるとか、トリッキーなこともしたくない…… 困ったもんだ。

◯SSH terminal上で、OpenCVの設定をWYSIWYGで変更したい!

WYSIWYGって、今日日聞かないな‥What You See Is What You Get, 、見たままのものが取得できる、ってことです.

そこで今回は、tui版cmake-guiともいえる、cmake-curses-guiを紹介したい。あ、tuiとはterminal user interfaceだと思います。

helpを見ると、Welcome to ccmake, curses based user interface for CMake. とのこと。

■ ubuntu21.10での導入方法

いつも通り、ubuntuだったらaptで導入できる。簡単、ヤッター!

sudo apt install cmake-curses-gui

■ ccmakeを使ってみる

こんな感じで、全部terminalで完結できる、素敵!

ssh
$ cmake -S opencv-4.5.5/ -B build
$ ccmake build
$ make -j 8
$ sudo make install -j8
$ sudo ldconfig

image.png

◯ ポイント

どうやら、現状の設定を保存だけする機能は無いっぽい。

[c] Configure[g] Generate の順番に実行。

ここで、configureをやらないとGenerateが生えてこないので要注意。

以下、ccmakeのヘルプより引用

 Commands:
  q : quit ccmake without generating build files
  h : help, shows this screen
  c : process the configuration files with the current options
  g : generate build files and exit, only available when there are no new options and no errors have been detected during last configuration.
  l : shows cmake output
  d : delete an option
  t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using
 normal mode unless you are an expert.
  / : search for a variable name.

■ まとめ

ssh接続で使っているユーザーの皆さんは、cmake-gui の代わりに、ccmakeを使うと、ちょっとだけ幸せになれるかもしれません(ごりごり make Optionでどうこうする派でなければ)

以上になります。

7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2