tag:blogger.com,1999:blog-13296015817679922992024-03-19T12:10:16.585+08:00kcwukcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-1329601581767992299.post-31290880213382081312022-10-13T20:58:00.004+08:002022-10-13T20:58:49.009+08:00Insta360 X3 battery test<h1 style="text-align: left;"><p>Test conditions</p></h1>
<div style="text-align: left;"><span><span style="font-size: small;"><b>Battery</b>: X3 battery 1800mAh (model CINAQBT/A)</span></span></div><div style="text-align: left;"><span><span style="font-size: small;"><b>Fast Charge Hub</b>: model CINSAAQ/A (12V/3A input is recommended)<br /></span></span><span style="font-size: small;"><b>Power bank</b>: </span>NITECORE NB10000 (not gen 2), Type-C output (max 9V/2A or 12V/1.5A)</div><div style="text-align: left;"><b>Power adapter</b>: Innergie 60C Pro USB-C (which supports 15V/3A and more)</div><div style="text-align: left;"><b>Room temperature</b>: 28°C</div><div style="text-align: left;"><br /></div>
<h1 style="text-align: left;"><div style="text-align: left;">Charge 1 battery via power bank</div></h1>
<tb></tb><table border="1">
<tbody><tr><th>time (min)</th>
<th>0</th>
<th>32</th>
<th>75</th>
</tr><tr>
<td>NB10000</td>
<td>100%</td>
<td></td>
<td>(>70%)</td>
</tr>
<tr>
<td>Battery</td>
<td>0%</td>
<td>80%</td>
<td>100%</td>
</tr>
</tbody></table>
<div style="text-align: left;"><span style="font-size: medium; font-weight: 400;">NB10000</span></div><ul style="font-weight: 400; text-align: left;"><li><span style="font-size: small;">Initially, 3 LED indicator (full)</span></li><li>Still 3 LED indicator when charging finished</li></ul><span style="font-weight: normal;"><span style="font-size: small;">Battery</span></span>
<ul style="text-align: left;"><li>Initially, LED was flashing yellow (<80%)</li><li>LED became flashing green (>80%) after 32 minutes</li><li>LED became solid green (full) after 75 minutes</li></ul><div><br /></div>
<h1 style="text-align: left;"><div style="text-align: left;">Charge 2 batteries via power bank</div></h1>
<tb></tb><table border="1">
<tbody><tr><th>time (min)</th>
<th>0</th>
<th>20</th>
<th>46</th>
<th>87</th>
<th>93</th>
<th>137</th>
</tr><tr>
<td>NB10000</td>
<td>100%</td>
<td>70%</td>
<td></td>
<td></td>
<td></td>
<td>(>30%)</td>
</tr>
<tr>
<td>Battery A</td>
<td>0%</td>
<td></td>
<td>80%</td>
<td>100%</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery B</td>
<td>0%</td>
<td></td>
<td></td>
<td></td>
<td>80%</td>
<td>100%</td>
</tr>
</tbody></table>
<p>NB10000</p><p></p><ul style="text-align: left;"><li>Initially, 3 LED indicator (full)</li><li>LED indicator became 2 (between 30% and 70%) after 20 minutes</li><li>Still 2 LED indicator when charging finished</li></ul><div>Battery A</div><ul style="text-align: left;"><li>Initially, LED was flashing yellow (<80%)</li><li>LED became flashing green (>80%) after 46 minutes</li><li>LED became solid green (full) after 87 minutes</li></ul><div>Battery B</div><div></div><p></p><div><ul style="text-align: left;"><li>Initially, LED was flashing yellow (<80%)</li><li>LED became flashing green (>80%) after 93 minutes</li><li>LED became solid green (full) after 137 minutes</li></ul><div><br /></div></div>
<h1 style="text-align: left;"><div style="text-align: left;">Charge 3 batteries via power bank</div></h1>
<tb></tb><table border="1">
<tbody><tr><th>time (min)</th>
<th>0</th>
<th>18</th>
<th>31</th>
<th>75</th>
<th>99</th>
<th>144</th>
<th>164</th>
<th>210</th>
</tr><tr>
<td>NB10000</td>
<td>100%</td>
<td>70%</td>
<td></td>
<td></td>
<td></td>
<td>30%</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery A</td>
<td>0%</td>
<td></td>
<td>80%</td>
<td>100%</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery B</td>
<td>0%</td>
<td></td>
<td></td>
<td></td>
<td>80%</td>
<td>100%</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery C</td>
<td>idle</td>
<td></td>
<td></td>
<td>0%</td>
<td></td>
<td></td>
<td>80%</td>
<td>100%</td>
</tr>
</tbody></table>
<p>NB10000</p><p></p><ul><li>Initially, 3 LED indicator (full)</li><li>LED indicator became 2 (between 30% and 70%) after 18 minutes</li><li>LED indicator became 1 (<30%) after 144 minutes</li><li>Still 1 LED indicator when charging finished</li></ul><div>Battery A</div><ul><li>Initially, LED was flashing yellow (<80%)</li><li>LED became flashing green (>80%) after 31 minutes</li><li>LED became solid green (full) after 75 minutes</li></ul><div>Battery B</div><div></div><p></p><div><ul><li>Initially, LED was flashing yellow (<80%)</li><li>LED became flashing green (>80%) after 99 minutes</li><li>LED became solid green (full) after 144 minutes</li></ul></div><div>Battery C</div><div></div><p></p><div><ul><li>Initially, LED was solid yellow (idle)</li><li>LED became flashing yellow (<80%) after 75 minutes</li><li>LED became flashing green (>80%) after 164 minutes</li><li>LED became solid green (full) after 210 minutes</li></ul></div><p><br /></p>
<h1 style="text-align: left;"><div style="text-align: left;">Charge batteries one by one via power bank</div></h1>
<tb></tb><table border="1">
<tbody><tr><th>time (min)</th>
<th>0</th>
<th>24</th>
<th>33</th>
<th>74</th>
<th>108</th>
<th>149</th>
<th>182</th>
<th>224</th>
<th>239</th>
<th>250</th>
</tr><tr>
<td>NB10000</td>
<td>100%</td>
<td>70%</td>
<td></td>
<td></td>
<td></td> <td></td>
<td></td>
<td></td>
<td>30%</td>
<td>0%</td>
</tr>
<tr>
<td>Battery A</td>
<td>0%</td>
<td></td>
<td>80%</td>
<td>100%</td>
<td></td>
<td></td> <td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery B</td>
<td></td>
<td></td>
<td></td>
<td>0%</td>
<td>80%</td>
<td>100%</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery C</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0%</td>
<td>80%</td>
<td>100%</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Battery D</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>0%</td>
<td></td>
<td></td>
</tr>
</tbody></table>
<div>p.s. After battery LED solid green, the LED would last for 30 seconds. I unplugged the batteries after that.</div>
<h1 style="text-align: left;"><div style="text-align: left;">Charge 1 battery via power adapter</div></h1>
<tb></tb><table border="1">
<tbody><tr><th>time (min)</th>
<th>0</th>
<th>32</th>
<th>74</th>
</tr>
<tr>
<td>Battery</td>
<td>0%</td>
<td>80%</td>
<td>100%</td>
</tr>
</tbody></table>
<ul style="text-align: left;"><li>Charge hub is connected to Innergie 60C Pro</li><li>Initially, LED was flashing yellow (<80%)</li><li>LED became flashing green (>80%) after 32 minutes</li><li>LED became solid green (full) after 74 minutes</li></ul><div><br /></div>
<h1 style="text-align: left;"><div style="text-align: left;">Charge 3 batteries via power adapter</div></h1>
<h4 style="text-align: left;">TODO</h4><p><br /></p>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-13664054276224544332017-06-30T01:35:00.000+08:002017-06-30T01:35:10.215+08:00GnuCash 台幣小數位數雖然 <a href="http://zh.wikipedia.org/wiki/%E6%96%B0%E8%87%BA%E5%B9%A3">新台幣</a> 最小單位是 0.01,以前也有 5 角的硬幣,但現在並不通行,在 GnuCash 中看到所有的數字都多寫「<b>.00</b>」實在很煩(小聲說,其實看久就習慣了),本文說明如何讓那「.00」不見,畫面更清爽。<br />
<h2>
基本設定</h2>
各個科目顯示幾位小數是可以改的,在「編輯科目」的「最小單位」,把「Use Commodity Value」改成「1」就可以了。每個科目都要一一修改。<br />
但還是有滿多地方會出現「.00」,譬如<br />
<br />
<ul>
<li>各交易的金額雖然寫整數,但 cursor 移上去要修改時,還是會出現兩位小數</li>
<li>科目樹有些欄位還是會有兩位小數</li>
<li>報表</li>
</ul>
<br />
以下說明如何消除那些「.00」<br />
<h2>
1. TWD 的定義</h2>
所有貨幣的定義都在 src/engine/iso-4217-currencies.scm 這個檔案,譬如 TWD 的定義是<br />
( "New Taiwan Dollar" "dollar" "cent" "ISO4217" "TWD" "901" 100 100 "NT$" )<br />
<br />
<div>
在編譯的過程中,iso-4217-currencies.scm 會產生 iso-4217-currencies.c 的下面幾行</div>
<div>
<div>
const char *fullname = "New Taiwan Dollar";</div>
<div>
gnc_commodity *c = gnc_commodity_new(book,</div>
<div>
CUR_I18N(fullname),</div>
<div>
"ISO4217",</div>
<div>
"TWD",</div>
<div>
"901",</div>
<div>
100);</div>
</div>
<div>
這個檔案是 libgncmod-engine 的一部份,也就是說,TWD 的定義最終是寫死在程式執行檔裡,不是在設定檔中。<br />
<h3>
修改方法</h3>
<div>
如果是從 source code 開始 build GnuCash, 修改方法很簡單,只要把 iso-4217-currencies.scm 裡</div>
( "New Taiwan Dollar" "dollar" "cent" "ISO4217" "TWD" "901" 100 100 "NT$" )<br />
<div>
那行改成</div>
<div>
( "New Taiwan Dollar" "dollar" "cent" "ISO4217" "TWD" "901" 1 1 "NT$" )</div>
<div>
再重 build 就好了。</div>
<div>
<br /></div>
<div>
或是把 iso-4217-currencies.c 那個 100 改成 1 也可以。<br />
<br />
如果是直接安裝執行檔,就比較麻煩了(譬如在 Windows)。我目前的解法是用 OllyDbg 開 libgncmod-engine.dll,找 reference 到 TWD 字串的程式碼位置前兩個 instruction<br />
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgico2zFwilsvDhmVR9c6uL0SqmjynSu3P79MfS2uCLEx5t8vafPtIe8JgzDciathkTR2A0y79HEFALtVGdV8W-ocMB1O-UkDy47l0ZRqcUdwpfKIe-TP9bBNx0e_ZZk5v5XXvJp-WQuuU/s1600/gnucash-2.6.0-dbg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgico2zFwilsvDhmVR9c6uL0SqmjynSu3P79MfS2uCLEx5t8vafPtIe8JgzDciathkTR2A0y79HEFALtVGdV8W-ocMB1O-UkDy47l0ZRqcUdwpfKIe-TP9bBNx0e_ZZk5v5XXvJp-WQuuU/s1600/gnucash-2.6.0-dbg.png" /></a></div>
把 64 (十六進位,就是 100)改成 01。</div>
</div>
<h2>
2. 帳本存檔</h2>
<div>
程式改完把 GnuCash 開起來,會發現每筆交易的數字都正常了。但是科目樹有的欄位還是錯的,像是</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVnDUKBuwRoA4XS484jNZNLkYxElXfV0jSgLS3B_32HT-VcGXKo6BVXPRyMawVe6N2quD_Gw1SbS-oGyOPP7qDpJsPax91hPFwnkKrrBSqZe1OpKoTokemh2DYcVKhxzhN2SfP0Yw49Hk/s1600/gnucash-tree-field.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVnDUKBuwRoA4XS484jNZNLkYxElXfV0jSgLS3B_32HT-VcGXKo6BVXPRyMawVe6N2quD_Gw1SbS-oGyOPP7qDpJsPax91hPFwnkKrrBSqZe1OpKoTokemh2DYcVKhxzhN2SfP0Yw49Hk/s1600/gnucash-tree-field.png" /></a></div>
</div>
<div>
<br /></div>
這是因為早在建立帳本時,TWD 的定義也寫到帳本資料檔中了。還要修改帳本資料檔才行。<br />
<br />
<ul>
<li>若是存成舊的 xml 格式,請搜尋檔案中 "TWD" 字串附近的 "fraction" 改成 1</li>
<li>若是存成新的 SQLite 格式,用 sqlite 打開存檔,執行以下指令</li>
</ul>
<br />
<blockquote class="tr_bq">
UPDATE commodities SET fraction = 1 WHERE mnemonic = 'TWD';</blockquote>
</div>
<h2>
3. 報表</h2>
<div>
在稍微新一點的版本(我不確定版號,大概是 2.6 開始),在某些執行環境(譬如 windows),報表上的新台幣金額還是會出現小數點。<br />
<br />
這是因為 GnuCash 產生報表時會用 locale 的設定,若抓不到(windows)就會用預設值 2。</div>
<div>
<br />
修改方法是改 gnc-ui-util.c 的 gnc_default_print_info() 裡,<br />
<span style="font-family: Courier New, Courier, monospace;">- info.min_decimal_places = lc->frac_digits;<br />+ info.min_decimal_places = 0;</span></div>
kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-55926341515505591012015-07-05T13:43:00.000+08:002016-07-20T23:18:30.520+08:00The C++ Programming Language 國際中文版 第四版 勘誤其實好幾年前,大約是 Modern C++ Design 讀了一半的時候,我就放棄學習 C++ 進階技術了。倒也不是看不懂,那些技術很巧妙、確實能解決某些其他語言不易解決的實際問題沒錯,但覺得用那些技術寫程式也末免太迂迴。<br />
<br />
舉個比較簡單的例子:用 static_assert<> 來檢查 compile time 的問題。compiler 不認得什麼是 static_assert,就乖乖的把 template 展開;視 static_assert 怎麼寫的,展開之後可能發現某 class 有問題或是陣列宣告不合語法,於是吐出一堆 template 具現化失敗的錯誤訊息。<br />
<br />
我的意思是說,一個很 high level 的目的(也許是 static_assert,也許是判斷某個 type 是不是繼承另一個 type,或判斷 template 參數的個數……),但 compiler 不認得,寫的人只好用一堆 low level 的東西湊出那個意圖,叫 compiler 去一堆 header 檔裡找 template 定義、template matching、推導、instantiation,層層疊疊,寫的人辛苦,compiler 也花一堆時間照做,若不小心寫錯,還吐出天書一般的錯誤訊息。整個就是事倍功半。簡直是為了解決一個問題結果製造更多問題。<br />
(p.s. static_cast 已經在 C++11 成為語言的一部分了)<br />
<br />
話雖如此,無論是工作還是自己寫東西自娛,我還是常常用 C++。這陣子越來越常看到有人用新的 C++ 語法,自己也開始用。雖然還不太懂整個 C++11 C++14,但就看到的部分,覺得新的 C++ 修正了許多原本的不足,也有嘗試改善前面我提到的問題。難怪有看到文章說,很多 C++ programmer 因為 C++11 對 C++ 好感度提升了。<br />
<br />
最近看到 The C++ Programming Language 第四版的中文版剛出,就買了一本來看,想比較有系統的學學 C++ 的新東西。目前只讀了前幾章導覽的部份,覺得組織得比第三版好(其實很薄弱的印象,畢竟好幾年前讀的了)。作者 Bjarne Stroustrup 也更強調這本不是給初學者的教材,初學者應該讀他寫的另一本 <a href="http://www.stroustrup.com/programming.html">Programming -- Principles and Practice Using C++</a>。(我前陣子忘了這件事,竟然還推薦一個初學者,還好他沒聽我的話 XD)<br />
<br />
第四版翻譯的品質沒第三版葉秉哲的那麼好。文句算通順沒問題,有些譯名不習慣還可以接受,但是錯譯不算少。讀到令人困惑之處再找原文比對,通常會發現是翻譯錯誤。整體來說,翻譯得還可以,希望出版社/譯者能花更多工夫確保書籍的正確性。原本讀中文版是想偷懶節省時間,但我查找原文比對,還做了勘誤表向譯者回報問題,最終可能沒省下太多時間 :(<br />
<br />
以下是我自己做的勘誤表(若我有空繼續讀的話,會持續更新)<br />
<a href="https://docs.google.com/spreadsheets/d/1d3yOOVuhAHSla6LKQLZ9QHdu1hKgGegaXO7Np5PlIV8/edit?usp=sharing">https://docs.google.com/spreadsheets/d/1d3yOOVuhAHSla6LKQLZ9QHdu1hKgGegaXO7Np5PlIV8/edit?usp=sharing</a><br />
譯者在出版社的<a href="http://books.gotop.com.tw/v_ACL036900#07">書籍網頁</a>最下面有提供勘誤下載(err, 為什麼不是網頁,為什麼是 docx…),目前好像都是我回報的 :P (不過譯者並沒有100%接受我的建議)kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com4tag:blogger.com,1999:blog-1329601581767992299.post-79912087655818979992015-06-04T01:39:00.001+08:002015-06-05T21:14:40.921+08:00nonogram 漫談 - 3 TCGA2015<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">之後約三年多沒再改程式,只是有時會想到一些沒機會實作的點子。今年春假時翻了幾篇最近幾年的論文,發現用 SAT solver 來解 nonogram 有好幾個突出的成果,讓我又冒出一些新想法(結合傳統 solver 跟 SAT solver 的用到的技術),便考慮今年再次參賽。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">再來就是了解現在參賽程式的發展。說到這個我就要抱怨一下。TCGA 及 TAAI 辦的比賽(我是指各項比賽,不只 nonogram)某些資訊不夠公開,譬如有時比賽規則細節從略,有時比賽結果只有名次,沒有比數或棋譜/數據,有幾年甚至連名次都很難找到。(今年的狀況似乎還可以)。雖然比賽後其實有結賽報告,但那只有訂閱期刊才看得到,且限於篇幅沒有完整的資料。我並不認為這是故意隱瞞,但我覺得這部分沒做好,其實是會間接影響這領域的發展的。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">想像有個無聊的人(我? :p) 或是有個學生,對某個棋類感到好奇,說不定他本來看一看棋譜發現當下的程式不過爾爾,有為者亦若是寫個更強的,或是覺得某個課題有趣想找這幾年的冠軍討論。但實際上他上網查到的只有殘缺不全的資訊,說不定就澆息他的想法了,覺得那是一個自己玩自己的小圈圈。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">也許我比較理想化,我覺得這比賽還算是學術活動,雖然各自的程式不公開,還是要盡量「可重現」(別人用一樣的機器、類似的做法,應該要有辦法做出類似的結果)。但實際上就算報名了比賽,可能還是不知道對方用什麼機器,看不到對方跟別人對弈的棋譜。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">扯遠了,回到主題。我去信詢問這次比賽的規則及最近幾次的賽況,了解到今年規則大致上沒有差太多,這幾年 nonogram 的交大第一名的程式自 2011 年後也沒什麼改動。雖然我的程式還沒完成,還是先報名了 :) 畢竟對我而言有個寫程式自娛的機會,還到會場去看看這領域的進展,跟一些朋友、老師聊聊,都很有意思,比賽名次只是附帶的。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">我也回頭看了一下我舊的程式,TAAI11 時,程式在第 510 題卡了 81 分鐘(直到比賽結束還沒解出來),應該是程式有 bug 掉到無窮迴圈,而不是單純算得慢。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">這回我的程式計畫是,先重構我舊的程式,實作交大論文的 fully probe, FP2, 還有 search heuristic 當作 baseline,然後再開始試驗結合 SAT solver (其實我有做點小實驗,效果還不錯)。程式檔名就叫 baseline,只是沒想到後來光最佳化 baseline 就用掉了我全部的時間。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">照著論文實作的好處是,有數據可以對照知道自己有沒有誤解論文。我發現我大方向是對的,搜尋次數是一樣的,但問題出在算一樣的東西我的就是比較慢。用時間複雜度來說明就是,整個演算法是 O(a * b^n * n^c),這是指數時間演算法,我的 search heuristic 跟論文相同,其他部分也正確,所以 search node 跟論文一樣多,也就是 b 一樣大。但是我的程式比較慢,也許是選用的基本資料結構不同造成 a 比較大,或是一些實作細節的不同 c 比較大……所以我就一路最佳化我的程式,從大約三倍慢一直改進到慢 40%。</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">這次的比賽結果,交大第一名,1000 題花了 908 秒, 我拿第二花了 1135 秒,第三名 3737 秒,第四名兩小時解了 232 題。只慢 20% 是因為我稍微調整了 choose weight 的參數(比較小的 b,不過我其實不是很有把握)。也就是說我的程式只有一點參數不同,其他部份其他部分跟第一名的程式沒什麼兩樣,這是比較無趣的地方(理想上大家用不同做法,百花齊放,有趣多了)。</span><br />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">(技術細節我在接下來的文章再談)</span><br />
<br style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;" />
<span style="background-color: white; color: rgba(0, 0, 0, 0.8); font-family: 'Roboto Slab', 'Times New Roman', serif; font-size: 14px; line-height: 19px; white-space: pre-wrap;">這次比賽花了我一個禮拜的休假,加上兩個禮拜下班後的時間。我原本都在 linux 上開發,由於比賽要在 windows 上跑,我在前兩天才開始下載 Visual Studio Express 2013,所以程式還沒有針對 windows/vc++ 作最佳化。在賽後我改用 mingw64-g++ 並調整 compiler 參數,還可以快 15%,也就是說跟第一名只差 5% 左右。所以我可以很阿 Q 的說,只要再一個禮拜就可以贏了 :P (我也試了 Intel system studio 2015 free trial 裡附的 intel c++ compiler 15.0,但沒有比較快,不過我跟 intel c++ compiler 參數也不熟就是了)</span>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-32394690077270383842015-06-01T01:39:00.000+08:002015-06-01T01:39:12.047+08:00nonogram 漫談 - 2我跟 nonogram 的故事要從國中開始說起 :)<br />
<div>
<br /></div>
<div>
國中時有同學帶了尖瑞出版社的一本 "解題畫冊"(我忘了當時的書名) 來學校玩,那時還不流行數獨,不過就類似那感覺,每一頁就是一題,用紙筆加上邏輯推理,解出謎底的圖案。印象中那時會跟同學抄題目到自己的計算紙上玩。雖然覺得很有趣但好像沒有一直玩下去,現在回想大概是抄題、解題太累了,而且沒有跟同學競技的快感 (那時還會玩三角殺棋(當時我們叫三角棋),幾A幾B等等)</div>
<div>
<br /></div>
<div>
後來在某一年(可能是 2001)的 IOI 研習營期中考題,就有老師出了一題叫「海島地圖」其實就是 nonogram ,我那時還去幫忙寫 test data 跟參考解答。後來(應該是 2003)我到建中幫忙出校內比賽的題目,就拿一樣的題目來用。當時題目要求輸出全部符合條件的圖形,我對 nonogram 的理解就是 search 題,不過並不要求大家在比賽時限內寫出任何 heuristic,所以 n 給得並不大,只要能正確的 DFS search 就可以拿到超過一半的分數,若 search 時有稍微考慮不跟相臨顏色的條件衝突,差不多就能拿滿分。程式碼約 100~200 行就可以完成。只是印象中大部分的人都拿不到一半的分數。</div>
<div>
<br /></div>
<div>
後來查資料才發現,IOI '92 那年有題 "<a href="http://www.ioinformatics.org/locations/ioi92/report.html#4.2">Islands in the Sea</a>" 相信就是研習營出題的來源。'92 年的測試資料最大 8*8。另外,ICPC '93 年有一題 "<a href="http://www.karrels.org/Ed/ACM/93/prob_h.html">Scanner</a>" 應該也算相關的題目,記得 '97 集訓寫考古題時大家都卡住,只有 lckung 學長成功解出。</div>
<div>
<br /></div>
<div>
大學時出現了一系列 logic 遊戲的<a href="http://www.puzzle-nonograms.com/">網站</a>,我還有一些同學有時會玩玩上面的遊戲打發時間。這些遊戲 (Nonogram, Slither Link, Sudoku, Light Up, Bridges, Shikaku, Nurikabe, Dominosa) 有些還有人發表<a href="http://ref.kcwu.csie.org/puzzles/">論文</a>研究,有幾項還成為 <a href="http://en.wikipedia.org/wiki/Computer_Olympiad">Computer Olympiad</a> 或其他類似 conference 的比賽項目。 (Computer Olympiad 每年會辦許多電腦棋類比賽(西洋棋、象棋、圍棋甚至橋牌、撲克),我偶爾會關心一下比賽了解最近發展的狀況。)</div>
<div>
<br /></div>
<div>
我在 2011 年時才發現 nonogram 2010 年開始有辦比賽,也就開始讀相關的論文跟網路資訊,我發現當時網路上已經有幾個很強的 nonogram solver,但是大部分的論文都沒提到這件事(也許是論文發表的時間差,譬如 BGU 2010 年不錯的成果,論文 2012 投稿,2014 才登出來已經晚了;除此之外,我是覺得有些論文,該怎麼說呢,參考價值不高)。</div>
<div>
<br /></div>
<div>
我當時也覺得比賽規則有很大的問題。也許是想增加競爭趣味,比賽方式是雙方互相出題給對方解。但出題是在事先準備好的,沒有資源限制,所以可以隨機產生大量題目,用大量 CPU 把簡單的題目過濾掉,只要有足夠的計算資源,我相信可以做到比賽時限內沒有人可以解出任何一題 ;)</div>
<div>
<br /></div>
<div>
當時我的做法就是這樣:先隨機產生幾百個題目當種子,然後用程式去解,把解得比較快的題目丟掉,解得比較慢的題目隨機改幾個顏色(黑變白或反過來)當作新的題目。然後跟朋友借一些 CPU 來跑(我忘了多少,大概有數十顆),跑了也許一個禮拜吧。</div>
<div>
<br /></div>
<div>
當時覺得這比賽參賽者可能不是很強(根據前一年的賽後報告),比賽規則又不是很公平(或說有漏洞),所以我就報名參賽 TCGA2011 (6月),程式取名 Naughty,就是說我是來搗蛋的 :) 從程式開始寫到比賽不到兩個禮拜,事實上比網路上抓得到的 solver 還弱,結果拿第一名。</div>
<div>
<br /></div>
<div>
到了年底另一個比賽 (TAAI2011, 11月),這回我就幫忙修改比賽規則,改回單純的比賽解題速度,可是也比較無趣 (相較於其他棋類你來我往的廝殺),往後幾年比賽的規則大致上延用。</div>
<div>
<br /></div>
<div>
不過半年不見,交大的隊伍重組,程式演算法大改進,這回就換我<a href="http://kcwu.csie.org/~kcwu/nonogram/taai11/">被痛宰</a>了 XD (現在回頭看當年的紀錄,我才發現四年前他們用的電腦比今年比賽用的還快 orz 還好近幾年規則改成統一用同一台電腦跑了)<br />
<br />
交大 2013 年也發表了一篇 <a href="http://dx.doi.org/10.1109/TCIAIG.2013.2251884">paper</a> 解釋他們的做法,有興趣寫 nonogram solver 的話值得一讀。</div>
kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-74192666846759788252015-01-11T17:16:00.000+08:002015-01-12T01:33:15.707+08:00OSM vector map - mapsforge<div>
本文介紹 mapsforge 的 map 格式、製作、應用及相關概念。</div>
<h3>
OSM vector map</h3>
在 Android 上 OSM 的 vector map 主要有三個選擇<br />
<div>
<ul>
<li><a href="http://www.osmand.net/">OSMAnd</a></li>
<li><a href="https://github.com/mapsforge/mapsforge">mapsforge</a></li>
<li><a href="http://maps.me/">maps.me</a></li>
</ul>
<div>
OSMAnd 雖然 open source 但它的 <a href="https://github.com/osmandapp/Osmand/blob/master/LICENSE">license</a> 在 GPLv3 之上另外加了限制</div>
<blockquote class="tr_bq">
Publishing applications using the OsmAnd GPLv3 code to Google Play, Amazon Market or Apple Store should be done with written permission</blockquote>
<div>
所以在 app 世界沒有其他人用。</div>
<div>
<br /></div>
<div>
maps.me (以前叫 MapsWithMe)的公司在被併購之後 app 變免費,還宣稱會在 2015 年 open source (<a href="http://blog.maps.me/2014/12/full-version-of-mapsme-becomes-free-and.html">公告</a>)。</div>
<div>
<br /></div>
<div>
而 mapsforge 不是 app,它是一個 map engine library (LGPL),所以幾乎其他支援 vector map 的 app 其實都是用它,像是 <a href="http://oruxmaps.com/">OruxMaps</a>、<a href="http://www.locusmap.eu/">LocusMap</a> <a href="https://github.com/mapsforge/mapsforge/blob/dev/docs/Mapsforge-Applications.md">等等</a>。</div>
<div>
<br /></div>
<div>
另外,garmin gps 的地圖檔格式已被研究、公開,也有<a href="http://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin">一些程式</a>或<a href="http://garmin.openstreetmap.nl/">網站</a>可以將 OSM data 轉為 garmin gps 用(<a href="http://www.geocaching.com.tw/forum/viewtopic.php?f=14&t=2028">教學</a>)。本文不討論 garmin map。</div>
<div>
<br /></div>
<h3>
mapsforge</h3>
<div>
OSM 的資料本來就是點、線座標及文字 tag,已經是「vector」了。只是一般 OSM 資料用的 xml 或 pbf 格式只適合儲存、批次處理,不能 random access, render map。</div>
<div>
<br /></div>
<div>
mapsforge 將 OSM 的資料 preprocess 預先切成一個個 tile (且以 zoom level 區分),同一個 tile 的資料連續儲存,因此 render 時就能從檔案一次把相關的資料全讀完,省下很多計算(不用考慮資料是不是太遠不用畫;在 low zoom level 的資料也已預先篩選、化簡,也不會資料量太大)。(<a href="https://github.com/mapsforge/mapsforge/blob/dev/docs/Specification-Binary-Map-File.md">spec</a>)</div>
<div>
<br /></div>
<div>
不過 tile 裡資料要怎麼呈現、文字的擺放位置,是 render 時才根據 <a href="https://github.com/mapsforge/mapsforge/blob/dev/docs/Rendertheme.md">render theme</a> 決定。也就是說,mapsforge 的 data model 是延續 OSM 的設計,mapsforge 並沒有區分什麼是路、房子、河流,它只知道點、線的座標還有 tag,地圖上的顏色、線條樣式都是 theme 裡頭寫的。</div>
<div>
<br /></div>
<div>
不少人會自己製作 map 或 theme 跟人分享,像是</div>
<div>
<ul>
<li>各 map app 的論壇不時會有人分享</li>
<li><a href="http://www.openandromaps.org/en/">OepnAndroMaps</a> 則是專門架站提供世界各地用的 map file</li>
<li><a href="http://download.mapsforge.org/">http://download.mapsforge.org/</a> 也有</li>
</ul>
</div>
<div>
map 檔跟 theme 檔是分開的,但兩者的內容要配對。有的人會兩個一起 share,但也常見使用現有的 map 檔,再依各人用途或喜好修改 theme 檔<a href="http://www.openandromaps.org/en/oam-forums/topic/map-theme-link-collection">分享</a>。譬如 <a href="http://tartamillo.wordpress.com/tiramisu/">tiramisu theme</a>(<a href="http://tartamillo.wordpress.com/2013/12/26/tiramisu-a-new-theme-for-oruxmaps-and-openandromaps/">介紹</a>) 好像受到不少好評。</div>
<div>
<br /></div>
<div>
要測試作出來的 map 跟 theme,除了把檔案傳到 Android 用 map app 看之外,也可以用電腦上的 viewer (譬如 <a href="http://wiki.openstreetmap.org/wiki/Atlas_(navigation_application)">atlas</a>)直接看,會比較有效率。</div>
<div>
<br /></div>
<div>
除了 mapsforge 的 map 格式有分版本(向前相容),mapsforge library 也有分版本,新的 library 版本除了加功能、修 bug 之外,也會支援新的 render theme feature。只是大部分 app 都沒寫他用的是哪一版的 mapsforge library。依 tiramisu theme 網站的說法,現在只有 oruxmap 6.0 及少數程式用 mapsforge library 0.4 (可以用 svg icon)。<a href="https://github.com/mapsforge/mapsforge/blob/dev/docs/Changelog.md">2014/12 release</a> 的 0.5 開始支援 render theme V4。</div>
<div>
<br /></div>
<h3>
等高線</h3>
<div>
mapsforge 原先只是設計給 OSM 地圖用,並沒有考慮到等高線。但有人就想到,如果把等高線的座標寫成 OSM 資料格式,「偽裝成一般的 OSM way」,就可以用原有的地圖製作工具作成 map 檔,再修改現有的 theme 加上等高線的定義(可能像是「細黑線,某些高度用粗黑線」),就可以有等高線地圖了。</div>
<div>
<br /></div>
<div>
至於等高線資料哪裡來?美國 NASA 及各國研究單位合作有免費提供全球的高程模型(Digital Elevation Data) 。DEM 的資料內容很單純,就是把全球切成譬如 90m*90m 的方格,每個方格有一個高度數值。等高線便可以透過程式計算出來。</div>
<div>
<br /></div>
<div>
DEM 資料集</div>
<div>
<ul>
<li>目前大家主要是用 SRTMv2 (全球範圍的解析度到 90m,美國 30m)(有些洞,高緯度也沒有) 或衍生出來的版本。</li>
<li>另外有個 ASTER GDEM 析解度到 30m,但品質沒那麼好(一些文章寫的,像是 <a href="http://www.viewfinderpanoramas.org/reviews.html#aster">viewfinder 的 review</a> 或是 <a href="http://www.geocaching.com.tw/forum/viewtopic.php?f=14&t=1658">台灣某些地方「隆起」</a>)。</li>
<li>viewfinder 網站有提供 SRTMv2 的修正或補全</li>
<li>最近 SRTMv3 (30m) 剛公開也包含台灣 <a href="http://www.geocaching.com.tw/forum/viewtopic.php?f=14&p=23107">http://www.geocaching.com.tw/forum/viewtopic.php?f=14&p=23107</a> (有部分資料從 ASTER GDEM 來)</li>
<li>順帶一提,台灣政府其實有做<a href="http://bmap.nlsc.gov.tw/bmap/ch/index.php?option=com_content&view=article&id=109&Itemid=114">解析度 5m 的 DEM</a>,但地理資料受到<a href="https://osmtw.hackpad.com/Open-Geo-Data-for-Government-legal-issues">管制</a>,一般人無法拿到,即便是國外已免費公開的解析度也一樣。</li>
</ul>
<div>
<br /></div>
</div>
<h3>
製作 mapsforge 地圖</h3>
<div>
用到的資料及工具</div>
<div>
<ul>
<li>OSM 網站可下載<a href="http://planet.osm.org/">每週最新的 data</a>,但全球的資料一個檔 26G。geofabrik 有提供每天最新的<a href="http://download.geofabrik.de/asia/taiwan.html">台灣 OSM data</a> extract。</li>
<li><a href="http://wiki.openstreetmap.org/wiki/Osmosis">osmosis</a> 是 OSM data 的資料處理、轉換工具,支援很多格式,還能寫 plugin。</li>
<li>mapsforge 有提供 <a href="https://github.com/mapsforge/mapsforge/blob/dev/docs/Getting-Started-Map-Writer.md">osmosis plugin MapWriter</a>,可以在 osmosis 讀入 OSM data 之後,輸出成 mapsforge map 檔。</li>
<li><a href="http://katze.tfiu.de/projects/phyghtmap/">phyghtmap</a> 可以把 DEM 資料轉為 OSM 格式等高線。還內建下載 SRTM 跟 viewfinderpanoramas DEM 的功能。</li>
<li>如果手邊的地形資料不是 phyghtmap 能處理的格式,可能可以用 <a href="http://www.gdal.org/gdal_contour.html">gdal_contour</a> 轉換。<a href="http://www.gdal.org/">gdal</a> 是處理 GIS 資料常用的 library/tool。</li>
</ul>
</div>
<div>
詳細的步驟有<a href="http://forum.locusmap.eu/index.php?topic=1839.0">教學</a>。</div>
<div>
<br /></div>
<div>
若單純只有台灣 OSM data 的話,大概兩三分鐘就跑完了。若是含等高線(每 10m 一條線),全台灣一個檔(ram mode)大約要 8GB ram 執行 24 小時(估)。另有 hd mode,可以用少一點 ram,我沒試過。</div>
</div>
<div>
<br /></div>
<div>
若覺得全台灣的資料量太大,可以先用 osmosis 切成更小的區域。</div>
<div>
<br /></div>
<h3>
台灣的地圖</h3>
<div>
前面提到的 OpenAndroMaps (OAM) 就可以下載台灣的地圖了。<br />
<br />
geocaching.com.tw 的 Jing (也就是足跡<a href="http://yosmhm.neis-one.org/?JingGeocacher">遍布全台</a>的圖客 <a href="http://www.openstreetmap.org/user/JingGeocacher">JingGeocacher</a>) 結合 ASTER GDEM 及 OSM data <a href="http://www.geocaching.com.tw/forum/viewtopic.php?f=14&t=2112">自製 mapsforge 地圖</a>。通常每個月會更新一次。<a href="https://sites.google.com/site/mobilegpshiking/">手機 GPS 登山推廣計畫</a>也有寫文章<a href="https://sites.google.com/site/mobilegpshiking/deng-shan-ruan-ti-jie-shao/oruxmaps#TOC-ASTEROSM_TaiwanTOPO_Mapsforge_tw-">教學</a>如何安裝、設定。<br />
<br />
OAM 跟 Jing 的地圖的差異:<br />
<br />
<ul>
<li>OAM 的等高線距 20m, Jing 的比較精細到 10m。</li>
<li>Jing 的地圖比較大(46mb vs 159mb)</li>
<li>Jing 有另外調過 theme,我沒跟其他 theme 比較過。</li>
<li>OAM 的歐洲以外的地圖更新頻率好像超過一個月</li>
</ul>
<br />
<br /></div>
kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-85256033098458998502014-01-31T19:40:00.000+08:002014-01-31T19:40:04.458+08:00OpenStreetMap 登山踏查畫 OpenStreetMap 地圖一個很重要的活動就是到戶外走訪、搜集資料。Dennis 的投影片<a href="http://www.slideshare.net/ChenJuilin/osm-15933442">Osm資料收集與方法</a>就有一些介紹。我也來分享一下我自己如何進行。<br />
<br />
<h3>
概要</h3>
帶著 GPS 記錄器行走(會自動記錄移動軌跡),行進間看到覺得值得記錄的東西就拍照。也就是說出門時除了走路、拍照,其實並不麻煩。由於數位相機都會記錄拍攝時間,透過GPS記錄就可以知道拍照地點,回家到電腦前再根據搜集到的資料畫圖。<br />
<br />
p.s. 畫 OpenStreetMap 的方式有很多種,有的人用紙筆記錄、有的人邊走邊用手機或平板電腦當場編輯,各有優缺點,不同狀況可能適合採用不同的方式。<br />
<br />
<h3>
攜帶物品</h3>
<h4>
GPS 記錄器</h4>
可以是智慧型手機、平板、也可以是 GPS 手錶、記錄器等等。<br />
一開始我以為登山專用的 GPS 裝置(我用的是 <a href="http://www.garmin.com.tw/products/onthetrail/dakota20/">Garmin Dakota 20</a>, 2009年上市)定位會比手機(定位只是附加功能)準確,但在看了網友的測試及我自己的經驗,我的結論是 GPS 晶片還是不斷在進步,新機可能更好,就算是新手機也可能比舊 Garmin 專用機強。<br />
<h4>
數位相機</h4>
由於只是要記錄景物,所以畫質、顏色什麼的其實不重要,對焦快可能有用一點(比較不會因拍照而停下太久,之後又要追趕隊友),但差異不大。廣角鏡頭可能不錯。我自己是用一般的口袋傻瓜相機。<br />
<h4>
備用電池、行動電源、記憶卡</h4>
依行程長短而定。GPS 功能還有 LCD 螢幕很耗電,帶著以備不時之需。<br />
<br />
<h3>
一開始準備、設定</h3>
<div>
有些設定可能在家裡先操作看看,或是翻說明書。</div>
<h4>
GPS</h4>
在登山口前甚至更早一點可能就要把 GPS 打開定位,舊一點的機型或是有遮蔽的情況,定位可能要數分鐘。若太晚開起來,一開始的軌跡會沒記錄到。<br />
<br />
我會把 GPS 的記錄間隔設為每秒記錄一次。(這會比較耗電)<br />
<h4>
數位相機</h4>
相機的時鐘很可能不準,要校正(到秒),可是調整相機時間很麻煩。我覺得最簡單的方法是,在 GPS 定位完成後,用相機拍 GPS 機的(看得到秒數的)畫面。之後回家根據拍攝時間及畫面內容比較就知道要修正幾秒。<br />
<br />
無論是 GPS 或是數位相機,螢幕都是最耗電的元件之一。建議可以調整螢幕亮度、螢幕待機省電的時間。有些相機甚至可以關掉 LCD 螢幕用觀景窗拍照(或是盲拍,反正取景不重要? 我自己沒這樣玩過)。<br />
<br />
<h3>
行進間</h3>
祝旅途愉快 :)<br />
<br />
要記錄、拍些什麼呢? 簡單的原則是,你覺得標在地圖上有用的景物。除了重要的景物,也要拍四周的樣貌,才知道相對位置。除了要記錄的景物之外,也可以拍一些有的沒的,之後在畫地圖時可能可以幫助回憶。<br />
<br />
實際要記錄的東西可以參考<br />
<ul>
<li>Dennis 的<a href="http://www.slideshare.net/ChenJuilin/osm-15933442">投影片</a> 24-27頁「要記錄什麼」有列一些</li>
<li>可以畫的東西很多,上官翻譯的<a href="http://www.slideshare.net/shangkuanlc/20130609-osm-map-features-what-we-map">我們標什麼</a>說明(一般畫OSM地圖)優先順序為何</li>
<li>我參考「我們標什麼」,列了<a href="https://docs.google.com/spreadsheet/ccc?key=0AoFUWdnG_V81dE8wcG5wX1FXSjdhRncyd2dGelgwV2c&usp=sharing">登山踏查的優先順序</a></li>
</ul>
<h4>
小技巧</h4>
<div>
<ul>
<li>在遠方看到景物或叉路就先拍一張,很接近時再拍一張。這樣既補捉到四周的樣貌,也記錄了實際的位置。</li>
<li>有時轉身拍照,回家後忘了那是哪個方向的照片。一個方法是多拍幾個方向的照片,另一個方法是伸一隻手指向前進方向。</li>
</ul>
</div>
<div>
<h3>
結束後編輯</h3>
回到家將 GPS 軌跡還有相片傳到電腦上。<br />
<h4>
修正相片時間</h4>
首先要修正相片的拍照時間,很多軟體都有這種功能,我習慣用的是 <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a>。<br />
<br />
譬如相機記錄的拍照時間是 <span style="font-family: Courier New, Courier, monospace;">9:44:47</span>,但拍到的 GPS 畫面是 <span style="font-family: Courier New, Courier, monospace;">9:42:31</span>,就表示相機快了<span style="font-family: inherit;"> 2 分 16 秒</span>。就可以執行<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">jhead -ta-0:02:16 -ft *.jpg</span></blockquote>
將全部的相片時間往前調 <span style="font-family: Courier New, Courier, monospace;">2:16</span>。其中 <span style="font-family: Courier New, Courier, monospace;">-ta</span> 表示要調整多少拍攝時間, <span style="font-family: Courier New, Courier, monospace;">-ft</span> 表示將相片的檔案時間也改成拍攝時間。更多參數及功能請自行參考 jhead 的網頁。<br />
<h4>
編輯</h4>
我使用的 OSM 編輯器是 <a href="http://josm.openstreetmap.de/">JOSM</a>,它可以修剪、合併 GPX 檔。也可以把圖檔或是目錄拉到 JOSM,在地圖軌跡上顯示拍照的地點。<br />
<br />
我就不在這詳細介紹 josm 操作了,可以參考<a href="http://openstreetmap.wikispaces.com/OpenStreetMap%E6%95%99%E5%AD%B8">OpenStreetMap教學</a>。<br />
<br />
p.s. JOSM 其實也有修正相片時間的功能,但它主要是依軌跡位置估時間來修正。我還是喜歡自己用 jhead 直接依時間差修正。<br />
<br />
<h3>
安全第一</h3>
一些爬山該帶的東西別忘了(飲水、雨具、手機),出門前最好讀過其他人的旅遊記錄、地圖。為免 GPS 收訊不好或運作異常,最好也帶著紙本地圖、指南針。<br />
注意如果用手機當作 GPS 記錄器,可能會把電力耗盡,導致無法打電話。<br />
<br />
<h3>
其他</h3>
這是我整理的,畫登山地圖比較常用到的 <a href="https://docs.google.com/document/d/1YSVua0Th0SnswhlSytddLEZazVaSK1gx0w3ojYfBkrQ/edit?usp=sharing">OSM Hiking tags</a>。<br />
<br />
<br /></div>
kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-53796459615112198002013-06-28T02:25:00.000+08:002013-06-28T23:14:53.782+08:00如何在網頁上放 OpenStreetMap 及 GPX 軌跡本文分享兩個主題<br />
<ul>
<li>如何放單純的地圖(可互動操作)</li>
<li>如何在網頁上放地圖並顯示 GPX 軌跡在地圖上</li>
</ul>
<h2>
如何放單純的地圖(可互動操作)</h2>
<ol>
<li>連到 <a href="http://www.openstreetmap.org/">http://www.openstreetmap.org/</a></li>
<li>點選畫面最上面的 "Export" 功能</li>
<li>用滑鼠拖拉地圖區域</li>
<li>選擇格式</li>
<ul>
<li>OpenStreetMap XML Data, 這是 XML 資料檔</li>
<li>Map Image (shows standard layer), 這是下載成圖片, 有 png,jpg,svg,pdf 格式</li>
<li>Embeddable HTML, 網頁的 HTML 語法 --- 選這個,系統就會給你一段 <iframe 開頭的 html 碼</li>
</ul>
</ol>
譬如這段 HTML<br />
<small><code>
<iframe frameborder="0" height="350" marginheight="0" marginwidth="0" scrolling="no" src="http://www.openstreetmap.org/export/embed.html?bbox=118.05,20.8,124.63,26.26&layer=mapnik&marker=23.97120,121.21765" style="border: 1px solid black;" width="425"></iframe><br />
<small><a href="http://www.openstreetmap.org/?lat=23.53&lon=121.34&zoom=7&layers=M&mlat=23.97120&mlon=121.21765">View Larger Map</a></small>
</code></small><br />
會產生這樣的地圖:<br />
<iframe frameborder="0" height="350" marginheight="0" marginwidth="0" scrolling="no" src="http://www.openstreetmap.org/export/embed.html?bbox=118.05,20.8,124.63,26.26&layer=mapnik&marker=23.97120,121.21765" style="border: 1px solid black;" width="425"></iframe><br />
<small><a href="http://www.openstreetmap.org/?lat=23.53&lon=121.34&zoom=7&layers=M&mlat=23.97120&mlon=121.21765">View Larger Map</a></small>
<br />
<br />
<h2>
如何在網頁上放地圖並顯示 GPX 軌跡在地圖上</h2>
<div>
這比較複雜一點,我的方法是用 leaflet 這個 library 來畫地圖。 leaflet 可以加 plugin,配合 <a href="https://github.com/mpetazzoni/leaflet-gpx">leaflet-gpx</a>,就能畫 GPX 軌跡。</div>
<div>
我參考作者的 <a href="http://mpetazzoni.github.io/leaflet-gpx/">demo</a>,簡化之後:</div>
<small>
</small>
<pre><small><script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://kcwu.csie.org/~kcwu/geo/leaflet.js"></script>
<script src="http://kcwu.csie.org/~kcwu/geo/leaflet-gpx/gpx.js"></script>
<script src="http://kcwu.csie.org/~kcwu/geo/osm-gpx.js"></script>
<style type="text/css"> @import url('http://kcwu.csie.org/~kcwu/geo/osm-gpx.css');</style>
<section id='gpx_container' class=gpx ></section>
<script type="application/javascript">
simple_gpx($('#gpx_container'),
"http://kcwu.csie.org/~kcwu/geo/gpx/20130518 鷹仔尖.gpx",
{ title: '20130518 鷹仔尖.gpx', height: 400 });
</script>
</small></pre>
<small>
</small>
<br />
<div>
上面這段 HTML code 可以做出下面這樣的地圖</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://kcwu.csie.org/~kcwu/geo/leaflet.js"></script>
<script src="http://kcwu.csie.org/~kcwu/geo/leaflet-gpx/gpx.js"></script>
<script src="http://kcwu.csie.org/~kcwu/geo/osm-gpx.js"></script>
<style type="text/css"> @import url('http://kcwu.csie.org/~kcwu/geo/osm-gpx.css'); </style>
<br />
<section class="gpx" id="gpx_container-20130628"></section>
<script type="application/javascript">
simple_gpx($('#gpx_container-20130628'),
"http://kcwu.csie.org/~kcwu/geo/gpx/20130518 鷹仔尖.gpx",
{ title: '20130518 鷹仔尖.gpx', height: 400 });
</script>
使用說明:<br />
<br />
<ul>
<li>一般使用只要改 simple_gpx 那三行就夠了,剩下不用動。</li>
<li>用到的檔案只有 osm-gpx.js 是我寫的,於 public domain 釋出。其他檔案是各 project 自己的(BSD或MIT授權),可自由使用。</li>
<li>若同一頁會用多次,gpx_container 要改成其他名字(不能跟其他的重複,不然會錯亂)。前兩行(jquery.min.js 跟 leaflet.js)總共只要寫一次就好。 </li>
</ul>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com1tag:blogger.com,1999:blog-1329601581767992299.post-60769355625938143842013-05-19T23:06:00.002+08:002022-10-13T20:54:29.745+08:00鷹仔尖, 觀音山硬漢嶺最近發現<a href="http://tw.myblog.yahoo.com/panyulin0714/">雨林老爬</a>的部絡格,驚嘆其行程紀錄詳細的程度,尤其是每個路口都有照片並畫線加註。所以這次出遊,就來試試看用詳細的照片作行程紀錄 :)<br />
<div>
很快的我就放棄畫線加註的念頭……也許是我不知道適合的畫圖工具,想到就覺得太費工了,我好懶。<br />
<div>
<br /></div>
</div>
<script src="https://kcwu.csie.org/~kcwu/geo/leaflet-gpx/gpx.js"></script>
<script src="https://kcwu.csie.org/~kcwu/geo/osm-gpx.js"></script>
<style type="text/css"> @import url('http://kcwu.csie.org/~kcwu/geo/osm-gpx.css'); </style>
<section class="gpx" id="gpx_container-20130519"></section>
<script type="application/javascript">
simple_gpx($('#gpx_container-20130519'),
"https://kcwu.csie.org/~kcwu/geo/gpx/20130518 鷹仔尖.gpx",
{ title: '20130518 鷹仔尖.gpx', height: 400 });
</script>
<div>
<b>行程摘要</b></div>
<div>
捷運蘆洲站 > 觀音里站 > 鷹仔尖 > 盤絲亭 > 北橫古道 > 觀音山硬漢嶺 > 無極宮 > 八里渡船頭 > 淡水</div>
<div>
<br /></div>
<div>
<b>詳細紀錄</b></div>
<div>
8:00在捷運蘆洲站一號出口集合,搭橘20或785公車至觀音里站。下車處是停車場。</div>
<div>
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-xNNZnNozHQ4/UZiZQ8ddr0I/AAAAAAAAmeQ/6WmXrvQlfBk/s1600/IMG_2550.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/-xNNZnNozHQ4/UZiZQ8ddr0I/AAAAAAAAmeQ/6WmXrvQlfBk/s320/IMG_2550.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
9:06 出發,從路邊護欄缺口階梯往下</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-MeEgyHQ8Dys/UZio30aEj4I/AAAAAAAAmko/dJrrq9nvcMA/s1600/IMG_2552.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-MeEgyHQ8Dys/UZio30aEj4I/AAAAAAAAmko/dJrrq9nvcMA/s320/IMG_2552.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
9:07 下階梯後取左</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-xZLYoBbpX70/UZiZTeOO3mI/AAAAAAAAmeY/g0nh9BuBudw/s1600/IMG_2557.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-xZLYoBbpX70/UZiZTeOO3mI/AAAAAAAAmeY/g0nh9BuBudw/s320/IMG_2557.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
9:11 小北插入口處萬聖公</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-WsmQz6aN1Aw/UZiZVeGEQaI/AAAAAAAAmeg/Oo4FxIyYnf0/s1600/IMG_2562.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-WsmQz6aN1Aw/UZiZVeGEQaI/AAAAAAAAmeg/Oo4FxIyYnf0/s320/IMG_2562.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
一路是原始地形好走</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-9K64jnBANqA/UZiZXJmve9I/AAAAAAAAmeo/wm6SzeKX0ck/s1600/IMG_2567.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-9K64jnBANqA/UZiZXJmve9I/AAAAAAAAmeo/wm6SzeKX0ck/s320/IMG_2567.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
疑似<a href="http://zh.wikipedia.org/wiki/%E9%A6%AC%E9%99%B8">馬陸</a>(恐怖?連結)約小指粗,近十隻</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-_mZKIHUk8n4/UZiZZ0CsGcI/AAAAAAAAmew/S0dWJpfkE4Y/s1600/IMG_2570.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-_mZKIHUk8n4/UZiZZ0CsGcI/AAAAAAAAmew/S0dWJpfkE4Y/s320/IMG_2570.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
10:28 鷹仔尖涼亭。右往鷹仔尖登山口。休息後往左走占山步道支線到盤絲亭</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-SRICQajPf2U/UZiZcZeFXMI/AAAAAAAAme4/UPAxZFdrZDQ/s1600/IMG_2574.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-SRICQajPf2U/UZiZcZeFXMI/AAAAAAAAme4/UPAxZFdrZDQ/s320/IMG_2574.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-okZL9FqxAtU/UZiZfGmBJUI/AAAAAAAAmfA/7Px9Rz4Y0mg/s1600/IMG_2577.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-okZL9FqxAtU/UZiZfGmBJUI/AAAAAAAAmfA/7Px9Rz4Y0mg/s320/IMG_2577.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
10:44 涼亭下來五公尺右邊有泥土叉路,取左走步道。</div>
<div class="separator" style="clear: both; text-align: center;">
上次登鷹仔尖就是從步道上來,走這泥土路下去。</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-SxsAWGhPb4M/UZiZhJyQMZI/AAAAAAAAmfI/7rRKygmr-S8/s1600/IMG_2581.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/-SxsAWGhPb4M/UZiZhJyQMZI/AAAAAAAAmfI/7rRKygmr-S8/s320/IMG_2581.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
10:48 (回望拍照)步道右後方有叉路,接10:44看到的叉路</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-oDok5HcLWmA/UZiZj36wwxI/AAAAAAAAmfQ/MTPg6CrYdOI/s1600/IMG_2583.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-oDok5HcLWmA/UZiZj36wwxI/AAAAAAAAmfQ/MTPg6CrYdOI/s320/IMG_2583.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
10:51 盤絲亭旁的路口。右前往占山,左前(走步道)往硬漢嶺。右方另有一條沒有鋪面的路,不知通往哪裡。等一下取右前</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-taR8Xl1ghKA/UZiZmVOq_TI/AAAAAAAAmfY/Nk9UQHMNSDE/s1600/IMG_2585.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-taR8Xl1ghKA/UZiZmVOq_TI/AAAAAAAAmfY/Nk9UQHMNSDE/s320/IMG_2585.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
涼亭前的大樹</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-o3LVu6LHQgU/UZiZoeUPHaI/AAAAAAAAmfg/1cdxdpJJSuQ/s1600/IMG_2588.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-o3LVu6LHQgU/UZiZoeUPHaI/AAAAAAAAmfg/1cdxdpJJSuQ/s320/IMG_2588.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
盤絲亭,在此休息用餐</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-SCJijId5274/UZiZ1HgpNUI/AAAAAAAAmgI/afKHCXCNlhU/s1600/IMG_2605.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-SCJijId5274/UZiZ1HgpNUI/AAAAAAAAmgI/afKHCXCNlhU/s320/IMG_2605.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
盤絲亭後方山徑,猜測往陵線。</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-GWwUekiwvPU/UZiZ4PUXhtI/AAAAAAAAmgQ/gjYK22QA0nA/s1600/IMG_2606.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-GWwUekiwvPU/UZiZ4PUXhtI/AAAAAAAAmgQ/gjYK22QA0nA/s320/IMG_2606.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
盤絲亭後方山徑</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-zJIG1BHk8k0/UZiZ6jYUb1I/AAAAAAAAmgY/p-HYiQuGx4I/s1600/IMG_2607.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-zJIG1BHk8k0/UZiZ6jYUb1I/AAAAAAAAmgY/p-HYiQuGx4I/s320/IMG_2607.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
盤絲亭後方山徑</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-8ul58yNnfaQ/UZiwBKmU_FI/AAAAAAAAmk8/C4L9Z5vT4T8/s1600/IMG_2609.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/-8ul58yNnfaQ/UZiwBKmU_FI/AAAAAAAAmk8/C4L9Z5vT4T8/s320/IMG_2609.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
13:49 從盤絲亭出發往占山方向 13:52 抵硬漢嶺叉路</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-KKYkFnAb9Y4/UZiZsyU36oI/AAAAAAAAmfw/oNur2qAtu10/s1600/IMG_2593.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-KKYkFnAb9Y4/UZiZsyU36oI/AAAAAAAAmfw/oNur2qAtu10/s320/IMG_2593.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
叉路前地圖</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-hjpBhyUVY1k/UZiZvIr2dkI/AAAAAAAAmf4/8yKTOmpaHM4/s1600/IMG_2595.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-hjpBhyUVY1k/UZiZvIr2dkI/AAAAAAAAmf4/8yKTOmpaHM4/s320/IMG_2595.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
往占山</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-2i5szzCphEE/UZiZxwDxA1I/AAAAAAAAmgA/1TJgpz2ufcs/s1600/IMG_2597.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-2i5szzCphEE/UZiZxwDxA1I/AAAAAAAAmgA/1TJgpz2ufcs/s320/IMG_2597.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
另一個角度看路口。左前往盤絲亭,後往占山,右上走陵線上硬漢嶺,取右下走北橫古道。</div>
<div class="separator" style="clear: both; text-align: center;">
上回登鷹仔尖大概是回程時在盤絲亭的路口轉錯邊,就沒有去占山了。</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-hyfjwDuK99U/UZiZ89DUB9I/AAAAAAAAmgg/yUzuzXKnxaE/s1600/IMG_2614.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-hyfjwDuK99U/UZiZ89DUB9I/AAAAAAAAmgg/yUzuzXKnxaE/s320/IMG_2614.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
14:08 左上往駱駝嶺(不取)</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-hT1yVQMRF4g/UZiZ_ANr4FI/AAAAAAAAmgo/YcXADo9GGRA/s1600/IMG_2615.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-hT1yVQMRF4g/UZiZ_ANr4FI/AAAAAAAAmgo/YcXADo9GGRA/s320/IMG_2615.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-XD1ZUpWO8ds/UZiaBueQUiI/AAAAAAAAmgw/LAfud2NejfY/s1600/IMG_2617.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-XD1ZUpWO8ds/UZiaBueQUiI/AAAAAAAAmgw/LAfud2NejfY/s320/IMG_2617.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
14:15 北橫三、四段口,取左往硬漢嶺,右往四段</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-NRO_z7OJkH8/UZiaD5LGLEI/AAAAAAAAmg4/tJGxA94RznY/s1600/IMG_2618.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-NRO_z7OJkH8/UZiaD5LGLEI/AAAAAAAAmg4/tJGxA94RznY/s320/IMG_2618.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
四段的路況</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-gJ5-Qd-IKgQ/UZiaFTPlAVI/AAAAAAAAmhA/gK71mLu-Yws/s1600/IMG_2633.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-gJ5-Qd-IKgQ/UZiaFTPlAVI/AAAAAAAAmhA/gK71mLu-Yws/s320/IMG_2633.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
14:53 抵硬漢嶺,從觀景台下小路出來</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/--rYZjPiMKKA/UZix0ktuw4I/AAAAAAAAmlQ/43WqAkFkPl4/s1600/IMG_2635.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/--rYZjPiMKKA/UZix0ktuw4I/AAAAAAAAmlQ/43WqAkFkPl4/s320/IMG_2635.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
硬漢碑,看別人的文章才知道三角點在碑頂</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-9mxAOhtpIBc/UZiaG_dLzRI/AAAAAAAAmhI/q4qFHs-D1Ec/s1600/IMG_2637.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-9mxAOhtpIBc/UZiaG_dLzRI/AAAAAAAAmhI/q4qFHs-D1Ec/s320/IMG_2637.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
今天沒有展望</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-UxvVsImQEg4/UZiaTuGwnNI/AAAAAAAAmiA/Au5i0RqCt-c/s1600/IMG_2661.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-UxvVsImQEg4/UZiaTuGwnNI/AAAAAAAAmiA/Au5i0RqCt-c/s320/IMG_2661.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
硬漢嶺牌樓</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-_wm_h0Xu-sY/UZiaIHcuCII/AAAAAAAAmhQ/k76-HqZ5Ta4/s1600/IMG_2644.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-_wm_h0Xu-sY/UZiaIHcuCII/AAAAAAAAmhQ/k76-HqZ5Ta4/s320/IMG_2644.JPG" width="240" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-s32O04v8qI4/UZiaJyHFOlI/AAAAAAAAmhY/J8zneATdlZo/s1600/IMG_2647.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-s32O04v8qI4/UZiaJyHFOlI/AAAAAAAAmhY/J8zneATdlZo/s320/IMG_2647.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
往西走160m到眾樂園</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-RCLgklZOJAE/UZiaL2QNcAI/AAAAAAAAmhk/PW2xskCsCI0/s1600/IMG_2650.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-RCLgklZOJAE/UZiaL2QNcAI/AAAAAAAAmhk/PW2xskCsCI0/s320/IMG_2650.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
牛寮埔步道0m</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-zCijAXcW9Nw/UZiaNUImdjI/AAAAAAAAmho/WUWWKHCzqyA/s1600/IMG_2651.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-zCijAXcW9Nw/UZiaNUImdjI/AAAAAAAAmho/WUWWKHCzqyA/s320/IMG_2651.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
前是牛寮埔步道,右方建築是廁所</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-IgY83E84wFY/UZiaPb_d3pI/AAAAAAAAmhw/7yHc6b0pclY/s1600/IMG_2658.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-IgY83E84wFY/UZiaPb_d3pI/AAAAAAAAmhw/7yHc6b0pclY/s320/IMG_2658.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
廁所前花圃約九隻小小狗,沒看到狗媽媽</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-MVmewNj_k0Q/UZiaRaSse2I/AAAAAAAAmh4/5pW_zppm5H4/s1600/IMG_2659.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-MVmewNj_k0Q/UZiaRaSse2I/AAAAAAAAmh4/5pW_zppm5H4/s320/IMG_2659.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-05eoXtaKI9Y/UZiaVNdJLqI/AAAAAAAAmiI/Y-MARBQjpGM/s1600/IMG_2663.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-05eoXtaKI9Y/UZiaVNdJLqI/AAAAAAAAmiI/Y-MARBQjpGM/s320/IMG_2663.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
15:53 準備下山</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-CxC-GD2jujw/UZiaWup4gFI/AAAAAAAAmiQ/oELvkhQ_BRw/s1600/IMG_2664.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-CxC-GD2jujw/UZiaWup4gFI/AAAAAAAAmiQ/oELvkhQ_BRw/s320/IMG_2664.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
15:54 觀景台下方,右是來的方向往盤絲亭,取前</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-lSgXD69Mn1E/UZiaY4E0_vI/AAAAAAAAmiY/Y7VMRX5Fqo0/s1600/IMG_2667.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-lSgXD69Mn1E/UZiaY4E0_vI/AAAAAAAAmiY/Y7VMRX5Fqo0/s320/IMG_2667.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
15:57 原始山路,很滑不是很好走,一路都有拉繩。空不出手拍照了。</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-4lT8d37jqms/UZi1D0Qsc5I/AAAAAAAAmlk/Uxn_w7fK8pQ/s1600/IMG_2669.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-4lT8d37jqms/UZi1D0Qsc5I/AAAAAAAAmlk/Uxn_w7fK8pQ/s320/IMG_2669.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
16:19 牛寮埔步道回望山路</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-OGylp2w5ajg/UZiaahs3KEI/AAAAAAAAmig/30sGxe9JbwA/s1600/IMG_2674.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-OGylp2w5ajg/UZiaahs3KEI/AAAAAAAAmig/30sGxe9JbwA/s320/IMG_2674.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
16:28 牛寮埔步道</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-bK0WqzPW4G8/UZiadbnDzsI/AAAAAAAAmio/0wuVDqO6t4I/s1600/IMG_2675.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-bK0WqzPW4G8/UZiadbnDzsI/AAAAAAAAmio/0wuVDqO6t4I/s320/IMG_2675.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
16:29 涼亭,在此休息</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-NwqY0BeNj4M/UZiafYHGEJI/AAAAAAAAmiw/oqa1dhA_mqg/s1600/IMG_2679.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-NwqY0BeNj4M/UZiafYHGEJI/AAAAAAAAmiw/oqa1dhA_mqg/s320/IMG_2679.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
16:59 牛寮埔步道終點,接產業道路(往左)下山</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-FST5_-bEi9w/UZiahNjJwcI/AAAAAAAAmi4/jT25enPiGxg/s1600/IMG_2683.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-FST5_-bEi9w/UZiahNjJwcI/AAAAAAAAmi4/jT25enPiGxg/s320/IMG_2683.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
步道前地圖</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-2YrzBD3tWPI/UZiai47YcvI/AAAAAAAAmjA/kYhbpZNnR5I/s1600/IMG_2692.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-2YrzBD3tWPI/UZiai47YcvI/AAAAAAAAmjA/kYhbpZNnR5I/s320/IMG_2692.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
17:50 延著產業道路走到無極宮,有廁所。再往東走產業道路下山</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-wgD7WkgWr40/UZiakjXUXTI/AAAAAAAAmjI/TRVNHWvgqEE/s1600/IMG_2694.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-wgD7WkgWr40/UZiakjXUXTI/AAAAAAAAmjI/TRVNHWvgqEE/s320/IMG_2694.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-oAWkDnQHnDs/UZianDX7EHI/AAAAAAAAmjQ/gm5mhBCf31U/s1600/IMG_2697.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-oAWkDnQHnDs/UZianDX7EHI/AAAAAAAAmjQ/gm5mhBCf31U/s320/IMG_2697.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
17:54 牛寮埔福德宮。取右下山。左邊有小橋、鋪石路,不知通往哪裡。</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-ViiH9Eu405c/UZiapML1UpI/AAAAAAAAmjY/Y7M4TQhu55w/s1600/IMG_2699.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/-ViiH9Eu405c/UZiapML1UpI/AAAAAAAAmjY/Y7M4TQhu55w/s320/IMG_2699.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
福德宮前小橋</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-3bVYz6FrkFw/UZimtkR0QtI/AAAAAAAAmkI/uWJVpZrpD6s/s1600/IMG_2707.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/-3bVYz6FrkFw/UZimtkR0QtI/AAAAAAAAmkI/uWJVpZrpD6s/s320/IMG_2707.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
17:59 墓園一角叉路,有開路紀念碑。取左</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-Xzk-j3ckORk/UZimvbum-6I/AAAAAAAAmkQ/z6jUqEaScvA/s1600/IMG_2710.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-Xzk-j3ckORk/UZimvbum-6I/AAAAAAAAmkQ/z6jUqEaScvA/s320/IMG_2710.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
開路紀念碑</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-kXu6QbAf960/UZi7rCjMtzI/AAAAAAAAml8/f2kVivGzUX8/s1600/IMG_2714.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-kXu6QbAf960/UZi7rCjMtzI/AAAAAAAAml8/f2kVivGzUX8/s320/IMG_2714.JPG" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
18:07 明園大佛寺在路的左邊,可以看到大佛像</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-gRZuDIqSLxU/UZiarvx0mwI/AAAAAAAAmjo/jwuxtkQ-yOg/s1600/IMG_2726.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://2.bp.blogspot.com/-gRZuDIqSLxU/UZiarvx0mwI/AAAAAAAAmjo/jwuxtkQ-yOg/s320/IMG_2726.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
18:35 八里渡船頭</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-55482927434300489362013-04-04T02:38:00.002+08:002013-04-04T02:38:33.789+08:00GnuCash 小技巧:調整同日交易順序GnuCash 內部是以秒為單位來儲存交易日期。也就是說,假設有兩筆同一天的交易:<br />
<center>
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZYUwOYzwZlk2uj-lWB7d2b_roEk1nlLS981oaw6nHn8rZlNseLNgsICB0rPSRyc3Rf3fbVkxycccrH3cdM3856ZTRUb0bE6BaM-QRU7dgPA5XNrO3WKBSJ0h0TaYOmpz81Ja-gczrwwc/s1600/gnucash-1.png" /></center>
<br />
其實程式內部是
<br />
<blockquote class="tr_bq">
2013/4/4 00:00:00 A<br />
2013/4/4 00:00:00 B</blockquote>
只是使用者看不到 00:00:00 的部分。<br />
<br />
從 GnuCash 2.4 開始,有個功能可以調整同日交易的次序。但由於做得不夠好,開發人員就先把它隱藏起來。<br />
<br />
打開試用的方法:<br />
<ol>
<li>找到系統上的 gnc-plugin-page-register-ui.xml,Windows XP 的話在 C:\Program Files\gnucash\share\gnucash\ui</li>
<li>用一般的文字編輯軟體打開這個檔案,把<br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"><!--menuitem name="ShiftTransactionForward" action="ShiftTransactionForwardAction"/--></span><br />
改成<br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"><menuitem action="ShiftTransactionForward" action="ShiftTransactionForwardAction"/></span><br />
(有兩次)</li>
</ol>
存檔之後重開 GnuCash,在交易選單中會多出一個「將交易向下移」
<br />
<center>
<img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0vMia6phHNyIpvFQdiJiCyxfvdUl3oYkt-Gv1jKAmoHGWxzmZZlha3Sm5a89NcmkUsBeKmkhYmV-ky2dOuCYLsUXCSWpmM6DqCb8HycxZBd9A6R3x3iQYDIDNCK-6jy35g5iEwu6O8Y4/s1600/gnucash-1.png" width="319" /></center>
<br />
在交易 A 上面使用這功能,程式內部會將該交易的時間加一秒。按了之後不會馬上更新順序。要做某些動作(譬如關掉該 tab 再開)讓 GnuCash 覺得該重新計算順序,才會看到效果。可以看到交易的順序的換過來了:<br />
<center>
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXAZ-XnNg6xIe99mnjnatg2PFB52pXa0c7ZDk384cMQ7QEcni1sq5e2t_i8dxP_wsDYvfK9ZyJfiIm2F8F4IsKZ1vPBmBQ6dmCAVI6VjhcpWjw-Pv4zqbuCtV0IfZe9oOPZ2zSZ7qPUcQ/s1600/gnucash-1.png" /></center>
<br />
<blockquote class="tr_bq">
2013/4/4 00:00:00 B<br />
2013/4/4 00:00:01 A</blockquote>
這功能最大的問題在於看不到內部的秒數,有時多按幾次自己都忘了各個交易加了幾秒了。不過在完整的功能出現之前就湊合著用吧。kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com1tag:blogger.com,1999:blog-1329601581767992299.post-70312439947948610772012-01-26T13:28:00.000+08:002012-01-26T15:00:52.862+08:00FreeBSD 單機使用光世代多個 IP跟中華電信申請光世代網路,會有八個 public ip。八個動態IP 或是<a href="http://briian.com/?p=4756">一個固定+七個動態IP</a>。一台電腦用一個 IP,總覺得剩下的放著不用有點浪費…所以我嘗試一些設定方式希望能把剩下的 IP 拿來用。<br />
<br />
<span style="font-size: large;">小知識</span><br />
<b>setfib(1)</b><br />
FreeBSD 自 7.1 開始,支援 multiple routing table。只要在 kernel config 裡加一行<br />
<blockquote class="tr_bq">
options ROUTETABLES=16 # max 16. 1 is back compatible.</blockquote>
之後在執行程式前加上 setfib N 就能指定使用第 N 個 routing table (預設是 0)。譬如<br />
<blockquote class="tr_bq">
$ setfib 1 route add default 192.168.1.1<br />
$ setfib 1 netstat -rn</blockquote>
使用 setfib 命令不需 root 權限。<br />
<br />
<b>光世代 VDSL modem</b><br />
從網路上可以找到許多教學,還有 admin default 帳號密碼。進入 http://192.168.1.1/ 管理介面發現可以動手設定的東西還不少。<br />
(比較新的 modem 預設開啟無線網路,也設好了 modem 撥號+DHCP server。)<br />
我用的這台型號是 ZyXEL VDSL2 P874。<br />
<b><br /></b><br />
<span style="font-size: large;">1. 開多個 PPP 連線 (fail)</span><br />
用光世代上網有兩種方式,一是從電腦 dial PPPoE,一是 VDSL modem 撥號再從電腦 DHCP。兩種方式可以共存。<br />
我原本就是 dial PPPoE 上網的,因此直覺是能不能 dial 多個。將原本設定檔整段複製一份,device 從 re0 改成 re1 (我有兩張網路卡),但不知道為什麼不成功。<br />
<br />
<span style="font-size: large;">2. 一個 PPP 連線一個 DHCP</span><br />
這個方式可以很簡單的使用兩個 IP。<br />
<br />
第二個 IP 就用 dhcp 拿到。要注意 dhcp 跟 ppp 都會設 default gateway,不要互相蓋到了。可以寫 dhclient config 或 script 解決;一個簡單的方法是用 setfib 跑 dhclient,這樣剛好 gateway 設定分開設在不同的 routing table 上。<br />
<br />
因為 ppp (public ip)跟 dhcp 的 ip (192.168.1.x)在不同的網段,所以只要 setfib 就能選用不同的 gateway,自然連出去的 ip 也就不同。也就是說<br />
<blockquote class="tr_bq">
$ w3m http://www.whatismyip.com # 是用第一個 ip<br />
$ setfib 1 w3m http://www.whatismyip.com # 是用第二個 ip</blockquote>
其實也不一定要用 DHCP,只要是 192.168.1.0/24 的 ip,gateway 設 192.168.1.1就會走 modem 自己撥號拿到的 ip 出去。<br />
<br />
<span style="font-size: large;">3. Modem dial PPPoE 兩次</span><br />
延續先前的設定。在 modem 的 web 管理介面中,<br />
Advanced Setup -> WAN 裡面可以新增 PPPoE 的連線,讓 modem 自己多撥幾個 IP 來。現在多加一組就好。假設新加的 interface 叫做 ppp1_4。<br />
Advanced Setup -> LAN 裡面可以勾選,增加第二組 LAN IP,譬如 192.168.3.1。<br />
Advanced Setup -> Routing -> Policy Routing 裡面可以設定符合某些條件的連線使用不同的 routing。這裡設定 192.168.3.0/24 走 ppp1_4。<br />
<br />
在 FreeBSD 這邊, ifconfig alias 一個 192.168.3.x 的 IP, gateway 設 192.168.3.1 (可以用 setfib 2 設在第三個 routing table 上)。<br />
<blockquote class="tr_bq">
$ setfib 2 w3m http://www.whatismyip.com 會用第三個 ip</blockquote>
<br />
<span style="font-size: large;">4. Modem dial PPPoE 多次</span><br />
以下內容我還沒試過。<br />
在 modem 的 web 管理介面中新增 WAN 更多組 PPPoE 連線。<br />
因為沒辦法新增更多 LAN ip,所以只能讓 FreeBSD 這邊的 ip 用相同的網段、相同的 gateway。譬如 192.168.1.2, 192.168.1.3, etc.<br />
Policy Routing 就設 192.168.1.2/32 走 ppp1_5,192.168.1.3/32 走 ppp1_6…依此類推。<br />
<br />
比較麻煩的是,都是相同的網段相同的 gateway,FreeBSD 上如何指定出去的 IP。<br />
a. 如果程式是自己寫的,可以 bind socket 到指定的 address。也許可以用 LD_PRELOAD 幫別人寫的程式 bind,我猜這個方法不是每個程式都能成功。<br />
b. jail 可以不同 jail 使用不同的 ip。我覺得這很可行,只是要管理及使用 jail 稍麻煩一點。<br />
c. 可能可以用 ipfw 或 pf 做 policy routing,以 user 或 group 當條件來 rewrite。我跟 pf 不熟,還試不出來。<br />
<br />
<span style="font-size: large;">其他</span><br />
a. 我一開始想改 modem admin 帳號(cht) 的密碼,但不知為何改了之後並沒有完全生效 --- 有時要輸入我改的密碼,有時要輸入預設密碼,相當困擾,於是我又改回去。<br />
b. modem 有些設定 save 之後去改其他東西,回頭來看竟然發現之前改的設定消失了,只好重改一次。有時設定要過好久才生效。於是我在測試時,就很難了解到底是我設錯還是 modem 發生什麼怪事。<br />
c. 我還曾發現我連出去的 ip 不是 dial PPPoE 拿到的 ip,相當神秘。<br />
d. modem 裡面預設就有一組 PPPoE 帳號密碼,但那組帳號不是我的 hinet 帳號。不知道這代表什麼。<br />
<br />kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com1tag:blogger.com,1999:blog-1329601581767992299.post-16025057846260002642011-08-27T23:16:00.000+08:002011-08-27T23:16:00.609+08:00漫談 nonogram我本來想寫兩篇文章,一篇寫我 survey nonogram 的心得,一篇寫我自己的 nonogram solver 用到的演算法跟技巧。後來想想,決定先寫這篇一般性的介紹。<br />
<br />
<span class="Apple-style-span" style="font-size: large;">什麼是 nonogram</span><br />
看 <a href="http://zh.wikipedia.org/zh-hant/Nonogram">wikipedia</a> 這張圖應該就很清楚了。nonogram 是個單人用紙筆玩的邏輯遊戲,題目是一個 m*n 大小的方格及左邊跟上面的數字,遊戲目的是根據這些數字提示,解出中間的圖形來。數字表示黑色色塊的數量,譬如第五橫列的 3 3 4 表示那一列中,由左至右有連續 3 個黑色,之後又有 3 個黑色,之後又有 4 個黑色。連續的黑色色塊之間至少有一個白色隔開。<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://upload.wikimedia.org/wikipedia/commons/6/64/Paint_by_numbers_Animation.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://upload.wikimedia.org/wikipedia/commons/6/64/Paint_by_numbers_Animation.gif" width="320" /></a></div><br />
<br />
很容易能理解,nonogram 出題很簡單,隨便畫出中間的圖,算出旁邊的數字就是一題,但 nonogram 的題目隨便出的話,很容易有不止一組解,也很可能難以解出。就像 sudoku 一樣,人們在設計 nonogram 題目時,常會要求要能夠用邏輯推理解題,而且只有唯一解才是好題目。<br />
Nonogram 這種 puzzle 似乎沒有統一的名字,只有各公司給的產品名稱,因為商標的關係,很多公司推出 nonogram 的遊戲時會另外再取名字。因此 nonogram 有<a href="http://www.comp.lancs.ac.uk/~ss/nonogram/syn">超過十幾種稱呼</a>,除了 nonogram 之外,常見的稱呼還有 Griddler、Picross、Paint by Numbers、甚至有的人直接用 "Japanese Puzzles" 來稱呼 nonogram。nonogram 也沒有統一的中文譯名。<br />
<br />
<br />
<br />
<span class="Apple-style-span" style="font-size: large;">相似或相關的問題</span><br />
<div>Nonogram 是黑白、2D、矩形的盤面。有許多類似的 puzzle 是用一樣的玩法規則,但加一些變化。譬如變成彩色(Picross)、變成3D(Picross 3D)、或變成<a href="http://www.griddlers.net/pages/t_rules">六角形</a>(Triddlers)。也有一種玩法是數字提示只給總合,不像 nonogram 會給出每一段的長度。</div><div>值得一提的是最後這種變形,學術上叫做 <a href="http://en.wikipedia.org/wiki/Discrete_tomography">Discrete Tomography</a>,是 <a href="http://en.wikipedia.org/wiki/Tomography">Tomography</a> 的特例。Tomography 是醫學或一些應用科學實際會遇到的問題,有相當多的研究。譬如用 X 光照相,根據陰影的濃度大概可以知道穿過多厚的東西,如何從不同方向照的相片,反推出被照物體的 3D 結構。</div><div><br />
</div><br />
<br />
<span class="Apple-style-span" style="font-size: large;">nonogram 的人類解法</span><br />
<div>一般的解法都是一次以一直行或一橫列,只看該行或該列,利用數字提示加上已知部分的黑或白,通過邏輯推理求出更多的色塊。也可以用試誤法、窮舉法等比較暴力的解法。會需要一次觀察多行/列才能解的題目算是難度相當高的。</div><div>很多網站的解法教學都只講了最基本的,剩下就讓人自行領略 <a href="http://en.wikipedia.org/wiki/Nonogram">en.wikipedia</a> 算是把這些基本方法列得比較詳細的。很少看到網站介紹比較進階的解法,推薦 webpbn 的這篇 <a href="http://webpbn.com/index.cgi?page=solving.html">Advanced Puzzle Solving Techniques</a>。</div><div><br />
</div><br />
<span class="Apple-style-span" style="font-size: large;">nonogram 的難度</span><br />
一般在報紙或書本上的 nonogram 題目,為了畫出好看的圖形、為了讓人解得出來,其實都不會太難。若是整個盤面隨機填黑白色塊,不限一定要用邏輯推理來解題,難度就會高非常多。也就是說,盤面的大小跟難度不一定有關係,雜誌上的 80x80 盤面可能很簡單,30x30的 random 盤面可能就很難,用電腦解可能要數分鐘、小時、甚至更久。<br />
在 1996 年,有論文證明了 <a href="http://www.phil.uu.nl/~oostrom/oudonderwijs/cki20/02-03/japansepuzzles/complexity.ps">nonogram 是 NP-complete 問題</a>。在該論文中,也同時證明了,如果已知 nonogram 的其中一組解,求是否有第二組解,也是 NP-complete 問題。<br />
<br />
<span class="Apple-style-span" style="font-size: large;">哪裡可以玩 nonogram</span><br />
有許多網站可以玩 nonogram,其中我最推薦的是 <a href="http://webpbn.com/" rel="noreferrer">http://webpbn.com/</a> 這個網站。與其他網站相比,他有這些優點:<br />
<br />
<ul><li>免費</li>
<li>只要瀏覽器(javascript)就能玩,不用裝 flash 或是 java plugin</li>
<li>遊戲操作介面良好。滑鼠左右鍵可設定,支援鍵盤快速鍵,還有 undo、redo、save,還有貼心的顏色提示(不喜歡可以關掉)。</li>
<li>題目是人出的,而不是程式 random 出題。網站上也有 quality、difficulty 標示,還能對題目寫 comment。</li>
</ul>在 Android/iOS 上也有 app 可以玩 nonogram,只是手機上不易操作,可能還是在 pad 之類螢幕比較大的裝置比較適合。<br />
<br />
<span class="Apple-style-span" style="font-size: large;">用程式解 nonogram</span><br />
事實上網路上有不少人寫過 nonogram solver,但大多只能解簡單的題目。目前有公開程式最強的 solver 應該是 webpbn 網站作者 Jan Wolter 寫的 <a href="http://webpbn.com/pbnsolve.html">pbnsolve</a>。Jan 也寫了一篇詳細的 <a href="http://webpbn.com/survey/index.html">solver survey</a> 比較各 solver。也有一些<a href="http://scholar.google.com.tw/scholar?hl=zh-TW&q=nonogram+OR+%22Japanese+puzzle%22&btnG=%E6%90%9C%E5%B0%8B&lr=&as_ylo=&as_vis=0">論文</a>在討論如何解 nonogram,我大概整理成一個<a href="http://ref.kcwu.csie.org/nonograms/">列表</a>,有空的話我會寫篇文章聊聊我看那些論文的心得。<br />
<br />
<span class="Apple-style-span" style="font-size: large;">nonogram 程式比賽</span><br />
<a href="http://ilk.uvt.nl/icga/">ICGA</a>、<a href="http://www.taai.org.tw/TAAI/">TAAI</a>、<a href="http://tcga.ndhu.edu.tw/">TCGA</a> 這幾個單位每年都會舉辦棋牌類的電腦程式比賽,像是象棋、圍棋、西洋棋、六子棋、暗棋等,最近幾年也加入了 puzzle 項目。從 2010 年開始有 nonogram 程式的比賽。比賽方式是比賽雙方事先出好題目,交換讓對方解,解得多的獲勝。老實說我覺得用對奕的方式比較 puzzle 輸贏是很奇怪的事。不過這比賽才兩年,也許賽制、形式還會再調整。<br />
今年六月 TCGA 辦的比賽我有參加,也許是這比賽知道的人不多,參賽者還太少,我覺得參賽的程式(包括我自己的)都還比 pbnsolve 弱很多。kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-68511128496093583362010-12-27T20:04:00.000+08:002011-08-27T23:29:03.834+08:00Nexus S 入手感想我從 milestone (2.1) 換用 nexus s (2.3) 不到一週的感想<br />
<div><br />
<div>列出一些我喜歡的改變:</div><ul><li>contacts 可以 search 到 nickname 了, 而且中文名字不再全列在最後, 改成用漢語拼音排列, 也可以用漢語拼音 search</li>
<li>gmail 支援有顏色的 label, 切換帳號跟 folder/label 變方便了(少一次 click)</li>
<li>"管理應用程式" 拉到主 menu, 在 app list 按 option 也會出現</li>
<li>"管理應用程式" 內建最基本的 disk/process 管理功能</li>
<li>calendar 也支援 multi-account 了</li>
<li>震動跟音量不再是分開設定了, 不用再裝 Silent Mode Jam </li>
<li>電池電量那邊, 可以顯示電量變化的折線圖, 還有各時段各種功能的開關狀態. 可惜圖沒辦法縮放, 不然就能完全取代 JuicePlotter 了</li>
</ul><div>還有一些不喜歡的, 大多是手機本身, 而不是 android 的問題:</div></div><div><ul><li>好像更耗電, 充電時間更久. 不過這我要多試幾次確定</li>
<li>不知道是不是因為螢幕 LCD 的 rgb 排列問題, 在白色底色可以看出一點點網點, 當看小字時會感到字變毛掉/鋸齒狀, 比較難以閱讀. 我懷疑因為這樣讓我用久了覺得不舒服.</li>
<li>沒了鍵盤, 連 trackball 都沒有, 這是要怎麼輸入密碼/玩遊戲...</li>
<li>我不喜歡 app list: 捲動停下來時會對齊, 造成捲動長度小於 0.5 就會被拉回去一些. 而且無法拉下方 fade out 區往上捲動... 總的來說我覺得是浪費上下兩排的空間作特效.</li>
<li>Back 鍵沒有延伸到手機面板邊緣, 好處也許是比較不會誤按, 可是缺點是常常沒按到.</li>
<li>鬧鐘 App 不見了, 改成要先進時鐘再選鬧鐘, 不知道是舊版才有還是那是 motorola 自製的.</li>
</ul><div><br />
</div></div>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-36455161819411603682010-12-16T23:22:00.000+08:002010-12-26T14:12:01.445+08:00我在用的 Android Apps<div>補足基本功能</div><ul><li>Silent Mode Jam - 預設的來電音量跟震動是分開設定的. 當你把音量調成靜音時, 這個 app 會自動把震動打開. (update: 2.3 已經內建)<br /></li><li>Battery Indicator - 狀態列預設的電池電量只有圖示, 這個 app 會另外用一個 notify icon 用<span style="font-weight: bold;">數字</span>顯示. 缺點是沒辦法取消原本的 icon.<br /></li><li>Brightness Level - 一個 1x1 的 widget. 按一下就能設定螢幕亮度.<br /></li><li>Handcent Sms - 簡訊程式, 比系統預設的稍好看一點.<br /></li><li>No Signal Alert - 當手機沒有訊號時, notify<br /></li></ul>省電相關<br /><ul><li>JuiceDefender - 我希望手機時常保持網路連線(譬如每隔一段時間就 sync gmail/gtalk/reader), 但我又不想自己手動開關網路連線, 我又想省電. 如果你的需求跟我一樣, 我相當推薦這個 app. 根據這個 app 的計算, 我的使用情況, 免費版大概讓我的電池使用時間變 1.5 倍, 付費版約 2~2.5 倍. 我不知道這數字多準, 但的確可以感受到可以用更久.<br /></li><li>JuicePlotter - 如果你很在意電池電量的變化, 這個 app 可以畫出電池電量對時間的折線圖, 還標示出何時開網路/GPS/螢幕/溫度. 搜集資料幾乎不會耗電(event driven, not polling), 只是畫圖並不快. (update: 2.3 內建簡化的功能)</li><li>APNdroid</li></ul><br />備份<br /><ul><li>App List - 備分已安裝的 app list (一個文字檔) 到 SD card 上<br /></li><li>AppMonster - 備分已安裝的 app 的 apk 檔到 SD card 上<br /></li><li>Call Logs Backup & Restore - 把 call log 備分到 SD card 上(xml)<br /></li><li>SMS Backup & Restore - 把 SMS 備分到 SD card 上(xml)<br /></li></ul><br />遊戲 - 我玩得不多就是了<br /><ul><li>Angry Birds, Angry Birds season</li><li>Jewels</li><li>Sudoku Daily - 我覺得這個 sudoku app 比其他的好. 有分很多 level, 有 undo/redo/hint, hint 很詳細還有教學. UI/操作也比較好. 如果你不是純紙筆派的, 需要或多或少(可設定)電腦輔助玩 sudoku 的話, 很推薦.<br /></li></ul><br />其他<br /><ul><li>ColorDict - 離線字典, Google Translate 線上字典</li><li>Divi Clock - 1x1 的 world clock widget, 支援 timezone, 免費</li><li>Gmail Notify Free - 當 gmail 收到符合特定條件的信, 會 notify(可設定). 免費版一個 account 只能設一個 rule. 不過可以 match label, 所以也很夠了. (gmail 預設的 notify 是有信就 notify)</li><li>handyCalc - 比較強的計算機, 內建單位/幣值換算功能</li><li>RealCalc Scientific Calculator - 比較像傳統的科學計算機<br /></li><li>NewsRob - 如果有在用 google reader, 非常推薦這個 app</li><li>Pluroid - plurk client 我不喜歡河道, 比較喜歡條列式的方式看 plurk</li><li>NetCounter - 記錄每天的網路用量, 分 3G/wifi </li><li>rTerm - bbs client</li><li>ConnectBot - telnet/ssh client<br /></li><li>Dropbox - sync files between windows/mac/android</li><li>KeepassDroid - manage password, 配合 Dropbox 使用<br /></li></ul>Google<br /><ul><li>Google Talk</li><li>Google Translate</li><li>Google Finance</li><li>Google Map Street view</li><li>My Maps editor by google<br /></li><li>Gesture Search</li><li>Barcode Scanner</li><li>Goole Sky Map</li><li>Voice Search - 比預期的還要好很多<br /></li></ul>工具類<br /><ul><li>Compass</li><li>StopWatch & Timer</li><li>TeslaLED Flashlight<br /></li><li>Voice Recorder</li><li>Ruler</li></ul>No comments<br /><ul><li>aContactss</li><li>ActionComplete</li><li>AK Notepad<br /></li><li>Calendar Pad</li><li>EasyProfiles<br /></li><li>GPS Test<br /></li><li>Opera Mini</li><li>台北公車</li><li>台灣天氣圖</li><li>高速公路</li><li>注音倉頡輸入法</li><li>嘸蝦米輸入法<br /></li></ul>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-54598167650104871482010-02-19T19:07:00.000+08:002010-02-19T23:24:23.901+08:00用 hugin 接合多張掃描圖檔(更新)本文介紹如何用 hugin 接圖, 專為掃描器掃描的圖檔而寫, 而非全景圖.<br /><br />這篇是<a href="http://kuangche.blogspot.com/2008/12/hugin.html">前一篇</a>的加強版. 根據 <a href="http://hugin.sourceforge.net/tutorials/scans/en.shtml">Hugin tutorial — Stitching flat scanned images</a> 及 hugin 2009.4.0 而寫.<br /><br /><br /><div><ol><br /><li>準備工作:<br /><ul><br /><li>先用其他軟體將 image 轉成相同方向, 同向就可以了(不一定要轉正). hugin 不認得 EXIF 旋轉 tag, 要真的轉 bitmap.<br /></li><li>若是 jpeg 檔, 我會用 <a href="http://jpegclub.org/">jpegcrop</a> 無失真旋轉. 並順便把多餘的部份切掉(不要切得剛剛好, 稍留幾個 pixel, 等最後完成時再切)<br /></li><br /></ul><br /><br /></li><li>File->Preferences 設定<br /><ul><br /><li>Control Points Editor 裡, 把 "Enable rotation search" 勾起來. start/stop angle 設小一點, 譬如 5, step 設小一點, 譬如 6. 若要接全景圖時記得調回來比較好.<br /></li></ul><br /><br /></li><li>在 "Images" tab<ol><br /><li>"Add individual images...", 載入全部的 image, HFOV 填 10.</li><li>(hugin 2009.4.0 沒附 autopano-sift-c.exe, 要自己去抓或自己 compile) 按 "create control points", 讓程式自動產生 control point. 若是掃描文件, 自動產生的效果並不好, 可以略過這步</li><br /><li>對比較中間, 或比較正的那張圖, 按 "Anchor this image for position". 對亮度比較對的圖按 "Anchor this image for exposure". (預設值是第一張).<br /></li></ol><br /><br /></li><li> 在 "Camera and Lens" tab<br /><ol><br /><li>在每張 image 上按 new lens, 確定 "Lens no." 都不一樣<br /></li><li>確定每張的 Lens type 都是 "Normal (rectilinear)"<br /></li><li>把每張圖的 view(v), horizontal shift(d), vertical shift(e) 的 link 都取消不要勾選<br /></li></ol><br /></li><br /><br /><li>在 "Control Points" tab<br /><ol><br /><li>可以自己增減 control points, 要幾個才夠我也不知道, 我的習慣是大約 10 個<br /></li><li>我習慣 zoom 50%, 比較容易看<br /></li><li>加 control point 時, 可以用滑鼠左鍵拖拉, 看好位置再放開左鍵<br /></li><li>"auto fine-tune" 有勾起來或自己按 "Fine-tune", 程式會自動找滑鼠點的附近最合的點, 因此也可不用點很準.<br /></li><li>左右圖各選一點後, 確定沒問題可以按 "Add" 新增, (或是在圖上按滑鼠右鍵)<br /></li><li>若圖都是斜的, 圖中又有水平或垂直線, 可以加 control point, mode 選 vertical line 或 horizontal line.<br /></li></ol></li><br /><br /><li>在 "Optimizer" tab<br /><ol><br /><li>選 custom parameter<br /></li><li>勾 reference image 以外的 r, v, d, e<br /></li><li>若 reference image 也是歪的, 把 r 也勾起來<br /></li><li>其他不要勾<br /></li><li>按 "Optimize now!", "Apply". 注意一下數值, 若太大的話回到 Control points tab 增刪調整.</li><br /></ol></li><br /><br /><li> 在 "Stitcher" tab<br /><ol><br /><li> projection(f) 選 "Rectilinear"<br /></li><li> 按 "calculate field of view", "calculate optimal size".<br /></li><li> output 選 jpeg, quality 90<br /></li><li> ctrl-shift-p fast preview<ul><br /> <li>若歪一邊, 選 "Drag" 調整. 可以按住 Shift, 再 drag, 比較容易水平或垂直調整<br /> </li><li>調整完回到 Stitcher tab 按 "calculate field of view", "calculate optimal size". 然後重新 fast preview<br /> </li><li>若 image 還是超出範圍, 只好自己手動填值<br /> </li><li>若 image 比範圍小, 可以選 "Crop" 切掉超出去的部份<br /></li></ul><br /></li><li> "Stitch now"</li><br /></ol></li><br /><br /><li>存檔, 方便以後修改, (也許將來 hugin 新版重做效果更好?)<br /></li></ol></div><br /><br /><br />簡單解釋參數:<br /><ol><li>yaw(y), pitch(p), roll(r): yaw 是左右偏角, pitch 是仰角, roll 是旋轉. 細節跟圖請參考<a href="http://en.wikipedia.org/wiki/Yaw,_pitch,_and_roll">Yaw, pitch, and roll</a>. 由於掃描器都是垂直文件掃描, yaw 跟 pitch 都是 0.<br /></li><li>view(v): 相當於縮放比例<br /></li><li>x shift(d), y shift(e): 直跟橫方向的平移量<br /></ol><br /><br />注意事項:<br /><ul><br /><li>hugin 有些地方 (nona.exe, enblend.exe) 對中文檔名的處理有問題, 當 "Stitch now" 真的開始接圖時, 可能會出現檔案無法開啟的錯誤訊息. 為了避免剛辛苦工作要重來, 先存 project 檔, 用文字編輯器開 .pto 把裡頭的檔名改掉就好.<br /></li></ul></li>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com1tag:blogger.com,1999:blog-1329601581767992299.post-43141323146584914492008-12-05T19:27:00.000+08:002011-08-27T23:29:38.761+08:00用 hugin 接合多張掃描圖檔不知道用什麼 keyword 比較適當, search 找到的大多是接合全景圖的方案. 若是全景接合, autostitch 簡單易用, 效果又不錯.<br />
<br />
若是一般的平面圖檔接合, 目前只有找到 <a href="http://hugin.sourceforge.net/">hugin</a> 比較合用. <a href="http://hugin.sourceforge.net/tutorials/scans/en.shtml">Hugin tutorial — Stitching flat scanned images</a> 這篇有教學, 配合 0.7.0 版的 hugin, 我的經驗跟步驟如下:<br />
<ol><li> 先用其他軟體將 image 轉成相同方向, 否則沒辦法讓程式自動產生 control point. 同向就可以了, 不用轉正.<br />
</li>
<li> 在 image tab, add individual images, 載入全部的 image, HFOV 填 10.<br />
</li>
<li> 按 "create control points", 讓程式自動產生 control point<br />
</li>
<li> 簡單看一下 control point, 若是掃描文件, 比較容易有錯, delete 掉錯的點<br />
</li>
<li> 如果圖都是歪的, 自己增加 control point, type 選 horizontal 或 vertical line<br />
</li>
<li> 對比較正/比較好的 image 設 anchor reference, "anchor this image for position", "anchor this image for exposure"<br />
</li>
<li> 在 camera and lens tab, 在每張 image 上按 new lens, 確定 "lens no." 都不一樣<br />
</li>
<li> 在 optimizer tab, 選 custom parameter, 勾 reference image 之外的 v, d, e. <br />
</li>
<li> 比較不歪的當基準, 勾其他的 r. 若都是歪的, 前面設了 control point, 那就全勾.<br />
</li>
<li> 按 "optimize now", apply<br />
</li>
<li> 在 stitcher tab, projection 選 rectilinear. 按 "calculate field of view", "calculate optimal size". output 選 jpeg, quality 85<br />
</li>
<li> ctrl-p preview, 調整一下 center 跟 h-fov, v-fov<br />
</li>
<li> "Stitch now"<br />
</li>
</ol>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-37838600516420901842008-02-09T01:36:00.000+08:002008-02-10T01:21:37.010+08:00gmake remove intermediate file通常在 windows 寫簡單的程式時, 我習慣用 nmake, 雖然功能少, 但還堪用, 省得還得另外張羅或設定.<br />這幾天想用 suffixes 讓 make 自動推論來避免寫重複的 rule, 譬如像這樣(這是簡化過的例子)<br /><br /><code><pre>$ cat makefile<br />.SUFFIXES : .c .obj .exe<br />all: file.exe<br />.c.obj:<br /> touch $*.obj<br />.obj.exe:<br /> touch $*.exe<br /></pre></code><br />當新增加 file2.c 時, 我只要在 makefile 多加 file2.exe, 剩下的事 make 會自動搞定.<br /><br />然而事情沒我想像得那麼順利: 如果 file.obj 不存在, nmake 就會叫不知道怎麼生 file.exe. 也就是說, nmake 只能自動推論實際存在檔案的規則. 實在是相當差啊. 之後我原本想一些招數 workaround, 後來受不了乾脆換用 gmake.<br /><br />雖然 gmake 如預期完成工作. 但它竟然在工作完成後把 file.obj 砍了. 以下是在 FreeBSD 做的實驗:<br /><br /><code>$ gmake<br />touch file.obj<br />touch file.exe<br />rm file.obj<br />$ make # bsdmake<br />touch file.obj<br />touch file.exe<br /></code><br />可以看到 bsdmake 跟 gmake 行為不同. 查 <a href="http://www.gnu.org/software/make/manual/html_node/Chained-Rules.html">gmake 文件</a>才知道這是 feature, 可以用 <code>.SECONDARY</code> 語法避免砍檔.<br /><blockquote>intermediate files ...... if <code>make</code> <em>does</em> create <var>b</var> in order to update something else, it deletes <var>b</var> later on after it is no longer needed.<br />...... You can prevent automatic deletion of an intermediate file by marking it as a <dfn>secondary</dfn> file. To do this, list it as a prerequisite of the special target <code>.SECONDARY</code>.<br /><br /></blockquote>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0tag:blogger.com,1999:blog-1329601581767992299.post-67086007908005133592007-12-17T20:34:00.000+08:002007-12-18T00:26:44.347+08:00初試 waf最近在看 build system, 目前比較喜歡的是 <a href="http://code.google.com/p/waf/">waf</a>.<br /><br />原本偏好的是 <a href="http://www.scons.org/">scons</a>. 但 scons 只能在 top level build, 不能只在子目錄中 build subtree, 除非在 top level 中用 name 來指定 build 那個 component, 感覺不好用, 我已經習慣現在 recursive make 這種 style 的用法了.<br />加上當時許多文件都說 scons performance 不好(不知道新版修好沒).<br /><br />waf 的設計及語法我滿喜歡的. 唯一的問題是 depend on python. 雖然現在這應該不是大問題了.<br /><br />在 google 及實際使用 waf 之後, 簡短的結論是<br /><ul><li>waf 的開發還很 active, 我發的幾個 bug report 當天就修好了, 從 svn log 來看也算 active<br /></li><li>由於很少 project 用, 因此可能有些問題要有人遇到才知道.</li><li>waf 對各 language/tool 的支援不一定夠成熟/portable, 尤其是非 c/c++ 系列 tool 在 windows 平台可能會是個問題.</li><li>waf 的 tool 實作採用類似 shell variable expansion 的作法, 因此目錄或檔名有空白會有問題. 短期內看來不會改 (README 說的).</li><li>我的建議是可以在以 unix 為主的 c/c++ 小 project 試用看看. 若是複雜 build rule 的 project, 又想超級 portable, 現在用還太早.<br /></li></ul>kcwuhttp://www.blogger.com/profile/13570088245905321375noreply@blogger.com0