update: 2016/08/08
reference:
1. PiMapper
2. Raspberry Pi: Pi 2 with Pi Mapper ---- 1/3
3. Raspberry Pi: Pi 2 with Pi Mapper ---- 2/3
C. 安裝 Pi Mapper
1. 下載軟體:
$ cd ~/of_v0.8.4_linuxarmv7l_release/addons/
$ git clone https://github.com/kr15h/ofxPiMapper.git
2. 安裝相依軟體:
$ cd ~/of_v0.8.4_linuxarmv7l_release/addons/
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git && git clone https://github.com/bakercp/ofxIO.git (約 10 分鐘)
3. (選擇性) 讓鍵盤與滑鼠運作正常:
$ sudo apt-get update && sudo apt-get dist-upgrade
$ sudo rpi-update // Raspberry Pi firmware update (約 10 分)
// A reboot is needed to activate the new firmware
$ sudo reboot // 重新開機
4. 編譯 Pi Mapper:
$ cd ~/of_v0.8.4_linuxarmv7l_release/addons/ofxPiMapper/example
$ make (約 15 分)
$ make run // 執行 (或: ./bin/example)
模式:(按下鍵盤的數字鍵)
1. Presentation mode (展示模式, 預設)
2. Texture mapping mode (紋理對應模式)
3. Projection mapping mode (投影對應模式)
4. Source selection mode (來源選擇模式)
說明: 一般的步驟為:
-> 先切換到模式3來選擇投影的形狀.
-> 隨後, 便可以在模式4選擇來源並於模式2編輯紋理.
快捷鍵:
鍵名 功能
i Show info
t Add triangle surface
q Add quad surface
f Toggle fullscreen
s Save composition
BACKSPACE Delete surface
Z Undo command operation
6. 備註:
create a symbolic link:
ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]
$ cd /home/pi
$ ln -s /home/pi/of_v0.8.4_linuxarmv7l_release/addons/ofxPiMapper ./PiMapper
a. 預設外觀設定檔:
/home/pi/PiMapper/example/bin/data/defaultSurfaces.xml
b. 使用者外觀設定檔:(save 後, 會自動產生)
/home/pi/PiMapper/example/bin/data/surfaces.xml
c. 圖片來源檔位置: (支援: .png .jpg .jpeg)
/home/pi/PiMapper/example/bin/data/sources/images/
image1.jpg, image2.jpg, image3.jpg ....
圖片格式 => 建議: 600 x 600 JPG(JPEG) 或 PNG 檔
d. 影片來源檔位置: (支援: .mp4 .h264 .mov .avi .mpeg)
/home/pi/PiMapper/example/bin/data/sources/videos/
test.mov ....
影片格式 => 建議: 1280 x 720 24fps 規格以下的 MP4, H264, MOV, AVI, MPEG 檔
備註: 圖片與影片定義來源:
/home/pi/PiMapper/src/MediaServer/DirectoryWatcher.h
e. ShowInfo:
/home/pi/PiMapper/src/ofxPiMapper.cpp (修改後, 需重新編譯)
....
void ofxPiMapper::draw(){
....
if (bShowInfo){
// Draw instructions
.....
ss << "Press <f> to toggle fullscreen\n";
ss << "Press <i> to hide this message\n";
ss << "Press <z> to undo command operation";
....
}
} // draw
....
f. 投影視窗大小:
/home/pi/PiMapper/example/src/main.cpp (修改後, 需重新編譯)
....
#ifdef TARGET_RASPBERRY_PI
// Accept arguments in the Pi version
int main(int argc, char* argv[]) {
cout << ">>>>>> Starting PiMapper on RASPBERRY_PI \n" << endl;
//bool fullscreen = false;
bool fullscreen = true; // 全螢幕
....
if (fullscreen) {
//ofSetupOpenGL(600, 500, OF_FULLSCREEN); // default
ofSetupOpenGL(600, 500, OF_FULLSCREEN);
} else {
//ofSetupOpenGL(800, 450, OF_WINDOW); // default
ofSetupOpenGL(800, 450, OF_WINDOW);
}
....
}
#else
int main() {
cout << ">>>>>> Starting PiMapper on Mac/PC \n" << endl;
//ofSetupOpenGL(800, 600, OF_WINDOW); // default
ofSetupOpenGL(800, 600, OF_WINDOW);
ofRunApp(new ofApp());
}
#endif
g. 讓 HDMI 影片的聲音正常播放:(修改以下二項設定後, 重新開機並編譯)
(1). $ sudo nano /boot/config.txt
....
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2
....
(2). $ sudo nano /home/pi/PiMapper/src/Sources/VideoSource.cpp
....
//bool VideoSource::enableAudio = false;
bool VideoSource::enableAudio = true;
/*
#ifdef TARGET_RASPBERRY_PI
// Do things with the OMX player
....
//settings.enableAudio = false; //default true, save resources by disabling
settings.enableAudio = true; //default true, save resources by disabling
....
*/
(3). $ sudo nano /home/pi/PiMapper/example/src/ofApp.cpp
.... //ofx::piMapper::VideoSource::enableAudio = false;
ofx::piMapper::VideoSource::enableAudio = true;
$ sudo reboot
7. 開機後直動登入執行 Pi Mapper:
a. 開機後自動登入: (需按 Esc 離開程式, 遠端才能登入)
$ sudo nano /etc/inittab
....
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
....
ctrl + o: write (enter)
ctrl + x: exit
b. 登入後自動執行 PiMapper 程式: (遠端登入不會再執行一次)
$ sudo nano ~/.bashrc
....
# auto run openFrameworks on start up but not SSH sign in
echo "tty = $(tty)"
if [ $(tty) == "/dev/tty1" ]; then
echo "We have a match."
cd ~/PiMapper/example
./bin/example
else
echo "We dont match."
fi
ctrl + o: write (enter)
ctrl + x: exit
8. 調整幾何圖形拖拉點的顏色與筆觸粗細:
/home/pi/PiMapper/src/UserInterface/BaseJoint.cpp
....
void BaseJoint::setDefaultColors() {
fillColor = ofColor(0, 255, 255, 0);
//strokeColor = ofColor(255, 255, 255);
strokeColor = ofColor(0, 0, 255); // 藍色拖拉點
fillColorSelected = ofColor(255, 255, 0, 0);
strokeColorSelected = ofColor(255, 0, 0);
}
void BaseJoint::setDefaultProperties() {
enabled = true;
visible = true;
position = ofVec2f(20.0f, 20.0f);
clickDistance = ofVec2f(0.0f, 0.0f);
bDrag = false;
selected = false;
//strokeWidth = 1.5f;
strokeWidth = 5.5f; // 拖拉點筆觸粗細
}
9. 調整 Pi 本機登入 Command line 的字型大小:
a. 進入 console setup:
$ sudo dpkg-reconfigure console-setup
b. 選擇 UTF-8 > Enter
f. 重新開機
$ sudo shutdown -h now
(或重啟 sonsole: $ sudo /etc/init.d/console-setup restart)