[Mac] OpenCV + Python

openCV 2.x + Python 2.x on MacOS

brew 安裝 python

$ brew install python

安裝 cmake

$ brew install cmake

安裝 openCV 2.x

$ brew install homebrew/science/opencv

會有警告訊息

Warning: opencv dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.

不理他 可以用

安裝 numpy

$ pip install numpy

安裝完 /Library/Caches/Homebrew/opencv-2.4.11.tar.gz 有範例

$ mkdir dev
$ cd dev
$ tar xvfz /Library/Caches/Homebrew/opencv-2.4.11.tar.gz
$ cd opencv-2.4.11/sample/python2
$ python demo.py

如果用人臉辨識 特徵在 data/haarcascades

portmaster re-install 問題

The following actions will be taken if you choose to proceed:
Re-install db48-4.8.30.0_2
Re-install ruby20-2.0.0.645,1


portmaster -av|grep moved 1 ↵
===>>> The databases/db42 port moved to databases/db48
===>>> The databases/db42 port moved to databases/db48
===>>> The lang/ruby19 port moved to lang/ruby20
===>>> The lang/ruby19 port moved to lang/ruby20

portmaster -o databases/db48 databases/db42
portmaster -o lang/ruby20 lang/ruby19

sftp chroot

/etc/ssh/sshd_config

#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem   sftp    internal-sftp

Match User user1, user2
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

然後 vipw 把 user1, user2 的 shell 改為 /bin/false
再把該使用者家目錄設為 root 擁有

chown root:root /home/user1
chown root:root /home/user2

最後重啟 sshd

製作 OSX Yosemite DVD iso image

筆記一下

hdiutil attach /Applications/Install\ OS\ X\ Yosemite.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Yosemite
hdiutil resize -size 8g /tmp/Yosemite.sparseimage
hdiutil attach /tmp/Yosemite.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build
rm /Volumes/install_build/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build
hdiutil detach /Volumes/install_app
hdiutil detach /Volumes/install_build
hdiutil resize -size `hdiutil resize -limits /tmp/Yosemite.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/Yosemite.sparseimage
hdiutil convert /tmp/Yosemite.sparseimage -format UDTO -o /tmp/Yosemite
rm /tmp/Yosemite.sparseimage
mv /tmp/Yosemite.cdr ~/Desktop/Yosemite.iso

不用再按 reload 了: LiveReload

每次網頁改來改去要一直按 reload 真的很麻煩
還是來裝一下 LiveReload 好了

瀏覽器安裝外掛

依照瀏覽器安裝 LiveReload 外掛
不要去瀏覽器官網列表裝 可能會是舊版的

Sublime Text3

到 Package 資料夾使用 git 安裝

OSX

cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
rm -rf LiveReload
git clone -b devel https://github.com/dz0ny/LiveReload-sublimetext2.git LiveReload

Windows

須先安裝 git (不然自己下載檔案 放進 package 也是可以)

執行 cmd

cd "C:\Users\使用者\AppData\Roaming\Sublime Text 3\Packages"
rd /s /q LiveReload
git clone -b devel https://github.com/dz0ny/LiveReload-sublimetext2.git LiveReload

啟動

如果裝完之後不會連動
打開 sublime
cmd(ctrl)+shift+p
LiveReload: Enable/disable plugins
Enable – SimpleReload
應該就可以做動了

參考資料
http://livereload.com/extensions/
https://github.com/dz0ny/LiveReload-sublimetext2
https://github.com/dz0ny/LiveReload-sublimetext2/issues/78