LeapMotionのSwipeのパラメータを調整する

LeapMotionのSDKがこっそりv1.0.8になっていますね。

Leap::SwipeGestureでもっと遅いスワイプでも検出したい!またはその逆
などをしたいときには、↓のようにすればOK。

controller.config().setFloat("Gesture.Swipe.MinLength", 200.0);
controller.config().setFloat("Gesture.Swipe.MinVelocity", 750);

デフォルトの値は150mm以上動かす、1000mm/s以上の速度で。というのが設定されているそうです。
https://developer.leapmotion.com/documentation/Languages/C++/API/class_leap_1_1_swipe_gesture.html

Homebrewで入れたOpenCVでcv::imshowとかcv::splitとかでリンクエラーが出るとき

原因はコンパイラ
わりと新しい環境で開発している人なら、Homebrewのデフォルトのコンパイラがclangになっていると思われます。

brew --env

するとわかりますね。

で、なんでかは知らないが(知っている方がいれば教えてほしいです)
clangでビルドすると、タイトルのとおり、なんか一部の関数でリンクエラーが出るんですね。
ビルドログをちゃんと見ていないのですが、なんか書いてるのかもしれません。

とりあえず。
brew install opencv --use-llvm
としけばよい。

safariが起動しない

なんか最近safariを起動しても起動時にエラーが出てて、
まぁエラーログはいっぱい出るんだけど、例えばこんなの↓
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (index >= 0) && (index < [_itemArray count])'

見ても全然わかんないので、適当にforum漁りました。

If you are using Lion 10.7.4 try the following, it worked for me:

Download and install Safari 6 from this link (it's the link used by software update to download Safari6 for Lion 10.7.4) :
http://swcdn.apple.com/content/downloads/37/23/041-5058/lr5tynbldi18zcrqo8a8uq88rnjushqliu/Safari6Lion.pkg

これ入れてsafariのバージョンを6にしたら直った。

cv::CalcOpticalFlowPyrLKでハマる

OpenCV Error: Assertion failed (mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && *1 in create, file /tmp/homebrew-opencv-2.4.2-IGYN/OpenCV-2.4.2/modules/core/src/matrix.cpp, line 1405

というエラー。
まぁどれかの型がおかしいんでしょうね、というところまではわかるんだけど。。

原因は
void calcOpticalFlowPyrLK(InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, OutputArray err, Size winSize=Size(21,21), int maxLevel=3, TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), int flags=0, double minEigThreshold=1e-4 )

のstatus
status – Output status vector. Each element of the vector is set to 1 if the flow for the corresponding features has been found. Otherwise, it is set to 0.
だけを読んで、ノリでstd::vectorにしてみたのが間違いでした。
std::vectorが正解のようです。

ドキュメント読んでもその辺はわかんないので、サンプルコード見ましょうってかんじなのかな。

*1:1 << type0) & fixedDepthMask) != 0

OSX Lionをクリーンインストール後TimeMachineで復元、homebrewの権限がおかしくなる

http://d.hatena.ne.jp/aoe-tk/20110423/1303565256
こちらに詳しく書いてある通り、homebrewは/usr/local 以下の所有者を変えるわけですが、
OSのクリーンインストール→TimeMachineで復元 後には、所有者がroot:wheelに戻ってしまいます。
なので、brew updateとかするとpermission deniedでエラー。

sudo chown -R $USER /usr/local
で直ったけど、なんか間違ってるよな、これ。