<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-249290266596149244</id><updated>2026-05-14T15:27:11.026+08:00</updated><category term="Books"/><category term="Android"/><category term="Android-OpenCV"/><category term="iOS"/><category term="Machine Learning"/><category term="Mahout"/><category term="Startups"/><category term="XCode"/><category term="ARM"/><category term="AWS"/><category term="Caffe"/><category term="Deep Learning"/><category term="Dropbox"/><category term="Espresso"/><category term="GAE"/><category term="GCC"/><category term="OpenGL"/><category term="Xilinx"/><category term="ZYNQ"/><category term="coffee"/><category term="iOS-OpenCV"/><category term="tools"/><title type='text'>Playground</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-7838071543398594580</id><published>2016-09-02T16:59:00.000+08:00</published><updated>2016-09-02T16:59:55.769+08:00</updated><title type='text'>SMIMS VILS Real-time Indoor Location systems (RTLS)</title><content type='html'>
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/XO0Oqpg4d28&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SMIMS VILS (VeriPrecision Indoor Real-time Location System)&lt;br /&gt;
&lt;br /&gt;
VILS is a UWB device based on the DecaWave real­time location systems (RTLS) chipset.&lt;br /&gt;
&lt;br /&gt;
The device incorporates an ARM processor, UWB transceiver and nine-axis MEMS into a very compact low power design.&lt;br /&gt;
&lt;br /&gt;
VILS is also aim at Internet of Things (IoT) applications.&lt;br /&gt;
&lt;br /&gt;
It provides cost effective RTLS solutions with precise indoor and outdoor positioning system.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://vils-iot-datacenter.appspot.com/&quot;&gt;SMIMS Real-time Indoor Location systems (RTLS)&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/7838071543398594580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2016/09/smims-vils-real-time-indoor-location.html#comment-form' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/7838071543398594580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/7838071543398594580'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2016/09/smims-vils-real-time-indoor-location.html' title='SMIMS VILS Real-time Indoor Location systems (RTLS)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/XO0Oqpg4d28/default.jpg" height="72" width="72"/><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-350069041646845055</id><published>2015-06-20T10:42:00.002+08:00</published><updated>2015-06-20T10:42:44.106+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="coffee"/><category scheme="http://www.blogger.com/atom/ns#" term="Espresso"/><title type='text'>Lulu&#39;s Hand Espresso</title><content type='html'>2年來每個週末早晨, 都會自己手沖咖啡, 純粹就是喜歡咖啡散發的香氣,&lt;/br&gt;
但是對於咖啡並沒有太多研究,幾度c的水, 幾克的咖啡, 對我來說太複雜.&lt;/br&gt;
不同的豆子也買過, 但是依我的程度跟本分不出差別,所以都到義美買,&lt;/br&gt;
因為回家路上會經過很方便.&lt;/br&gt;
 &lt;/br&gt;
最近入手取代手沖的的&lt;a href=&quot;https://www.facebook.com/pages/Lulus-Hand-coffee-brewing-kit/1430005520614466&quot;&gt; Lulu&#39;s Hand&lt;/a&gt; 可以不用一次性的濾紙,&lt;/br&gt;
造型也不錯, 由於我沒買手沖壺, 都是直接拿水壺手沖, 所以剛好可以一次解決.&lt;/br&gt;
 &lt;/br&gt;
Espresso一直都是在歐洲旅遊時用餐必點的, 那種強烈的果酸在舌根爆炸的震憾,&lt;/br&gt;
可以持續在口中迴盪,雖然小小一杯, 但是可以啜飲許久,&lt;/br&gt;
所以嘗試了一下如何用Lulu&#39;s Hand泡出Espresso.&lt;/br&gt;
磨豆機因為太貴了, 所以我是用可調粗細的日製手搖磨豆機.&lt;/br&gt;
步驟如下:&lt;/br&gt;
1.咖啡粉, 鎖緊後退2格, 豆量約8分滿, 幾克就不知道了, 從沒量過.&lt;/br&gt;
2.鋪在Lulu&#39;s Hand下層不鏽剛濾網上, 鋪起來大約是7分滿.&lt;/br&gt;
3.在上層放水到200ml刻度.&lt;/br&gt;
4.調整水量到壓克力窗的一半, 關閉上層水.&lt;/br&gt;
5.此時就讓水自動萃取咖啡, 直到水量達到壓克力窗下緣.&lt;/br&gt;
6.移開Lulu&#39;s Hand, 即可享用.&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwU_2Xrr-jNRlkDcxwzKqsMgu1eGQ2GOBZsN3i5emnNIJFNZsoZqHiGtPi9thXuAzUPKoLM-uIT-cvTWVZUijl14jZgiv7oDjA8T7qMJ5eoufNohX4vENVRmvg0W7RZc6YSMCyiD54aQ8/s1600/Lulu%2527s+Hand+Espresso-1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwU_2Xrr-jNRlkDcxwzKqsMgu1eGQ2GOBZsN3i5emnNIJFNZsoZqHiGtPi9thXuAzUPKoLM-uIT-cvTWVZUijl14jZgiv7oDjA8T7qMJ5eoufNohX4vENVRmvg0W7RZc6YSMCyiD54aQ8/s320/Lulu%2527s+Hand+Espresso-1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
Lulu&#39;s Hand Espresso 用具
&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTAF7Chhxvh8Qf0T3ADUe9MUbus3Nc2p4BddAJt5Jf54jxYc0kxiI0o480rkaIHTz_8ztnmdKpHdWJoR5Z0IrYKM-iacDG220ov0Z7uFtezwz_yD7DPC5to9SZs2lRfC5KX1MHOBfPcow/s1600/Lulu%2527s+Hand+Espresso-2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTAF7Chhxvh8Qf0T3ADUe9MUbus3Nc2p4BddAJt5Jf54jxYc0kxiI0o480rkaIHTz_8ztnmdKpHdWJoR5Z0IrYKM-iacDG220ov0Z7uFtezwz_yD7DPC5to9SZs2lRfC5KX1MHOBfPcow/s320/Lulu%2527s+Hand+Espresso-2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
鎖緊後退2格, 豆量約8分滿, 幾克就不知道了, 從沒量過.
&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnM_Bt5iNFr6XTQYfO1o08GhfM8IYGklrlInwN-J05YcDomGl9lr6PiUS9tiHc7XdUaFsChDa_mmSH-lrXB1wmSeuhvdXrM-K1-K4VOlAYe8RbotLhieJ97YUd4VsjwxW8L05GUZ2Yn_s/s1600/Lulu%2527s+Hand+Espresso-3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnM_Bt5iNFr6XTQYfO1o08GhfM8IYGklrlInwN-J05YcDomGl9lr6PiUS9tiHc7XdUaFsChDa_mmSH-lrXB1wmSeuhvdXrM-K1-K4VOlAYe8RbotLhieJ97YUd4VsjwxW8L05GUZ2Yn_s/s320/Lulu%2527s+Hand+Espresso-3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
鋪在Lulu&#39;s Hand下層不鏽剛濾網上, 鋪起來大約是7分滿.
&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxACvYzVUp9zYljCZhW8pazUhrJ5TP51HwDoUGWYJ-hv3LOki09yrWwY9Js6O50qdHSqSX1hx6wX6DAogl1pwSJbHVGclbvZCX1Ipz5TmfL3Z4XGjWUh70rxgA42xDki6ZFEQxar6p0cM/s1600/Lulu%2527s+Hand+Espresso-4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxACvYzVUp9zYljCZhW8pazUhrJ5TP51HwDoUGWYJ-hv3LOki09yrWwY9Js6O50qdHSqSX1hx6wX6DAogl1pwSJbHVGclbvZCX1Ipz5TmfL3Z4XGjWUh70rxgA42xDki6ZFEQxar6p0cM/s320/Lulu%2527s+Hand+Espresso-4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
調整水量到壓克力窗的一半, 關閉上層水.
&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKqcLLpwg_JE4BtCIr7yznK37NQp_zHG-WB5I7DG4kOEi3hw4-GCa9zGO5r_AU92v0yzjFqWdYP2OQouWcu0JSCBhMPzbya4A7fUvDzubZWL9MnBzdbRHRdghfMmiWuM7GiXAJ3Tu13R8/s1600/Lulu%2527s+Hand+Espresso-5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKqcLLpwg_JE4BtCIr7yznK37NQp_zHG-WB5I7DG4kOEi3hw4-GCa9zGO5r_AU92v0yzjFqWdYP2OQouWcu0JSCBhMPzbya4A7fUvDzubZWL9MnBzdbRHRdghfMmiWuM7GiXAJ3Tu13R8/s320/Lulu%2527s+Hand+Espresso-5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
讓水自動萃取咖啡, 直到水量達到壓克力窗下緣.
&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIDUhR6KcUJAnoqz3Q5ybI45bTTyS8HHUwizn2r9XLZ8rYornYfRSdWPa3En-EUZbDUDtGXfY8e1Y1XW1ZNySyOPTFwinz7UH1wd867HVmE2ZRgD3B3Qc0Jpn_x90DnzD1Z1B3-VQYVXU/s1600/Lulu%2527s+Hand+Espresso-6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIDUhR6KcUJAnoqz3Q5ybI45bTTyS8HHUwizn2r9XLZ8rYornYfRSdWPa3En-EUZbDUDtGXfY8e1Y1XW1ZNySyOPTFwinz7UH1wd867HVmE2ZRgD3B3Qc0Jpn_x90DnzD1Z1B3-VQYVXU/s320/Lulu%2527s+Hand+Espresso-6.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
即可享用Lulu&#39;s Hand Espresso.
&lt;/br&gt;
&lt;/br&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/350069041646845055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2015/06/lulus-hand-espresso.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/350069041646845055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/350069041646845055'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2015/06/lulus-hand-espresso.html' title='Lulu&#39;s Hand Espresso'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwU_2Xrr-jNRlkDcxwzKqsMgu1eGQ2GOBZsN3i5emnNIJFNZsoZqHiGtPi9thXuAzUPKoLM-uIT-cvTWVZUijl14jZgiv7oDjA8T7qMJ5eoufNohX4vENVRmvg0W7RZc6YSMCyiD54aQ8/s72-c/Lulu%2527s+Hand+Espresso-1.jpg" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-4951177511761663493</id><published>2015-02-17T13:34:00.001+08:00</published><updated>2015-12-04T13:21:44.996+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="GAE"/><title type='text'>How to create Google App Engine eclipse project with frontend module and backend module</title><content type='html'>
In this article, i will create a Google App Engine eclipse project support frontend module and backend module.&lt;/br&gt;
Why i doing this, because GAE console keep annoying me whit this.
&lt;/br&gt;


&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauCmhCmTM2w7MjGxB7mvuewkWpZ-k7Uwg1xZpr1oG8sEqfL61sIPMJ0l9wpQISyE2WpHx-o57gO7tWNGbb87DyvgR-txZjKYDQOA8G8FOPwb5I1KcfBoWoNIJKT95tYb29EadAqtTcB0/s1600/+Backends_deprecated+.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauCmhCmTM2w7MjGxB7mvuewkWpZ-k7Uwg1xZpr1oG8sEqfL61sIPMJ0l9wpQISyE2WpHx-o57gO7tWNGbb87DyvgR-txZjKYDQOA8G8FOPwb5I1KcfBoWoNIJKT95tYb29EadAqtTcB0/s640/+Backends_deprecated+.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&quot;This application uses Backends, a deprecated feature that has been replaced by Modules, which offers additional functionality. Please convert your backends to modules as described at: Python | Java | Go&quot;
&lt;/br&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Prepare eclipse environment
&lt;/br&gt;
Switch eclipse to Java EE perspective.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYpYA6jOYxn0vmZG89FsbeX_Wai-dgnuD_degA4MWpogECAcSquXQIkagS5HMnLbQwhqS2Z0LIhc-HvSM8eOcq7NXZ0vDLj6XRGi2AKCAq_a0pugctFjlM9-gh_WiTZpi4qmx9ipbpyng/s1600/J2EE.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYpYA6jOYxn0vmZG89FsbeX_Wai-dgnuD_degA4MWpogECAcSquXQIkagS5HMnLbQwhqS2Z0LIhc-HvSM8eOcq7NXZ0vDLj6XRGi2AKCAq_a0pugctFjlM9-gh_WiTZpi4qmx9ipbpyng/s400/J2EE.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;&lt;/span&gt;Create new Enterprise Application Project
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfEs_PgLTvxvsI0a4-kPWpf_2Yc8PRqQpD6E_0anmbXhLsnatZsdBaUy7ejpfo_RFrk6Sgs-p_QLn7qW9DMxF8SXX6skG51EJzOP_K6atgzhBC3-eYEdqnbM9vHiQPxjTqrSBPsbrTx6M/s1600/NewEAR.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfEs_PgLTvxvsI0a4-kPWpf_2Yc8PRqQpD6E_0anmbXhLsnatZsdBaUy7ejpfo_RFrk6Sgs-p_QLn7qW9DMxF8SXX6skG51EJzOP_K6atgzhBC3-eYEdqnbM9vHiQPxjTqrSBPsbrTx6M/s1600/NewEAR.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
Setting Project name and target runtime.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC7FPVIBD6-dMWs2XWhPavGlMtoMZDiEK4Z5ig0apffgrdp-BEfWWXk8hpavqBkRUr_15tRpqp-h61PNn3ojd6RASRh2H2aJi00TiFIzSzj58gPLSy-40hEtw_v6kanWzTfXgrhI1pbq8/s1600/NewEAR1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC7FPVIBD6-dMWs2XWhPavGlMtoMZDiEK4Z5ig0apffgrdp-BEfWWXk8hpavqBkRUr_15tRpqp-h61PNn3ojd6RASRh2H2aJi00TiFIzSzj58gPLSy-40hEtw_v6kanWzTfXgrhI1pbq8/s1600/NewEAR1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Select existed modules.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVa4QQ7FIkzqsOIuSeGORDjnxRniKVVWZ9TY2xxAcj0oTfazmMC4K-vAJweCqLl-ljyCBc-Wq4uKV1J0ID-9kxANUdNWOEIwY6K00YywOTRoFAcc9nogOpPPNWIQUGd2n-2rP9kb6eFxA/s1600/NewEAR2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVa4QQ7FIkzqsOIuSeGORDjnxRniKVVWZ9TY2xxAcj0oTfazmMC4K-vAJweCqLl-ljyCBc-Wq4uKV1J0ID-9kxANUdNWOEIwY6K00YywOTRoFAcc9nogOpPPNWIQUGd2n-2rP9kb6eFxA/s1600/NewEAR2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Setting Google App engine Application ID.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkgsq_c-IYvaweupf3N2iYGQ1wZO_oQU3Ty_RBTwUBcSWMeWGkHEDZ5t1f0AqWhWjGq1ToTJ-Vnf1PIplegCIKb_FVZg5RH4Z94ivHuYYJTdmnVCdPxk8jWLXvNbrbkuEW-jVaZDQl3dE/s1600/NewEAR3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkgsq_c-IYvaweupf3N2iYGQ1wZO_oQU3Ty_RBTwUBcSWMeWGkHEDZ5t1f0AqWhWjGq1ToTJ-Vnf1PIplegCIKb_FVZg5RH4Z94ivHuYYJTdmnVCdPxk8jWLXvNbrbkuEW-jVaZDQl3dE/s1600/NewEAR3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
You may has this error message after create a new project.&lt;/br&gt;
&quot;vc-complex-type.2.4.b: The content of element &#39;application&#39; is not complete. One of &#39;{&quot;http://java.sun.com/xml/ns/javaee&quot;:display-name, &quot;http://java.sun.com/xml/ns/javaee&quot;:icon, &quot;http://java.sun.com/xml/ns/javaee&quot;:module}&#39; is expected.&quot;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjydWVcGN0IcZ3W7Bnlc2Rhkfag6E1XtlNhMaSN2tlTydAyVneSgHoi0MPDcGLpTkjcKLseqSjoItQwcd4sVPQi6QHZrQLGpI37Y0TPrF1hCTUGIrs6xinjSURJx2JAgxN9Tq_6T3g1Mq0/s1600/EAR_errMsg.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjydWVcGN0IcZ3W7Bnlc2Rhkfag6E1XtlNhMaSN2tlTydAyVneSgHoi0MPDcGLpTkjcKLseqSjoItQwcd4sVPQi6QHZrQLGpI37Y0TPrF1hCTUGIrs6xinjSURJx2JAgxN9Tq_6T3g1Mq0/s1600/EAR_errMsg.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Change the xsi:schemaLocation content from
&lt;pre class=&quot;brush:cpp&quot;&gt;
 xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee 
       http://java.sun.com/xml/ns/javaee/application_5.xsd&quot;&gt;
&lt;/pre&gt; 
&lt;/br&gt;
&lt;/br&gt;
To
&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
 xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee;
                     http://java.sun.com/xml/ns/javaee/application_5.xsd&quot;&gt;
&lt;/pre&gt; 
&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;Create new Dynamic Web Project for frontend default module
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbz_uaVxjV9aoHQDGk18SF8UIGD5TN7THlRM9uLUOl73JUj6mdWwS2WD6bgXOju3Y8fQP3U4jN5yCCwhcJBZgf_JqA-SLMMN8zoxx9liYnJyQ8tQZ8wLOz8kR1KfRq6HtofQa3PhQc8lQ/s1600/NewDWP1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbz_uaVxjV9aoHQDGk18SF8UIGD5TN7THlRM9uLUOl73JUj6mdWwS2WD6bgXOju3Y8fQP3U4jN5yCCwhcJBZgf_JqA-SLMMN8zoxx9liYnJyQ8tQZ8wLOz8kR1KfRq6HtofQa3PhQc8lQ/s1600/NewDWP1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
Setting Project name and add this project to EAR project.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj486LX1hZozvsIxBic9Nn5jFR9cKdh8iMyD7MnHjAWVGHMVSk0z_U5CgqBsd7-68NS1raKJEhmG1e3sqHzEaQBVTZ2b25XsPa-kgp049-aNU4h5eeXcL6ePFeJazIDsK7RuWVT-55MoXw/s1600/NewDWP2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj486LX1hZozvsIxBic9Nn5jFR9cKdh8iMyD7MnHjAWVGHMVSk0z_U5CgqBsd7-68NS1raKJEhmG1e3sqHzEaQBVTZ2b25XsPa-kgp049-aNU4h5eeXcL6ePFeJazIDsK7RuWVT-55MoXw/s1600/NewDWP2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Setting source folder.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrDDShNXBTvIXqavXaFpiBTN4iMpq79aksUpwULAnjbwniEgq_-KpsDC0ZWmYeWBQGFhtQz_uxmdNqNVx3lrntA7LCJip9ZqxNoJO34KULF2ZTw39VJWNyE3hvAuag9iZ0L1ELMN1VRBg/s1600/NewDWP3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrDDShNXBTvIXqavXaFpiBTN4iMpq79aksUpwULAnjbwniEgq_-KpsDC0ZWmYeWBQGFhtQz_uxmdNqNVx3lrntA7LCJip9ZqxNoJO34KULF2ZTw39VJWNyE3hvAuag9iZ0L1ELMN1VRBg/s1600/NewDWP3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Configure web module setting. Set the Context root as &quot;default&quot;, because GAE need a default front module name as &quot;default&quot;.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxmgdMXeL7saK5l83GL9KU1ov8MaNsTgQdXmvFGyjSR9Ctkv6JAvBAEyMZn-4l1W58SyT62hDoJwwCOYGe10qiEgZLDOmAXablT7Pnr36_dOvkMh_xql4Xq69iiuNo2Un7Ei6KXZpWHoE/s1600/NewDWP4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxmgdMXeL7saK5l83GL9KU1ov8MaNsTgQdXmvFGyjSR9Ctkv6JAvBAEyMZn-4l1W58SyT62hDoJwwCOYGe10qiEgZLDOmAXablT7Pnr36_dOvkMh_xql4Xq69iiuNo2Un7Ei6KXZpWHoE/s1600/NewDWP4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Configure Google App Engine. Again, GAE needs a module named &quot;default&quot;.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLQH7QMtMLmPyr_ZK1ppPOYQy9zjXLFKVkAZILFpx9PmNdTOF1GuD592Cp4ZjQf58UBdHAGvgrkKmdLX8C0ih5KSRXOeuo2-RTb5HDGYwARzuB2D-xxm5e3eOLLJJxor-pz1c43jHzMjs/s1600/NewDWP5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLQH7QMtMLmPyr_ZK1ppPOYQy9zjXLFKVkAZILFpx9PmNdTOF1GuD592Cp4ZjQf58UBdHAGvgrkKmdLX8C0ih5KSRXOeuo2-RTb5HDGYwARzuB2D-xxm5e3eOLLJJxor-pz1c43jHzMjs/s1600/NewDWP5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
The default frontend module is created.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSekB9u-FEJ9_FVIvC2Mdp1K9yoelhzbSg01jMRCOEyFt3MWIPS_uwxcxpwcySeeesQPektfGk-h35dcjD5U8AfsHYLLpmMxTXOAI-F0d7HYoIuus5EDiByrMi-FpCEC37c52TgZpO8F4/s1600/projecttree1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSekB9u-FEJ9_FVIvC2Mdp1K9yoelhzbSg01jMRCOEyFt3MWIPS_uwxcxpwcySeeesQPektfGk-h35dcjD5U8AfsHYLLpmMxTXOAI-F0d7HYoIuus5EDiByrMi-FpCEC37c52TgZpO8F4/s1600/projecttree1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step4:&lt;/b&gt;&lt;/span&gt;Create new Dynamic Web Project for backend module
&lt;/br&gt;
&lt;/br&gt;
Setting Project name and add this project to EAR project.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4cwraYTA7stzSk941h6GnI7WbY_gWqq9uY88NjUqt_cFQTfgIOUNISqOmX29EsFUZMMAkAWlYPqysR59j0Qs1nhIkLXsAEjgtCbUihrLQhX6x8lxHndguE0_qWDACBuV5J8DMICut9mQ/s1600/Newback1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4cwraYTA7stzSk941h6GnI7WbY_gWqq9uY88NjUqt_cFQTfgIOUNISqOmX29EsFUZMMAkAWlYPqysR59j0Qs1nhIkLXsAEjgtCbUihrLQhX6x8lxHndguE0_qWDACBuV5J8DMICut9mQ/s1600/Newback1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Setting source folder.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipxBr3vRPjPvETkspWjw198v3dn3nOo5H7yQT2aKwMgYMjc8mMWX8UhdsULoYUdQoyYnXeUzTQi4iL6y1M9pB92To85f0Ee1nlPfI-KV8oYx4Kg2IVsPI6XAOhX5YM3t6eEqsRx6uZemw/s1600/Newback2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipxBr3vRPjPvETkspWjw198v3dn3nOo5H7yQT2aKwMgYMjc8mMWX8UhdsULoYUdQoyYnXeUzTQi4iL6y1M9pB92To85f0Ee1nlPfI-KV8oYx4Kg2IVsPI6XAOhX5YM3t6eEqsRx6uZemw/s1600/Newback2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Configure web module setting.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRfm4ML_rGkwdBbtvZrEdeyE9T0eLW7QQSbF0vW4K9VOPB0rl_L9L2hVeqhVJWEJOSyA_QD5BjqK6nGEMuVdOQpnW7zbGww1_RfkQ7DPxqFAXAw1kh5Y0HA-drAGAZbKY5gVoRNkV-Hug/s1600/Newback3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRfm4ML_rGkwdBbtvZrEdeyE9T0eLW7QQSbF0vW4K9VOPB0rl_L9L2hVeqhVJWEJOSyA_QD5BjqK6nGEMuVdOQpnW7zbGww1_RfkQ7DPxqFAXAw1kh5Y0HA-drAGAZbKY5gVoRNkV-Hug/s1600/Newback3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Configure Google App Engine.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hwSvM7oRmb0OA2wiPYwNu7YFZqlK0YFmBLTIkMCi7alL5KGAJkj41oA39CL2iwTS1QtBEhna_3xQYlhgdFgi8vG5amSYVM28Yums4kvkk789YlnKRCI1JquiVoKUGSBQb9DYlbHcc9M/s1600/Newback4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hwSvM7oRmb0OA2wiPYwNu7YFZqlK0YFmBLTIkMCi7alL5KGAJkj41oA39CL2iwTS1QtBEhna_3xQYlhgdFgi8vG5amSYVM28Yums4kvkk789YlnKRCI1JquiVoKUGSBQb9DYlbHcc9M/s1600/Newback4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
The modules are created.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsgw1LIA14F_ztm6-MKS4s1BXe6OOXMBnA55tDlbz3BcAsfzBWmQfdATAv33bvBEu_gFPMPa3YiyrgS_vIHW7f4i345lyPx8owxm6qDnx7z5nYOwmvBIgJEqI2HTqay7OrFgq3sjOwj3c/s1600/projecttree3.jpg.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsgw1LIA14F_ztm6-MKS4s1BXe6OOXMBnA55tDlbz3BcAsfzBWmQfdATAv33bvBEu_gFPMPa3YiyrgS_vIHW7f4i345lyPx8owxm6qDnx7z5nYOwmvBIgJEqI2HTqay7OrFgq3sjOwj3c/s1600/projecttree3.jpg.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;
Modify the GAEJModuleBackend/WebContent/WEB-INF/appengine-web.xml to support the backend instance.&lt;/br&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;
 
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;appengine-web-app xmlns=&quot;http://appengine.google.com/ns/1.0&quot;&gt;
  &lt;application&gt;gaejmoduletest&lt;/application&gt;
  &lt;module&gt;backend&lt;/module&gt;
  &lt;version&gt;2&lt;/version&gt;
 &lt;threadsafe&gt;true&lt;/threadsafe&gt;

  &lt;!--  ikki add  --&gt;
  &lt;instance-class&gt;B1&lt;/instance-class&gt;
  &lt;basic-scaling&gt;
    &lt;max-instances&gt;11&lt;/max-instances&gt;
    &lt;idle-timeout&gt;10m&lt;/idle-timeout&gt;
  &lt;/basic-scaling&gt;
  
  &lt;!-- Configure java.util.logging --&gt;
  &lt;system-properties&gt;
    &lt;property name=&quot;java.util.logging.config.file&quot; value=&quot;WEB-INF/logging.properties&quot;/&gt;
  &lt;/system-properties&gt;
&lt;/appengine-web-app&gt;
&lt;/pre&gt;

Create background threads to run the instance in backend.We modify the GAEJModuleBackendServlet.java.&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
public class GAEJModuleBackendServlet extends HttpServlet 
{
 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException 
 {
  Thread thread = ThreadManager.createBackgroundThread(
  new Runnable() 
  {
   public void run() 
   {
    try 
    {
     Thread.sleep(10);
    } 
    catch (InterruptedException ex) 
    {
     throw new RuntimeException(&quot;Exception:&quot;, ex);
    }
   }
  });
  thread.start();
 }
}
&lt;/pre&gt; 



&lt;/br&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step4:&lt;/b&gt;&lt;/span&gt;Setting remote server
&lt;/br&gt;
&lt;/br&gt;
Click the link to create remote server.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXhKNsFAX0EjejuU8G7Q_naFeh1BxSMwQvExFrR8egE_i8mFuwG6S3AnuFUA7NFbspjgRxD3-5lvV2MlR_NE90jU7EKzYHYS819F8YSXU0kVB-e3qPJWulB5A24wWXAgVtjt4UH-eqGPc/s1600/createserver1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXhKNsFAX0EjejuU8G7Q_naFeh1BxSMwQvExFrR8egE_i8mFuwG6S3AnuFUA7NFbspjgRxD3-5lvV2MlR_NE90jU7EKzYHYS819F8YSXU0kVB-e3qPJWulB5A24wWXAgVtjt4UH-eqGPc/s1600/createserver1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Define a new server.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJePxgjKjFX2yUACA_hCVGEHueVWv4H0pIL0nbeaBzXcVg6WcEchh3r6UIPMg5Xg0bnMgNmSUgNtops-QQznHvFYJ1lQb0iph8EUCHPB2MagiNmOLdBBkxIsBmAOE7wM6-UjRie5kHg54/s1600/createserver2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJePxgjKjFX2yUACA_hCVGEHueVWv4H0pIL0nbeaBzXcVg6WcEchh3r6UIPMg5Xg0bnMgNmSUgNtops-QQznHvFYJ1lQb0iph8EUCHPB2MagiNmOLdBBkxIsBmAOE7wM6-UjRie5kHg54/s1600/createserver2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Configure server.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL3A205t3IyJLymHXkVxlMZuuK-bWtaQlF82xn6kKMmnKipahvWeVpJ16UCKgW9lbuIhWyG5qmlzi3rzweJaS5KKHV8acOeqdVauQNBXGCFwBhot5-_7p51o8_ZrOBGoJoLkXgbishmeo/s1600/createserver3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL3A205t3IyJLymHXkVxlMZuuK-bWtaQlF82xn6kKMmnKipahvWeVpJ16UCKgW9lbuIhWyG5qmlzi3rzweJaS5KKHV8acOeqdVauQNBXGCFwBhot5-_7p51o8_ZrOBGoJoLkXgbishmeo/s1600/createserver3.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
Add server.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStje3vo3yaR3lyTBuLNrricJZaEVDPCWfXdqfzoVklRYwuNUr9E6iSV51vZ9kWsD7csETqk0YS1hwQrrIWiFWbecg379TzSLLL3TM6tDXc2xnNJt3ipb9ee3W1n-IjZ0HwDRdwbB97OI/s1600/createserver4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStje3vo3yaR3lyTBuLNrricJZaEVDPCWfXdqfzoVklRYwuNUr9E6iSV51vZ9kWsD7csETqk0YS1hwQrrIWiFWbecg379TzSLLL3TM6tDXc2xnNJt3ipb9ee3W1n-IjZ0HwDRdwbB97OI/s1600/createserver4.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
We created a App Engine localhost server.&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCfONOK6HcB2lITp6_QPPqiUFy38Lwffrkq7bCYOkn7aLDZs76w-rTUPpmFPy6ilv3Z2e3Wz6NrJv3gnvd_lk2JQQd_yiqlO3EGsLnvw3OlMugrBdhHi3wT7-EQJMSiT0X-EzIxBVC-3A/s1600/createserver5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCfONOK6HcB2lITp6_QPPqiUFy38Lwffrkq7bCYOkn7aLDZs76w-rTUPpmFPy6ilv3Z2e3Wz6NrJv3gnvd_lk2JQQd_yiqlO3EGsLnvw3OlMugrBdhHi3wT7-EQJMSiT0X-EzIxBVC-3A/s1600/createserver5.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/br&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step5:&lt;/b&gt;&lt;/span&gt;Uploading to Google App Engine
&lt;/br&gt;
&lt;/br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSPsDZovZBdmU79nf97S5n-YehU-AjF79FwVY73yiVai0Wzbnuc_p_ANxJLWne8aaZOABseWX0-BSAOlCi_GXCquuAN9q2H2dJ7AkCaR3V6anNtgX5vpff7LsVrAe0yrXa59w4r-2qWyw/s1600/DeployToServer.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSPsDZovZBdmU79nf97S5n-YehU-AjF79FwVY73yiVai0Wzbnuc_p_ANxJLWne8aaZOABseWX0-BSAOlCi_GXCquuAN9q2H2dJ7AkCaR3V6anNtgX5vpff7LsVrAe0yrXa59w4r-2qWyw/s1600/DeployToServer.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;


&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/4951177511761663493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2015/02/how-to-create-google-app-engine-eclipse.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4951177511761663493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4951177511761663493'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2015/02/how-to-create-google-app-engine-eclipse.html' title='How to create Google App Engine eclipse project with frontend module and backend module'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauCmhCmTM2w7MjGxB7mvuewkWpZ-k7Uwg1xZpr1oG8sEqfL61sIPMJ0l9wpQISyE2WpHx-o57gO7tWNGbb87DyvgR-txZjKYDQOA8G8FOPwb5I1KcfBoWoNIJKT95tYb29EadAqtTcB0/s72-c/+Backends_deprecated+.jpg" height="72" width="72"/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-3034765486039479547</id><published>2015-01-20T11:20:00.003+08:00</published><updated>2015-01-21T10:25:25.129+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Caffe"/><category scheme="http://www.blogger.com/atom/ns#" term="Deep Learning"/><title type='text'>C++ Prediction Example With Caffe Deep Learning</title><content type='html'>In this example, we will using cifar10_quick_iter_5000.caffemodel as pre-trained model. And modified cifar10_quick_train_test.prototxt to get argmax for prediction.
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Download the example from &lt;a href=&#39;https://github.com/ikkiChung/Prediction-Example-With-Caffe/&#39;&gt;Github&lt;/a&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;&lt;/span&gt;Copy files to caffe master directory. &lt;/br&gt;
Copy files to your caffe master directory. keep the same directories and subdirectories.&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
 
    caffe-master/examples/images/cat10.png
    caffe-master/examples/images/dog10.png
    caffe-master/examples/images/truck10.png
    caffe-master/examples/prediction_example/file_list.txt
    caffe-master/examples/prediction_example/prediction_example.prototxt
    caffe-master/tools/prediction_example.cpp
 &lt;/pre&gt; 
&lt;/br&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;Compile Example. &lt;/br&gt;
We assume you are ine the caffe master directory, just use make to compile our example.&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
    make
&lt;/pre&gt; 
The caffe makefile will automatic find the new example and copy the result to build directory.&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
    caffe-master ikki$ ls ./build/tools/prediction_example*
    ./build/tools/prediction_example
    ./build/tools/prediction_example.bin
    ./build/tools/prediction_example.o
    ./build/tools/prediction_example.o.warnings.txt
&lt;/pre&gt; 
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step4:&lt;/b&gt;&lt;/span&gt;Prediction&lt;/br&gt;
Just run the example.&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
    ./build/tools/prediction_example
    I0120 11:02:45.297869 2008834832 prediction_example.cpp:52] Result size: 3
    I0120 11:02:45.297899 2008834832 prediction_example.cpp:55] Blob size: 0
    I0120 11:02:45.297905 2008834832 prediction_example.cpp:58] -------------
    I0120 11:02:45.297910 2008834832 prediction_example.cpp:59]  prediction :  
    I0120 11:02:45.297919 2008834832 prediction_example.cpp:69] ------------------------------------------------------
    I0120 11:02:45.297924 2008834832 prediction_example.cpp:73] Pattern:0 class:5 Prob=2.69744e-06
    I0120 11:02:45.297940 2008834832 prediction_example.cpp:73] Pattern:1 class:3 Prob=4.0121e-05
    I0120 11:02:45.297948 2008834832 prediction_example.cpp:73] Pattern:2 class:9 Prob=0.00531694
    I0120 11:02:45.297956 2008834832 prediction_example.cpp:75] -------------
&lt;/pre&gt;&lt;/br&gt;
For run on GPU device.
&lt;pre class=&quot;brush:cpp&quot;&gt;
    ./build/tools/prediction_example GPU 0
&lt;/pre&gt;&lt;/br&gt;
Here are the classes in the &lt;a href=&#39;http://www.cs.toronto.edu/~kriz/cifar.html&#39;&gt;CIFAR-10&lt;/a&gt; dataset:&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
    class:0 airplane
    class:1 automobile
    class:2 bird
    class:3 cat
    class:4 deer
    class:5 dog
    class:6 frog
    class:7 horse
    class:8 ship
    class:9 truck
&lt;/pre&gt;&lt;/br&gt;

&lt;/br&gt;

&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/3034765486039479547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2015/01/c-prediction-example-with-caffe-deep.html#comment-form' title='27 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3034765486039479547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3034765486039479547'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2015/01/c-prediction-example-with-caffe-deep.html' title='C++ Prediction Example With Caffe Deep Learning'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>27</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-1175908243206978360</id><published>2014-12-10T14:30:00.000+08:00</published><updated>2014-12-10T14:30:03.201+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ARM"/><category scheme="http://www.blogger.com/atom/ns#" term="GCC"/><category scheme="http://www.blogger.com/atom/ns#" term="Xilinx"/><category scheme="http://www.blogger.com/atom/ns#" term="ZYNQ"/><title type='text'>How To Build GCC ARM Cross-Compiler for Xilinx ZYNQ on ZC702 </title><content type='html'>&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Intro:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre&gt;
   In this How To we are going to build an ARM cross-compiler based upon GCC 4.8.2.&lt;/br&gt;
   Since the original tool chain does not support OpenMP. I create my GCC to support OpenMP and Neon.&lt;/br&gt;
   Reference from &lt;a href=&quot;http://how-to-build-for-arm.wikispaces.com/gcc-4_8_2&quot;&gt;this&lt;/a&gt;.
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Tar Balls:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre&gt;
   binutils-2.24.tar.bz2
   glibc-2.18.tar.gz
   gcc-4.8.2.tar.bz2
   gmp-4.3.2.tar.bz2
   mpfr-2.4.2.tar.bz2
   mpc-0.8.1.tar.gz
   xlnx-3.14  --&gt; copy from /opt/pkg/petalinux-v2014.2-final/components/linux-kernel/xlnx-3.14
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Create a Workspace:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
$ export SRCDIR=~/workbench/gcc-4.8.2/xtools/src
$ mkdir -pv ~/workbench/gcc-4.8.2/xtools
$ mkdir $SRCDIR
$ cd $SRCDIR
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Gather the Sources:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
binutils
$ tar -pxzf binutils-2.24.tar.gz

glibc
$ tar -pxzf glibc-2.18.tar.gz

gcc
$ tar -pxjf gcc-4.8.2.tar.bz2
$ cd gcc-4.8.2
$ tar -pxjf ../gmp-4.3.2.tar.bz2
$ tar -pxjf ../mpfr-2.4.2.tar.bz2
$ tar -pxzf ../mpc-0.8.1.tar.gz
$ mv gmp-4.3.2/ gmp
$ mv mpfr-2.4.2/ mpfr
$ mv mpc-0.8.1/ mpc
$ cd $SRCDIR

kernel
copy from /opt/pkg/petalinux-v2014.2-final/components/linux-kernel/xlnx-3.14 to $SRCDIR/xlnx-3.14

&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Build Environment:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
Build Environment save to file envsetting.sh
#!/bin/sh
export SRCDIR=~/workbench/gcc-4.8.2/xtools/src
export BINUTILS_SRC=$SRCDIR/binutils-2.24
export KERNEL_SRC=$SRCDIR/xlnx-3.14
export GCC_SRC=$SRCDIR/gcc-4.8.2
export GLIBC_SRC=$SRCDIR/glibc-2.18
export BUILDDIR=~/workbench/gcc-4.8.2/xtools/build
export TARGETMACH=arm-none-linux-gnueabi
export BUILDMACH=i686-pc-linux-gnu
export INSTALLDIR=~/workbench/gcc-4.8.2/arm
export SYSROOTDIR=$INSTALLDIR/sysroot
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Build binutils:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
$ mkdir $BUILDDIR
$ mkdir $BUILDDIR/binutils
$ cd $BUILDDIR/binutils
$ $BINUTILS_SRC/configure --disable-werror --build=$BUILDMACH --target=$TARGETMACH --prefix=$INSTALLDIR --with-sysroot=$SYSROOTDIR
$ make
$ make install
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Kernel Headers:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
$ cd ~/workbench/gcc-4.8.2/xtools/src/xlnx-3.14
$ make mrproper
$ make ARCH=arm xilinx_zynq_defconfig
$ mkdir -pv $INSTALLDIR/sysroot/usr
$ make ARCH=arm headers_check
$ make ARCH=arm INSTALL_HDR_PATH=$INSTALLDIR/sysroot/usr headers_install
$ cd $SRCDIR
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Bootstrap gcc:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
$ mkdir $BUILDDIR/bootstrap-gcc
$ cd $BUILDDIR/bootstrap-gcc
$ $GCC_SRC/configure --build=$BUILDMACH --host=$BUILDMACH --target=$TARGETMACH --prefix=$INSTALLDIR --without-headers --enable-boostrap --enable-languages=&quot;c&quot; --disable-threads --enable-__cxa_atexit --disable-libmudflap --with-gnu-ld --with-gnu-as --disable-libssp --disable-libgomp --disable-nls --disable-shared --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard
$ make all-gcc install-gcc
$ make all-target-libgcc install-target-libgcc
$ ln -s $INSTALLDIR/lib/gcc/arm-none-linux-gnueabi/4.8.2/libgcc.a $INSTALLDIR/lib/gcc/arm-none-linux-gnueabi/4.8.2/libgcc_sh.a
$ cd $SRCDIR
&lt;/pre&gt;
&lt;/br&gt;
&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;glibc Headers:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
$ mkdir -pv $BUILDDIR/libc
$ cd $BUILDDIR/libc
$ echo &quot;libc_cv_forced_unwind=yes&quot; &gt; config.cache
$ echo &quot;libc_cv_c_cleanup=yes&quot; &gt;&gt; config.cache
$ export PATH=$INSTALLDIR/bin:$PATH
$ export CROSS=arm-none-linux-gnueabi
$ export CC=${CROSS}-gcc
$ export LD=${CROSS}-ld
$ export AS=${CROSS}-as
$ $GLIBC_SRC/configure --build=$BUILDMACH --host=$TARGETMACH --prefix=$SYSROOTDIR/usr --with-headers=$SYSROOTDIR/usr/include --config-cache --enable-kernel=3.14
$ make -k install-headers cross_compiling=yes install_root=$SYSROOTDIR
 
*** We need to move some files ***
$ pushd $SYSROOTDIR/$INSTALLDIR/sysroot/usr/include
$ cp -rv * $SYSROOTDIR/usr/include/
$ popd
 
$ ln -s $INSTALLDIR/lib/gcc/arm-none-linux-gnueabi/4.8.2/libgcc.a $INSTALLDIR/lib/gcc/arm-none-linux-gnueabi/4.8.2/libgcc_eh.a
$ cd $SRCDIR
&lt;/pre&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Building glibc:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
$ rm -rf $BUILDDIR/libc
$ mkdir -pv $BUILDDIR/libc
$ cd $BUILDDIR/libc
$ echo &quot;libc_cv_forced_unwind=yes&quot; &gt; config.cache
$ echo &quot;libc_cv_c_cleanup=yes&quot; &gt;&gt; config.cache
 
*** check to make sure these are still set, they should be ***
$ echo $PATH
$ echo $CROSS
$ echo $CC
 
$ $GLIBC_SRC/configure --build=$BUILDMACH --host=$TARGETMACH --prefix=/usr --with-headers=$SYSROOTDIR/usr/include --config-cache --enable-kernel=3.14
$ make -k install-headers cross_compiling=yes install_root=$SYSROOTDIR
$ ln -s $INSTALLDIR/lib/gcc/arm-none-linux-gnueabi/4.8.2/libgcc.a $INSTALLDIR/lib/gcc/arm-none-linux-gnueabi/4.8.2/libgcc_s.a
$ make
$ make install_root=$SYSROOTDIR install
&lt;/pre&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Building The Next gcc:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
*** unset CC, LD, and AS. We do not want to xcompile the xcompiler :-) ***
$ unset CC
$ unset LD
$ unset AS
 
*** delete gcc-x.x.x and re-install it ***
$ cd $SRCDIR
$ rm -rf gcc-4.8.2
$ tar -pxjf gcc-4.8.2.tar.bz2
$ cd gcc-4.8.2/
$ tar -pxjf ../gmp-4.3.2.tar.bz2
$ tar -pxjf ../mpfr-2.4.2.tar.bz2
$ tar -pxzf ../mpc-0.8.1.tar.gz
$ mv gmp-4.3.2/ gmp
$ mv mpfr-2.4.2/ mpfr
$ mv mpc-0.8.1/ mpc
$ mkdir -pv $BUILDDIR/final-gcc
$ cd $BUILDDIR/final-gcc
$ echo &quot;libc_cv_forced_unwind=yes&quot; &gt; config.cache
$ echo &quot;libc_cv_c_cleanup=yes&quot; &gt;&gt; config.cache
$ BUILD_CC=gcc
$ $GCC_SRC/configure --build=$BUILDMACH --target=$TARGETMACH --prefix=$INSTALLDIR --with-sysroot=$SYSROOTDIR --enable-languages=&quot;c,c++&quot; --with-gnu-as --with-gnu-ld --disable-multilib --disable-sjlj-exceptions --disable-nls --enable-threads=posix --enable-long-longx --enable-libgomp --disable-shared --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard
$ make all-gcc
$ make install-gcc
&lt;/pre&gt;
&lt;/br&gt;


&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Building The Final gcc:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
*** make sure these are still unset ***
$ echo $CC
$ echo $LD
$ echo $AS
 
*** delete gcc-x.x.x and re-install it ***
$ cd $SRCDIR
$ rm -rf gcc-4.8.2
$ tar -pxjf gcc-4.8.2.tar.bz2
$ cd gcc-4.8.2/
$ tar -pxjf ../gmp-4.3.2.tar.bz2
$ tar -pxjf ../mpfr-2.4.2.tar.bz2
$ tar -pxzf ../mpc-0.8.1.tar.gz
$ mv gmp-4.3.2/ gmp
$ mv mpfr-2.4.2/ mpfr
$ mv mpc-0.8.1/ mpc
$ mkdir -pv $BUILDDIR/final-gcc-2
$ cd $BUILDDIR/final-gcc-2
$ echo &quot;libc_cv_forced_unwind=yes&quot; &gt; config.cache
$ echo &quot;libc_cv_c_cleanup=yes&quot; &gt;&gt; config.cache
$ $GCC_SRC/configure --build=$BUILDMACH --target=$TARGETMACH --prefix=$INSTALLDIR --with-sysroot=$SYSROOTDIR --enable-languages=&quot;c,c++&quot; --with-gnu-as --with-gnu-ld --disable-multilib --with-float=soft --disable-sjlj-exceptions --disable-nls --enable-threads=posix --disable-libmudflap --disable-libssp --enable-long-longx --enable-libgomp --with-shared --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard
$ make
$ make install
&lt;/pre&gt;
&lt;/br&gt;



&lt;span style=&quot;font-size: large;color:orange;&quot;&gt;&lt;b&gt;Usage:&lt;/b&gt;&lt;/span&gt;&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
export INSTALLDIR=~/workbench/gcc-4.8.2/arm
export PATH=$INSTALLDIR/bin:$PATH
export TARGETMACH=arm-none-linux-gnueabi
export BUILDMACH=i686-pc-linux-gnu
export CROSS=arm-none-linux-gnueabi
export CC=${CROSS}-gcc
export LD=${CROSS}-ld
export AS=${CROSS}-as

Now compile your test program:
$CC -Wall -Wextra &lt;your test&gt;.c -o &lt;your test&gt;
&lt;/pre&gt;
&lt;/br&gt;








</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/1175908243206978360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2014/12/how-to-build-gcc-arm-cross-compiler-for.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/1175908243206978360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/1175908243206978360'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2014/12/how-to-build-gcc-arm-cross-compiler-for.html' title='How To Build GCC ARM Cross-Compiler for Xilinx ZYNQ on ZC702 '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-8002119049002966154</id><published>2014-05-07T11:57:00.001+08:00</published><updated>2014-05-07T11:59:03.947+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="AWS"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><title type='text'>How to secure connection between AWS SDK and mobile APP(Android, iOS)?</title><content type='html'>This article shows the steps to build the secure connection between AWS SDK and mobile APP(Android, iOS).
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
   Using the root key(access key ID, secret access key) in your mobile application in plain text is very dangerous.&lt;br /&gt;
   AWS has a service for mobile client devices to connect to the AWS. The TVM(Token Vending Machine) creates a temporary credentials for mobile clients.&lt;br /&gt;
   The IAM(Identity and Access Management) user is a limited grant permissions user for access AWS.&lt;br /&gt;
   Here we will create a IAM user and build a TVM server for anonymous registration.
&lt;/pre&gt;
&lt;br /&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Fallow the steps to create a user to your AWS account for the TVM. Start from the paragraph &quot;To add a user to your AWS account for the TVM&quot; from this link.
&lt;a href=&#39;http://aws.amazon.com/code/8872061742402990&#39;&gt;Token Vending Machine for Anonymous Registration - Sample Java Web Application&lt;/a&gt;.
&lt;/br&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;&lt;/span&gt;Create a TVM server. Start from the paragraph &quot;Create the AWS Elastic Beanstalk application&quot; from this link.
&lt;a href=&#39;http://aws.amazon.com/code/8872061742402990&#39;&gt;Token Vending Machine for Anonymous Registration - Sample Java Web Application&lt;/a&gt;.
&lt;/br&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;Now you should have a IAM user and a TVM server runs on your AWS account. Download the AnonymousTVM sample for test. If you using Android download from this link
&lt;a href=&#39;https://github.com/awslabs/aws-sdk-android-samples/tree/master/S3_SimpleDB_SNS_SQS_DemoTVM&#39;&gt;aws-sdk-android-samples&lt;/a&gt;. This is for iOS &lt;a href=&#39;https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3_SimpleDB_SNS_SQS_DemoTVM&#39;&gt;aws-sdk-ios-samples&lt;/a&gt;. Fallow the README.md to run the project.  
&lt;/br&gt;
&lt;/br&gt;
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step4:&lt;/b&gt;&lt;/span&gt;If you have a existed project using the root key, you can easily change to TVM. Copy the necessary files from the example to your project. These are iOS example files.
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEg1QfVasXVUBtdzMD2c1Z_4ONkDPQC-5ioyFbQIc6OUOt3e_dArFSNX4yOeO1Wct5KGPGILtLVbaPAl372fa_kxct8xkQCkUpAIBoAK8Cbq3dtbnhWzSRRs6ZrhpMmc2lMrMx9aBoXHA/s1600/AVMfiles.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEg1QfVasXVUBtdzMD2c1Z_4ONkDPQC-5ioyFbQIc6OUOt3e_dArFSNX4yOeO1Wct5KGPGILtLVbaPAl372fa_kxct8xkQCkUpAIBoAK8Cbq3dtbnhWzSRRs6ZrhpMmc2lMrMx9aBoXHA/s320/AVMfiles.png&quot; /&gt;&lt;/a&gt;&lt;/br&gt;
remove the Create Certificate codes.&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
        //Create Certificate
        mCertificate = [[AmazonCredentials alloc] initWithAccessKey:AccessKeyID withSecretKey:SecretAccessKey];
        
        //Initialize DynamoDBClient
        mDdbClient = [[AmazonDynamoDBClient alloc] initWithCredentials:mCertificate];
&lt;/pre&gt;
&lt;/br&gt;
Change the access code.
&lt;/br&gt;From&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
DynamoDBPutItemResponse *response = [mDdbClient putItem:request];
&lt;/pre&gt;
&lt;/br&gt;To&lt;/br&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
DynamoDBPutItemResponse *response = [[AmazonClientManagerRunway ddb] putItem:request];
&lt;/pre&gt;&lt;/br&gt;
And That&#39;s it.



&lt;/br&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/8002119049002966154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2014/05/how-to-secure-connection-between-aws.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/8002119049002966154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/8002119049002966154'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2014/05/how-to-secure-connection-between-aws.html' title='How to secure connection between AWS SDK and mobile APP(Android, iOS)?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEg1QfVasXVUBtdzMD2c1Z_4ONkDPQC-5ioyFbQIc6OUOt3e_dArFSNX4yOeO1Wct5KGPGILtLVbaPAl372fa_kxct8xkQCkUpAIBoAK8Cbq3dtbnhWzSRRs6ZrhpMmc2lMrMx9aBoXHA/s72-c/AVMfiles.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-5897169570684404669</id><published>2013-12-04T15:42:00.000+08:00</published><updated>2013-12-04T15:51:15.713+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Mahout"/><title type='text'>Book: Mahout in Action</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYrvNp8CsHmGgIrSC2EhaPRiRqKN_3jlNtqfg4Cfz_hwdjLiPg0ZNe9pz8e-rMr43xnz7QIADByk9umLw5WKjVkFSGxBGfEmJTbQQySoL0ZK7TS_sFAsfhrT5j-qbURBcuqS0PR2Z5Vao/s1600/MahoutInAction.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYrvNp8CsHmGgIrSC2EhaPRiRqKN_3jlNtqfg4Cfz_hwdjLiPg0ZNe9pz8e-rMr43xnz7QIADByk9umLw5WKjVkFSGxBGfEmJTbQQySoL0ZK7TS_sFAsfhrT5j-qbURBcuqS0PR2Z5Vao/s320/MahoutInAction.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 因為目前公司有個重要專案(&lt;a href=&quot;http://bonrack.com/&quot;&gt;BonRack&lt;/a&gt;), 需要用到推薦系統, 研究了一下這個open source系統, 其實原本想法是想要利用機器學習來做, 因為OpenCV 摸了一陣子, 第一個想到的是用OpenCV 裡的Machine Learning API, 來搭建系統, 後來不經意的透過同學和學長介紹, 了解Apache有個機器學習專案, 安裝了來用, 再依照本書來實作, 以下大概解說概要, 實際內容請閱讀此書.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;第一篇, 主要解說推薦系統, 這是目前需多網站會使用的功能, 主要分為User-based與Item-based, 分別也有不同的分析方法, 也都有詳盡的解說與範例說明.&lt;br /&gt;
這2個方法的差別在於分析的途徑, User-based會依據使用者之間的相似性來判別相同的興趣.而item-based是依據物品的相關性來做推薦.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 此篇後面也針對資料量龐大時, 如何使用Apache Hadoop利用MapReduce方法來做分散式運算, 也解釋如何將演算部分拆成Map/Reduce可使用的輸入資料, 基本方式就是利用矩陣相乘時, 每個row和column之間運算過程並不會與其他row和column有相關, 只需回傳自己row與column相乘結果即可.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 第二篇clustering, 就是分群, 將相似物件歸為群集, Mahout實作的演算法有k-means,  fuzzy k-means, canopy, Dirichlet 和 LDA, 那如何定義相似?&amp;nbsp;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Mahout提供幾個方法, 簡單的解釋就是距離, 可以依照實際需求採用不同的距離計算方法. 
這幾個實作的演算發都有分為單機版與MapReduce版, 可以簡單的切換不同運算需求, 此篇也有提到其他的演算法, 但是因為無法拆成MapReduce形式, 就沒有實作出來.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Mahout也提供了一些tool class, 可以幫忙分析使用不同方法算出的結果, 可用來調整最佳算法與參數.
篇末提供了3個使用真實世界資料用clustering分析的例子,&amp;nbsp;
&lt;br /&gt;
1.twitter:透過使用者tweet的文字, 來將使用者分群.&lt;br /&gt;
2.Last.fm:網路音樂電台, 透過用戶將音樂標籤, 可以建議音樂或作者類似標籤.&lt;br /&gt;
3.Stack Overflow:透過問題與答案, 和相關的回答者與得分, 來分辨是否有相關的問題與答案.&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 第三篇Classification, 字面翻譯是分類, 感覺上很像clustering, 但是區別在於, clustering是透過演算本身將資料分群. 而Classification比較像是預測分析, 需要經過一個訓練過程, 找出一個最佳解, 像是垃圾郵件分類器就是這一類演算法.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 典型的classification分為3大步驟:&lt;br /&gt;
1.定義目標值, 收集訓練資料, 定義預測值, 選擇演算法, 開始訓練並產生model.&lt;br /&gt;
2.使用測試資料測試model, 檢測結果, 並調整訓練參數, 演算法等.&lt;br /&gt;
3.開始使用未知資料, 進行運作.
這部分可以用的演算法有: stochastic gradient descent (SGD), Support Vector Machine(SVM), naive Bayes, complementary naive Bayes, Random forests.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Mahout提供了評估訓練結果的API, 可以在訓練過程中做即時評估, 可用來做調整訓練參數或更換演算法的依據.

對於機器學習有興趣的人一定要去看看這個&lt;a href=&quot;http://www.blogger.com/%E2%80%9Chttp://videolectures.net/stanfordcs229f07_machine_learning/&quot;&gt;Stanford機器學習公開課程CS229&lt;/a&gt;
&lt;a href=&quot;http://www.blogger.com/%E2%80%9Chttp://study.163.com/plan/planLearn.htm?id=1200146#/learn/resVideo?lessonId=2207&quot;&gt;這是有中文字幕版本&lt;/a&gt;, 還有很重要的&lt;a href=&quot;http://www.blogger.com/%E2%80%9Chttp://see.stanford.edu/see/materials/aimlcs229/handouts.aspx&quot;&gt;講義&lt;/a&gt;一定要看.



&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/5897169570684404669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2013/12/book-mahout-in-action.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/5897169570684404669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/5897169570684404669'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2013/12/book-mahout-in-action.html' title='Book: Mahout in Action'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYrvNp8CsHmGgIrSC2EhaPRiRqKN_3jlNtqfg4Cfz_hwdjLiPg0ZNe9pz8e-rMr43xnz7QIADByk9umLw5WKjVkFSGxBGfEmJTbQQySoL0ZK7TS_sFAsfhrT5j-qbURBcuqS0PR2Z5Vao/s72-c/MahoutInAction.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-6585703116544197404</id><published>2013-11-27T12:25:00.000+08:00</published><updated>2013-12-04T15:42:45.822+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Mahout"/><title type='text'>Simple recommender engine</title><content type='html'>This example is from Mahout in Action book.&lt;br /&gt;
&lt;br /&gt;
Step1:&lt;br /&gt;
Create a new Maven project in the Mahout main directory, in my environment is ~/Mahout/trunk&lt;br /&gt;
This command creates a new &quot;project&quot; directory. And add a new package &quot;com.smims.recommenderintro&quot; in its.&lt;br /&gt;
And create a new java file &quot;App.java&quot;.&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt;
smims@ubuntu:~/mahout/trunk$mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.smims.recommenderintro -DartifactId=project
&lt;/pre&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt;
smims@ubuntu:~/mahout/trunk$mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.smims.recommenderintro -DartifactId=project
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.smims.recommenderintro
[INFO] Parameter: packageName, Value: com.smims.recommenderintro
[INFO] Parameter: package, Value: com.smims.recommenderintro
[INFO] Parameter: artifactId, Value: project
[INFO] Parameter: basedir, Value: /home/smims/mahout/trunk
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /home/smims/mahout/trunk/project
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Mahout Build Tools ................................ SKIPPED
[INFO] Apache Mahout ..................................... SUCCESS [22.584s]
[INFO] Mahout Math ....................................... SKIPPED
[INFO] Mahout Core ....................................... SKIPPED
[INFO] Mahout Integration ................................ SKIPPED
[INFO] Mahout Examples ................................... SKIPPED
[INFO] Mahout Release Package ............................ SKIPPED
[INFO] Mahout Math/Scala wrappers ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 33.614s
[INFO] Finished at: Wed Nov 27 11:00:53 CST 2013
[INFO] Final Memory: 18M/44M
[INFO] ------------------------------------------------------------------------
&lt;/pre&gt;
&lt;br /&gt;
Step2:&lt;br /&gt;
Change to the project directory.
Test the new project, it should print the &quot;Hello world!&quot; message. 
&lt;pre class=&quot;brush:c&quot;&gt;
smims@ubuntu:~/mahout/trunk/project$mvn compile
smims@ubuntu:~/mahout/trunk/project$mvn exec:java -Dexec.mainClass=&quot;com.smims.recommenderintro.App&quot;
&lt;/pre&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt;
smims@ubuntu:~/mahout/trunk/project$mvn compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ project ---
[INFO] Using &#39;UTF-8&#39; encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/smims/mahout/trunk/project/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/smims/mahout/trunk/project/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.181s
[INFO] Finished at: Wed Nov 27 11:09:03 CST 2013
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------ 

smims@ubuntu:~/mahout/trunk/project$mvn exec:java -Dexec.mainClass=&quot;com.smims.recommenderintro.App&quot;
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] &gt;&gt;&gt; exec-maven-plugin:1.2.1:java (default-cli) @ project &gt;&gt;&gt;
[INFO] 
[INFO] &lt;&lt;&lt; exec-maven-plugin:1.2.1:java (default-cli) @ project &lt;&lt;&lt;
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ project ---
Hello World!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.945s
[INFO] Finished at: Wed Nov 27 11:13:45 CST 2013
[INFO] Final Memory: 11M/26M
[INFO] ------------------------------------------------------------------------
&lt;/pre&gt;
&lt;br /&gt;

Step3:&lt;br /&gt;
Create a text file &quot;intro.csv&quot; in the project directory, same as the pom.xml.&lt;br /&gt;
For example:User 1 has preference value 3.0 for item 102.&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
1,101,5.0
1,102,3.0
1,103,2.5
2,101,2.0
2,102,2.5
2,103,5.0
2,104,2.0
3,101,2.5
3,104,4.0
3,105,4.5
3,107,5.0
4,101,5.0
4,103,3.0
4,104,4.5
4,106,4.0
5,101,4.0
5,102,3.0
5,103,2.0
5,104,4.0
5,105,3.5
5,106,4.0
&lt;/pre&gt;
&lt;br /&gt;
Step4:&lt;br /&gt;
Create a recommender engine in java code, open and edit &quot;App.java&quot;.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;
package com.smims.recommenderintro;

import org.apache.mahout.cf.taste.impl.model.file.*;
import org.apache.mahout.cf.taste.impl.neighborhood.*;
import org.apache.mahout.cf.taste.impl.recommender.*;
import org.apache.mahout.cf.taste.impl.similarity.*;
import org.apache.mahout.cf.taste.model.*;
import org.apache.mahout.cf.taste.neighborhood.*;
import org.apache.mahout.cf.taste.recommender.*;
import org.apache.mahout.cf.taste.similarity.*;
import java.io.*;
import java.util.*;

class App 
{
 public static void main(String[] args) throws Exception 
 {
  // Load data file
  DataModel model = new FileDataModel (new File(&quot;intro.csv&quot;)); 
  UserSimilarity similarity = new PearsonCorrelationSimilarity (model);
  UserNeighborhood neighborhood = new NearestNUserNeighborhood (2, similarity, model);
  
  // Create recommender engine
  Recommender recommender = new GenericUserBasedRecommender (model, neighborhood, similarity); 
  
  // For user 1, recommend 1 item
  List&amp;lt;RecommendedItem&amp;gt; recommendations = recommender.recommend(1, 1); 
  
  for (RecommendedItem recommendation : recommendations) 
  {
   System.out.println(recommendation);
  }
 }
} 
&lt;/pre&gt;
&lt;br /&gt;
Step5:&lt;br /&gt;
Before compile the code, we need setting the Mahout dependencies in the pom.xml.&lt;br /&gt;
Add these lines under the &amp;lt;dependencies&amp;gt; section in the pom.xml.
&lt;pre class=&quot;brush:c&quot;&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.mahout&lt;/groupId&gt;
      &lt;artifactId&gt;mahout-core&lt;/artifactId&gt;
      &lt;version&gt;0.9-SNAPSHOT&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.mahout&lt;/groupId&gt;
      &lt;artifactId&gt;mahout-math&lt;/artifactId&gt;
      &lt;version&gt;0.9-SNAPSHOT&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.mahout&lt;/groupId&gt;
      &lt;artifactId&gt;mahout-math&lt;/artifactId&gt;
      &lt;version&gt;0.9-SNAPSHOT&lt;/version&gt;
      &lt;type&gt;test-jar&lt;/type&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.mahout&lt;/groupId&gt;
      &lt;artifactId&gt;mahout-utils&lt;/artifactId&gt;
      &lt;version&gt;0.5&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/pre&gt;
&lt;br /&gt;
Step6:&lt;br /&gt;
Compile and run the code.&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt;
smims@ubuntu:~/mahout/trunk/project$mvn compile
smims@ubuntu:~/mahout/trunk/project$mvn exec:java -Dexec.mainClass=&quot;com.smims.recommenderintro.App&quot;
&lt;/pre&gt;
&lt;pre class=&quot;brush:c&quot;&gt;
smims@ubuntu:~/mahout/trunk/project$mvn compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ project ---
[INFO] Using &#39;UTF-8&#39; encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/smims/mahout/trunk/project/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ project ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.995s
[INFO] Finished at: Wed Nov 27 12:10:57 CST 2013
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
smims@ubuntu:~/mahout/trunk/project$mvn exec:java -Dexec.mainClass=&quot;com.smims.recommenderintro.App&quot;
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] &gt;&gt;&gt; exec-maven-plugin:1.2.1:java (default-cli) @ project &gt;&gt;&gt;
[INFO] 
[INFO] &lt;&lt;&lt; exec-maven-plugin:1.2.1:java (default-cli) @ project &lt;&lt;&lt;
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ project ---
SLF4J: Failed to load class &quot;org.slf4j.impl.StaticLoggerBinder&quot;.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
RecommendedItem[item:104, value:4.257081]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.254s
[INFO] Finished at: Wed Nov 27 12:13:01 CST 2013
[INFO] Final Memory: 12M/29M
[INFO] ------------------------------------------------------------------------

&lt;/pre&gt;
&lt;br /&gt;
The recommend result for the user 1 is the 104 item.


&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/6585703116544197404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2013/11/simple-recommender-engine.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/6585703116544197404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/6585703116544197404'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2013/11/simple-recommender-engine.html' title='Simple recommender engine'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-3492897658630993038</id><published>2013-11-18T12:57:00.000+08:00</published><updated>2013-12-04T15:42:38.687+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><category scheme="http://www.blogger.com/atom/ns#" term="Mahout"/><title type='text'>Install Mahout on VirtualBox ubuntu under MAC OS</title><content type='html'>Environments:
&lt;br /&gt;
MAC OS X 10.9&lt;br /&gt;
VirtualBox 4.3.0&lt;br /&gt;
ubuntu-13.10-server-i386.iso&lt;br /&gt;
&lt;br /&gt;
1.Install ubuntu on VirtualBox.2GB RAM, 8GB hard disk.&lt;br /&gt;
&lt;a href=&quot;http://www.ubuntu.com/download/server&quot;&gt;http://www.ubuntu.com/download/server&lt;/a&gt;&lt;br /&gt;
2.In ubuntu, check the prerequisites for building Mahout.

&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ java -version
java version &quot;1.7.0_25&quot;
OpenJDK Runtime Environment (IcedTea 2.3.12) (7u25-2.3.12-4ubuntu3)
OpenJDK Client VM (build 23.7-b01, mixed mode, sharing)
&lt;/pre&gt;
We have JDK1.7 and it&#39;s ok.

&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ mvn -version
The program &#39;mvn&#39; can be found in the following packages:
 * maven
 * maven2
Try: sudo apt-get install &amp;ltselected package&amp;gt
&lt;/pre&gt;
The default system environment does not has the maven package.&lt;br /&gt;
3.Start to install the Maven package.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ sudo apt-get install maven
&lt;/pre&gt;
It may takes few minutes to download.&lt;br /&gt;
check again after install completed.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ mvn -version
Warning: JAVA_HOME environment variable is not set.
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-i386/jre
Default locale: en_HK, platform encoding: UTF-8
OS name: &quot;linux&quot;, version: &quot;3.11.0-12-generic&quot;, arch: &quot;i386&quot;, family: &quot;unix&quot;
&lt;/pre&gt;
4.There is a warning in the first line. JAVA_HOME environment variable is not set.&lt;br/&gt;
Add lines to /etc/environment. And exit shell and re-login.&lt;br/&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ cat /etc/environment 
PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games&quot;
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
smims@ubuntu:~$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-i386/jre
Default locale: en_HK, platform encoding: UTF-8
OS name: &quot;linux&quot;, version: &quot;3.11.0-12-generic&quot;, arch: &quot;i386&quot;, family: &quot;unix&quot;
&lt;/pre&gt;
5.Install subversion.
&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ sudo apt-get install subversion
&lt;/pre&gt;

6.Download mahout, using svn to get the latest version.&lt;br /&gt;
https://cwiki.apache.org/confluence/display/MAHOUT/BuildingMahout&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$mkdir mahout
smims@ubuntu:~$cd mahout
smims@ubuntu:~/mahout$ svn co http://svn.apache.org/repos/asf/mahout/trunk
...
smims@ubuntu:~/mahout$ ls -la
total 12
drwxrwxr-x  3 smims smims 4096 Nov 18 12:14 .
drwxr-xr-x  5 smims smims 4096 Nov 18 12:14 ..
drwxrwxr-x 12 smims smims 4096 Nov 18 12:15 trunk
&lt;/pre&gt;

7.Compiling the Mahout using maven.&lt;br /&gt;
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~$ cd mahout/trunk
smims@ubuntu:~/mahout/trunk$ mvn install 
...
&lt;/pre&gt;
But there is a error message.&lt;br /&gt;
[ERROR] COMPILATION ERROR : &lt;br /&gt;
[INFO] -------------------------------------------------------------&lt;br /&gt;
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?&lt;br /&gt;
[INFO] 1 error&lt;br /&gt;
...&lt;br /&gt;

To fix this, just re-install the jdk and install again. It works just fine.
&lt;pre class=&quot;brush:c&quot;&gt; 
smims@ubuntu:~/mahout/trunk$ sudo apt-get install openjdk-7-jdk
...
smims@ubuntu:~/mahout/trunk$ mvn install 
...
&lt;/pre&gt;

8.At the last few steps, it will automatic test some examples.
&lt;pre class=&quot;brush:c&quot;&gt; 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Mahout Build Tools ................................ SUCCESS [1.373s]
[INFO] Apache Mahout ..................................... SUCCESS [0.368s]
[INFO] Mahout Math ....................................... SUCCESS [2:12.007s]
[INFO] Mahout Core ....................................... SUCCESS [23:55.232s]
[INFO] Mahout Integration ................................ SUCCESS [2:35.669s]
[INFO] Mahout Examples ................................... SUCCESS [9.259s]
[INFO] Mahout Release Package ............................ SUCCESS [0.016s]
[INFO] Mahout Math/Scala wrappers ........................ SUCCESS [1:29.086s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30:23.327s
[INFO] Finished at: Mon Nov 18 13:12:10 CST 2013
[INFO] Final Memory: 42M/129M
[INFO] ------------------------------------------------------------------------
&lt;/pre&gt;


&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/3492897658630993038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2013/11/install-mahout-on-virtualbox-ubuntu.html#comment-form' title='124 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3492897658630993038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3492897658630993038'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2013/11/install-mahout-on-virtualbox-ubuntu.html' title='Install Mahout on VirtualBox ubuntu under MAC OS'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>124</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-7301478257963247468</id><published>2012-12-24T10:57:00.000+08:00</published><updated>2012-12-24T10:57:25.033+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="XCode"/><title type='text'>更改 iOS navigationItem.backBarButtonItem.title</title><content type='html'>
iOS navigationItem.backBarButtonItem.title 不能直接改名.&lt;/br&gt;
因為它會引用 parent controller 的title, 也就是按下 back button 會返回的controller title.&lt;/br&gt;
所以方法1. 將parent controller 的title 改名.&lt;/br&gt;
方法2. 產生新的UIBarButtonItem,但是 back button 的外型會變成四方.&lt;/br&gt;

&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/7301478257963247468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/12/ios-navigationitembackbarbuttonitemtitle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/7301478257963247468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/7301478257963247468'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/12/ios-navigationitembackbarbuttonitemtitle.html' title='更改 iOS navigationItem.backBarButtonItem.title'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-6476260870127034341</id><published>2012-11-13T11:35:00.000+08:00</published><updated>2012-11-13T12:01:24.171+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS-OpenCV"/><category scheme="http://www.blogger.com/atom/ns#" term="XCode"/><title type='text'>How to use OpenCV in iOS?</title><content type='html'>This article shows the steps to build the OpenCV application under the iOS.
&lt;/br&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Download the pre-compile binary OpenCV library for iOS framework. Refers to the &lt;a href=&#39;http://computer-vision-talks.com/2012/06/opencv-tutorial-a-collection-of-opencv-samples-for-iphoneipad-part-1/&#39;&gt;link&lt;/a&gt;. Direct download link &lt;a href=&#39;http://computer-vision-talks.com/download/opencv-2.4-build.zip&#39;&gt;OpenCV-2.4-build.zip&lt;/a&gt;.
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;&lt;/span&gt;Extract the zip file to the directory, for example, &#39;~/opencv-2.4-build&#39;. 
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;Open the XCode project to setup the project.Go to the Targets build setting. &lt;/br&gt;
Add a Header Search Paths for debug and release with the string &quot;~/opencv-2.4-build/**&quot;. &lt;/br&gt;
Add a Library Search Paths for debug with the string &quot;~/opencv-2.4-build/lib/debug&quot;.&lt;/br&gt;
 And for release path with string &quot;~/opencv-2.4-build/lib/release&quot;.
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step4:&lt;/b&gt;&lt;/span&gt;Setting linking path to the project. &lt;/br&gt;
Add the string &quot;-lopencv_calib3d -lzlib -lopencv_contrib -lopencv_legacy -lopencv_features2d -lopencv_imgproc -lopencv_video -lopencv_core&quot; to the Other Linker flag.
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step5:&lt;/b&gt;&lt;/span&gt;Modify the project Prefix header.
&lt;/br&gt; Add these code to the [YourProjectName]-Prefix.pch file.
&lt;pre class=&quot;brush:cpp&quot;&gt;
#ifdef __cplusplus
    #include &amp;lt;opencv2/opencv.hpp&amp;gt;
    #include &amp;lt;opencv2/nonfree/nonfree.hpp&amp;gt;
#endif

#ifdef __OBJC__
    #import &amp;lt;UIKit/UIKit.h&amp;gt;
    #import &amp;lt;Foundation/Foundation.h&amp;gt;
#endif
&lt;/pre&gt; 
&lt;/br&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step6:&lt;/b&gt;&lt;/span&gt;Now you can use the OpenCV API.



&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/6476260870127034341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/11/how-to-use-opencv-in-ios.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/6476260870127034341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/6476260870127034341'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/11/how-to-use-opencv-in-ios.html' title='How to use OpenCV in iOS?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-246310705757739024</id><published>2012-10-04T11:35:00.000+08:00</published><updated>2012-11-13T10:23:20.588+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Dropbox"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="XCode"/><title type='text'>How to using Git repository on Dropbox to back up XCode Project?</title><content type='html'>This article teaches how to using Git repository on Dropbox to back up XCode Project.

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Create XCode project and allowed it to set up a local Git Repository.

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;&lt;/span&gt;Open a console and chdir to the XCode project directory.
&lt;br /&gt;

&lt;pre class=&quot;brush:cpp&quot;&gt;$cd ~/MyProject/NewProject1

&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;Clone a git repository to the Dropbox directory. That is the .git directory in the NewProject1.We do not want the whole working code sync with Dropbox.
&lt;br /&gt;

&lt;pre class=&quot;brush:cpp&quot;&gt;$git clone --bare . ~/Dropbox/git/repo/NewProject1.git

&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step4:&lt;/b&gt;&lt;/span&gt;Create a remote git repository. XCode will recognize this remote repo.
&lt;br /&gt;

&lt;pre class=&quot;brush:cpp&quot;&gt;$git remote add NewProject1 ~/Dropbox/git/repo/NewProject1.git

&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step5:&lt;/b&gt;&lt;/span&gt;Add Git .gitignore file to the project directory.&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;# .gitignore file for Xcode4 / OS X Source projects
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
# Generated
*.o
*.pyc 

&lt;/pre&gt;
&lt;br /&gt;

&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step6:&lt;/b&gt;&lt;/span&gt;Now we can use this remote git repository in the XCode.Open the NewProject1 project in the XCode. Go to the menubar, File-&gt;Source Control-&gt;Push. Now you can find the remote repository.
&lt;br /&gt;


&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;

</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/246310705757739024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/10/how-to-using-git-repository-on-dropbox.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/246310705757739024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/246310705757739024'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/10/how-to-using-git-repository-on-dropbox.html' title='How to using Git repository on Dropbox to back up XCode Project?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-1237355765449654741</id><published>2012-09-25T12:25:00.001+08:00</published><updated>2012-10-15T13:49:34.264+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Startups"/><title type='text'>BJ Fogg - Innovation</title><content type='html'>The source of the content&amp;nbsp;&lt;a href=&quot;http://www.bjfogg.com/innovation.html&quot;&gt;My Focus = Psychology + Innovation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The video main idea is the behavior change.&lt;br /&gt;
Behavior has the trigger. Like the email, warning light on the run out of the gas, text message or a sound.&lt;br /&gt;
And others are ability and motivation.&lt;br /&gt;
&lt;br /&gt;
Fogg Behavior model/Equation:&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;Motivation&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;, Ability and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;Trigger. B=MAT.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipSwhmh8X6Mr_ra8piZ659gWd6k3Ps8BNaMXJAkaPPYL01CSJ553Vt_04QSoxxtLHzfyAE8h7s5M5qBYjyS2bJPFVwmCbR96RY0pWqHbsbLr14R3Nw-QsIpz8EKCYAvCiMbDEx0fCJHEs/s1600/MAT.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipSwhmh8X6Mr_ra8piZ659gWd6k3Ps8BNaMXJAkaPPYL01CSJ553Vt_04QSoxxtLHzfyAE8h7s5M5qBYjyS2bJPFVwmCbR96RY0pWqHbsbLr14R3Nw-QsIpz8EKCYAvCiMbDEx0fCJHEs/s320/MAT.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Example in the video is the App for help people lose their weight and more healthier.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;We already trigger they to use our product, but imaging&amp;nbsp;&lt;/span&gt;our user in the left-bottom area.&lt;br /&gt;
First thing is make your product easy to do.&lt;br /&gt;
&lt;br /&gt;
Assume we have a solution could help people for track their food every day.&lt;br /&gt;
Number one target is the already in the right-top corner market, we just need trigger and will happen.&lt;br /&gt;
Number two is the people in the left-top area, they have motivate but is hard to do. So we create a solution for these is to make it easier.&lt;br /&gt;
And number three is the right-bottom corner, but i will forget these people, and&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;do not wast you time to the people in the left-bottom people.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Look at the creations in your products, are you helping people step by step do what they already want to do.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/1237355765449654741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/09/bj-fogg-innovation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/1237355765449654741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/1237355765449654741'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/09/bj-fogg-innovation.html' title='BJ Fogg - Innovation'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipSwhmh8X6Mr_ra8piZ659gWd6k3Ps8BNaMXJAkaPPYL01CSJ553Vt_04QSoxxtLHzfyAE8h7s5M5qBYjyS2bJPFVwmCbR96RY0pWqHbsbLr14R3Nw-QsIpz8EKCYAvCiMbDEx0fCJHEs/s72-c/MAT.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-3214228421751250866</id><published>2012-09-14T08:39:00.002+08:00</published><updated>2012-10-15T13:49:25.137+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Startups"/><title type='text'>2012 Start-Up Chile Holds Its First Demo Day In San Francisco</title><content type='html'>&lt;br /&gt;
The article source &lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+Techcrunch+%28TechCrunch%29&amp;amp;utm_content=Google+Reader&quot;&gt;Start-Up Chile Holds Its First Demo Day In San Francisco&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-image: none !important; color: #66e877; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;
Here then, are the 25 companies that came to San Francisco this week to pitch their startups to Silicon Valley investors:&lt;/div&gt;
&lt;ul style=&quot;background-image: none !important; color: #66e877; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.comenta.tv/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Comenta.TV&lt;/a&gt;: Comenta.TV is an early stage company that identifies, measures, and analyzes in real time the resonance of live TV shows in social networks.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/social_radio_logo/&quot; rel=&quot;attachment wp-att-650622&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.thesocialradio.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;The Social Radio&lt;/a&gt;: The Social Radio lets you listen to Twitter mixed with your favorite music, so you don’t have to read them while driving, running, or working.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.jogabu.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Jogabo&lt;/a&gt;: Jogabo is a community platform for soccer players to organize, share, and discover unique games in their cities online or from a smartphone.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.escapeswithyou.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;EscapesWithYou&lt;/a&gt;: EscapesWithYou.com is a social e-commerce platform that features happy lifetime experiences at incredible destinations around the world.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.bractlet.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Bractlet&lt;/a&gt;: Bractlet reduces energy consumption in hotels through a hardware-software integrated solution that allows guests to earn rewards by using less energy than others and allows managers to see a real-time breakdown of energy use, create customizable alerts, and reduce energy misuse.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.biometrycloud.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;BiometryCloud&lt;/a&gt;: BiometryCloud is the most simple, fast, and robust identity platform on the market. We provide a cloud-based facial recognition engine that can identify users, stop fraud, and make personal interactions easier with just a picture from their mobile devices.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/chef_surfing/&quot; rel=&quot;attachment wp-att-650625&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.chefsurfing.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Chef Surfing&lt;/a&gt;: A new home for chefs on the web. To Chefs: Create your professional profile and find new opportunities. To Guests: Hire a chef the easy way. Get custom proposals from chefs in your city.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.silverliningsnewyork.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Chu Shu&lt;/a&gt;: Chu Shu makes Silver Linings, shoe liners that extend the life of shoes and keep feet odor-free. We see our business as an opportunity to make a positive change on the environment.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.contentdj.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;ContentDJ&lt;/a&gt;: ContentDJ is the HootSuite for content curators. It fights information overload and lets you curate and publish awesome content on social media sites.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/flipter_logo/&quot; rel=&quot;attachment wp-att-650628&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.flipter.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Flipter&lt;/a&gt;: Flipter lets you create, share, and organize opinion polls about the things you find interesting on the web and in real life, including images, videos, and links. Best of all, you can browse Flipter and discover the demographic profile of those voting with powerful charts and reports.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.kedzoh.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Kedzoh&lt;/a&gt;: Kedzoh gives you back the time to manage and to learn, time that’s been lost to today’s complex tools and systems. Kedzoh is an enterprise tool that makes it easy and fun for managers and employees to create and take short, three-to-five-minute, lessons on their smartphones or tablets.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/kwelia_logo/&quot; rel=&quot;attachment wp-att-650632&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.kwelia.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Kwelia&lt;/a&gt;: Kwelia is a data analytics platform for real estate. Positioned at the nexus between big data, quantitative analysis, and real estate, we deliver intelligence like dynamic pricing and automated lease term generation to property owners.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.localguiding.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;LocalGuiding&lt;/a&gt;: LocalGuiding is a peer-to-peer marketplace for unique travel tours offered by local guides. On our website travelers can easily find and instantly book personal tours organized by locals.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.mibuzz.tv/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;MiBuzz.tv&lt;/a&gt;: MiBuzz.tv is a social tool for video people where you can find, collect, and share videos + work + ideas.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.motiondisplays.cl/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Motion Displays&lt;/a&gt;: Motion Displays develops the next generation of self-service and guided selling software solutions for the retail industry.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/street_investor_logo/&quot; rel=&quot;attachment wp-att-650629&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.streetinvestor.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Street Investor&lt;/a&gt;: StreetInvestor is the Latin-American version of Bússola do Investidor, a Brazilian online platform to help individual investors to invest. We offer our users investing tools and information to help them make the best investment decisions.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.wallwisher.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Wallwisher&lt;/a&gt;: Wallwisher is a family of applications and services that simplify publishing content on the web. People can use it to create, communicate, and collaborate more easily, effectively, and imaginatively.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/2012/09/13/start-up-chile-holds-its-first-demo-day-in-san-francisco/yupi_logo/&quot; rel=&quot;attachment wp-att-650637&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.yupistudios.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Yupi&lt;/a&gt;: Yupi Studios develops apps, games and innovative solutions for Smartphones, Tablets, Smart TVs and Social Networks. We’re partners of Tapjoy, who helps us marketing freemium games for iOS and Android.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.wehostels.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;WeHostels&lt;/a&gt;: First social booking site for hostels, beds, and couches. We take the beauty of the Social Web and bring it to the Travel Booking Market.&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://techcrunch.com/?attachment_id=635485&quot; rel=&quot;attachment wp-att-635485&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://http//babelverse.com&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;Babelverse&lt;/a&gt;: Babelverse is the first solution for universal speech translation, powered by a global community of human interpreters. Multilinguals and professional interpreters alike are able to earn money for their time, creating a new source of income for people all over the world. (The company was a finalist at TechCrunch Disrupt NY 2012.)&lt;/li&gt;
&lt;li style=&quot;background-image: none !important;&quot;&gt;&lt;a href=&quot;http://www.gym-pact.com/&quot; style=&quot;background-image: none !important; color: #1155cc;&quot; target=&quot;_blank&quot;&gt;GymPact&lt;/a&gt;: GymPact conquers workout excuses with money as a motivator. Commit to exercise, and earn cash for doing it – paid for by non-exercisers. Just check-in at the gym with our iPhone app, or track outdoor runs, walks, and bike rides with our partner RunKeeper.&lt;/li&gt;
&lt;/ul&gt;


&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/3214228421751250866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/09/2012-start-up-chile-holds-its-first.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3214228421751250866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3214228421751250866'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/09/2012-start-up-chile-holds-its-first.html' title='2012 Start-Up Chile Holds Its First Demo Day In San Francisco'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-1116253427467330117</id><published>2012-09-13T16:49:00.000+08:00</published><updated>2012-10-15T13:49:00.432+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Startups"/><title type='text'>2012 TechCrunch Disrupt  San Francisco</title><content type='html'>The Final 7 Disrupt SF Startups:&lt;br /&gt;
1.&lt;a href=&quot;http://techcrunch.com/2012/09/11/expect-labs-mindmeld-ipad-app-understands-your-conversations-in-real-time/&quot;&gt;Expect Labs’ MindMeld app&lt;/a&gt;: Analyze your conversations in real time and pull pertinent information on your iPad.&lt;br /&gt;
&lt;br /&gt;
2.&lt;a href=&quot;http://techcrunch.com/2012/09/10/gyft-is-moving-the-plastic-gift-card-industry-to-your-iphone/&quot;&gt;Gyft&lt;/a&gt;: It is a mobile app allows you to buy, save and redeem gift cards using your mobile phone. It’s taking the existing $100 billion market for physical gift cards and moving it to the phone. &lt;br /&gt;

&lt;br /&gt;
3.&lt;a href=&quot;http://techcrunch.com/2012/09/10/lit-motors-will-shake-up-the-electric-vehicle-market-with-its-two-wheeled-untippable-c-1/&quot;&gt;Lit Motors’ C-1&lt;/a&gt;: The world’s first gyroscopically stabilized, two-wheeled all-electric vehicle.&lt;br /&gt;

&lt;br /&gt;
4.&lt;a href=&quot;http://techcrunch.com/2012/09/11/prior-knowledge-a-predictive-database-for-developers/&quot;&gt;Prior Knowledge&lt;/a&gt;: A predictive database for application developers.
which the company says is designed to make applications smarter. The technology uses state of the art machine learning behind the scenes to handle the complexity for real world data.&lt;br /&gt;

&lt;br /&gt;
5.&lt;a href=&quot;http://techcrunch.com/2012/09/10/saya-mobile-has-a-message-it-wants-to-be-the-whatsapp-for-the-feature-phones-of-the-world/&quot;&gt;Saya Mobile&lt;/a&gt;: Which offers an instant messaging and SMS service to feature phones geared specifically to emerging markets like Africa.&lt;br /&gt;

&lt;br /&gt;
6.&lt;a href=&quot;http://techcrunch.com/2012/09/11/yourmechanic-the-uber-of-car-maintenance-offers-on-demand-certified-mechanics-at-30-50-savings/&quot;&gt;YourMechanic&lt;/a&gt;: A peer-to-peer car repair marketplace that enables mechanics to fix users’ cars at their home or office.&lt;br /&gt;

&lt;br /&gt;
7.&lt;a href=&quot;http://techcrunch.com/2012/09/11/zumper-disrupt12/&quot;&gt;Zumper&lt;/a&gt;: Using data from landlords to find the right tenants.You can favorite neighborhoods, for instance, for a customized news feed that’s refreshed every five minutes.&lt;br /&gt;

&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/1116253427467330117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/09/2012-techcrunch-disrupt-san-francisco.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/1116253427467330117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/1116253427467330117'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/09/2012-techcrunch-disrupt-san-francisco.html' title='2012 TechCrunch Disrupt  San Francisco'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-2267864010589605227</id><published>2012-08-15T14:25:00.000+08:00</published><updated>2012-10-15T13:48:49.935+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android-OpenCV"/><title type='text'>How to do real time image processing in Android using OpenCV?</title><content type='html'>This article teaches how to pass camera preview frame to android-opencv on the fly.&lt;br /&gt;
&lt;br /&gt;
The Android camera have preview data callback function. I can get the data from the function convert to the OpenCV Mat data form.Using Android JNI IF pass the frame data to the OpenCV, let the image processing do in the native OpenCV library.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;I need a camera preview class to handle the Android camera device.The class i created from the article&amp;nbsp;&lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/08/how-to-use-camera-in-android.html&quot;&gt;How to use camera in Android?&lt;/a&gt;.In the article shows the way to take picture and save to the file.But in this article i only need the frame data in the camera preview period.&lt;br /&gt;
In the new&amp;nbsp;CameraPreview.java file, i removed unused callback functions. Leave the only callback function&amp;nbsp;onPreviewFrame(), and create a native function interface.&lt;br /&gt;
And create a&amp;nbsp;Runnable() object to do the image processing.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;/*
*  CameraPreview.java
*/
public class CameraPreview implements SurfaceHolder.Callback, Camera.PreviewCallback
{
  private Camera mCamera = null;
  private ImageView MyCameraPreview = null;
  private Bitmap bitmap = null;
  private int[] pixels = null;
  private byte[] FrameData = null;
  private int imageFormat;
  private int PreviewSizeWidth;
  private int PreviewSizeHeight;
  private boolean bProcessing = false;
 
  Handler mHandler = new Handler(Looper.getMainLooper());
  
  public CameraPreview(int PreviewlayoutWidth, int PreviewlayoutHeight,
     ImageView CameraPreview)
  {
    PreviewSizeWidth = PreviewlayoutWidth;
    PreviewSizeHeight = PreviewlayoutHeight;
    MyCameraPreview = CameraPreview;
    bitmap = Bitmap.createBitmap(PreviewSizeWidth, PreviewSizeHeight, Bitmap.Config.ARGB_8888);
    pixels = new int[PreviewSizeWidth * PreviewSizeHeight];
  }

  @Override
  public void onPreviewFrame(byte[] arg0, Camera arg1) 
  {
    // At preview mode, the frame data will push to here.
    if (imageFormat == ImageFormat.NV21)
    {
      //We only accept the NV21(YUV420) format.
      if ( !bProcessing )
      {
        FrameData = arg0;
        mHandler.post(DoImageProcessing);
      }
    }
  }
 
  public void onPause()
  {
    mCamera.stopPreview();
  }

  @Override
  public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) 
  {
    Parameters parameters;
  
    parameters = mCamera.getParameters();
    // Set the camera preview size
    parameters.setPreviewSize(PreviewSizeWidth, PreviewSizeHeight);
  
    imageFormat = parameters.getPreviewFormat();
  
    mCamera.setParameters(parameters);
  
    mCamera.startPreview();
  }

  @Override
  public void surfaceCreated(SurfaceHolder arg0) 
  {
    mCamera = Camera.open();
    try
    {
      // If did not set the SurfaceHolder, the preview area will be black.
      mCamera.setPreviewDisplay(arg0);
      mCamera.setPreviewCallback(this);
    } 
    catch (IOException e)
    {
      mCamera.release();
      mCamera = null;
    }
  }

  @Override
  public void surfaceDestroyed(SurfaceHolder arg0) 
  {
     mCamera.setPreviewCallback(null);
  mCamera.stopPreview();
  mCamera.release();
  mCamera = null;
  }

  //
  // Native JNI 
  //
  public native boolean ImageProcessing(int width, int height, 
      byte[] NV21FrameData, int [] pixels);
  static 
  {
     System.loadLibrary(&quot;ImageProcessing&quot;);
  }
    
  private Runnable DoImageProcessing = new Runnable() 
  {
    public void run() 
    {
      Log.i(&quot;MyRealTimeImageProcessing&quot;, &quot;DoImageProcessing():&quot;);
      bProcessing = true;
      ImageProcessing(PreviewSizeWidth, PreviewSizeHeight, FrameData, pixels);
      
      bitmap.setPixels(pixels, 0, PreviewSizeWidth, 0, 0, PreviewSizeWidth, PreviewSizeHeight);
      MyCameraPreview.setImageBitmap(bitmap);
      bProcessing = false;
    }
  };
}
&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Step2:&lt;/span&gt;&lt;/b&gt;Create a JNI cpp file to do the image processing.
&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;/*
*  ImageProcessing.cpp
*/
#include &amp;lt;jni.h&amp;gt;

#include &amp;lt;opencv2/core/core.hpp&amp;gt;
#include &amp;lt;opencv2/imgproc/imgproc_c.h&amp;gt;

using namespace std;
using namespace cv;

Mat * mCanny = NULL;

extern &quot;C&quot;
jboolean
Java_my_project_MyRealTimeImageProcessing_CameraPreview_ImageProcessing(
    JNIEnv* env, jobject thiz,
    jint width, jint height,
    jbyteArray NV21FrameData, jintArray outPixels)
{
  jbyte * pNV21FrameData = env-&amp;gt;GetByteArrayElements(NV21FrameData, 0);
  jint * poutPixels = env-&amp;gt;GetIntArrayElements(outPixels, 0);

  if ( mCanny == NULL )
  {
    mCanny = new Mat(height, width, CV_8UC1);
  }

  Mat mGray(height, width, CV_8UC1, (unsigned char *)pNV21FrameData);
  Mat mResult(height, width, CV_8UC4, (unsigned char *)poutPixels);
  IplImage srcImg = mGray;
  IplImage CannyImg = *mCanny;
  IplImage ResultImg = mResult;

  cvCanny(&amp;amp;srcImg, &amp;amp;CannyImg, 80, 100, 3);
  cvCvtColor(&amp;amp;CannyImg, &amp;amp;ResultImg, CV_GRAY2BGRA);

  env-&amp;gt;ReleaseByteArrayElements(NV21FrameData, pNV21FrameData, 0);
  env-&amp;gt;ReleaseIntArrayElements(outPixels, poutPixels, 0);
  return true;
}
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;Create a instance in the main class.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MyRealTimeImageProcessing extends Activity 
{
  private CameraPreview camPreview;
  private ImageView MyCameraPreview = null;
  private FrameLayout mainLayout;
  private int PreviewSizeWidth = 640;
  private int PreviewSizeHeight= 480;
  
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {
    super.onCreate(savedInstanceState);
    //Set this APK Full screen
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //Set this APK no title
    requestWindowFeature(Window.FEATURE_NO_TITLE);  
    setContentView(R.layout.main);
        
    //
    // Create my camera preview 
    //
    MyCameraPreview = new ImageView(this);

    SurfaceView camView = new SurfaceView(this);
    SurfaceHolder camHolder = camView.getHolder();
    camPreview = new CameraPreview(PreviewSizeWidth, PreviewSizeHeight, MyCameraPreview);
        
    camHolder.addCallback(camPreview);
    camHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        
        
    mainLayout = (FrameLayout) findViewById(R.id.frameLayout1);
    mainLayout.addView(camView, new LayoutParams(PreviewSizeWidth, PreviewSizeHeight));
    mainLayout.addView(MyCameraPreview, new LayoutParams(PreviewSizeWidth, PreviewSizeHeight));
  }
  protected void onPause()
  {
    if ( camPreview != null)
      camPreview.onPause();
    super.onPause();
 }
}
&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Step4:&lt;/span&gt;&lt;/b&gt;The preview will be the canny image process result.
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKgVX2p4YitZPm8Dcx8iA6eVhA1ku8xoNUb3vKw2VO7f7zvnR7WpN6YxrQ0Kt8Ha9EXGe41vnrYIPt9jg8bvaIqVZTDjWkL0LCls2D7J9RDLijD1pjxys1z3yWMIMuvw3FCkcjq6LHapQ/s1600/device.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKgVX2p4YitZPm8Dcx8iA6eVhA1ku8xoNUb3vKw2VO7f7zvnR7WpN6YxrQ0Kt8Ha9EXGe41vnrYIPt9jg8bvaIqVZTDjWkL0LCls2D7J9RDLijD1pjxys1z3yWMIMuvw3FCkcjq6LHapQ/s400/device.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;


&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/2267864010589605227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-do-real-time-image-processing-in.html#comment-form' title='89 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/2267864010589605227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/2267864010589605227'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-do-real-time-image-processing-in.html' title='How to do real time image processing in Android using OpenCV?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKgVX2p4YitZPm8Dcx8iA6eVhA1ku8xoNUb3vKw2VO7f7zvnR7WpN6YxrQ0Kt8Ha9EXGe41vnrYIPt9jg8bvaIqVZTDjWkL0LCls2D7J9RDLijD1pjxys1z3yWMIMuvw3FCkcjq6LHapQ/s72-c/device.png" height="72" width="72"/><thr:total>89</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-3090101933166367874</id><published>2012-08-08T11:14:00.000+08:00</published><updated>2012-08-08T18:40:20.563+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>How to use Android sensors?</title><content type='html'>This article teaches how to use Android sensors.&lt;br /&gt;
&lt;br /&gt;
The Android sensors are hardware devices. Android provides a manager to control the devices.User should register the devices you want to use by the manager. And implements the callback functions for the sensor event alert.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step1:&lt;/span&gt;We create a new class for the sensors. This is a reusable class.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class SensorController implements SensorEventListener 
{
 public SensorController(Context context)
 {
 }
 @Override
 public void onAccuracyChanged(Sensor arg0, int arg1) 
 {
  // TODO Auto-generated method stub
 }
 @Override
 public void onSensorChanged(SensorEvent arg0) 
 {
  // TODO Auto-generated method stub
 }
}
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step2:&lt;/span&gt;The class implements two interface for the sensor events.In the class constructor we need the Context to get the sensor manager.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; private SensorManager mSensorManager = null;

 public SensorController(Context context)
 {
   mSensorManager = (SensorManager)context.getSystemService(context.SENSOR_SERVICE);
   registerSensor(); 
 }
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step3:&lt;/span&gt;Create the registerSensor() function to register the sensors.At this example i register the magnetic and accelerometer. These two sensor can combined to create a compass on Android.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; private Boolean sensorRegisteredFlag = false;
 private void registerSensor()
 {
  if(mSensorManager != null)
  {
   List&lt;sensor&gt; sensors = mSensorManager.getSensorList(Sensor.TYPE_MAGNETIC_FIELD);
   if(sensors.size() &amp;gt; 0)
   {
    Sensor sensor = sensors.get(0);
    //if(!mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL))
    if(!mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME))//faster than SENSOR_DELAY_NORMAL
    {
     return;
    }
   }
   sensors = mSensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
   if(sensors.size() &amp;gt; 0)
   {
    Sensor sensor = sensors.get(0);
    //if(!mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL))
    if(!mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME))//faster than SENSOR_DELAY_NORMAL
    {
     return;
    }
   }
   sensorRegisteredFlag = true;
  }
 }
&lt;/sensor&gt;&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step4:&lt;/span&gt;The onAccuracyChanged() method is called when the sensor accuracy has changed.
The first parameter is the sensor of the registered. And the other parameter is the new accuracy of the sensor.There are four value of the accuracy.At this example we does not care the changes.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;SensorManager.SENSOR_STATUS_ACCURACY_HIGH 
    // This sensor is reporting data with maximum accuracy

SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM 
    // This sensor is reporting data with an average level of accuracy, 
    // calibration with the environment may improve the readings

SensorManager.SENSOR_STATUS_ACCURACY_LOW 
    // This sensor is reporting data with low accuracy, 
    // calibration with the environment is needed

SensorManager.SENSOR_STATUS_UNRELIABLE 
    // The values returned by this sensor cannot be trusted, 
    // calibration is needed or the environment doesn&#39;t allow readings
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step5:&lt;/span&gt;The onSensorChanged() method is whole thing we want.We collect the magnetic and accelerometer values and convert to the human readable values.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; private final double RADIANS_TO_DEGREES = 180/Math.PI;
 private final float[] sZVector = { 0, 0, 1, 1 };
 private float R[] = new float[16];
 private float remapR[] = new float[16];
 private float remapR_inv[] = new float[16];
 private float AccelerometerValues_last[] = new float[3];
 private float MagneticFieldValues_last[] = new float[3];
 private float orientationValues[] = new float[3];
 private float orientationVector[] = new float[4];
 private float azimuthVector[] = new float[4];
 boolean bHaveAccelerometer = false;
 boolean bHaveMagneticField = false;
 private float orientation;//up direction
 private float azimuth;//aim to north
 private float pitch;

 public void onSensorChanged(SensorEvent event) 
 {
  if(event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD)
  {
   MagneticFieldValues_last[0] = event.values[0];
   MagneticFieldValues_last[1] = event.values[1];
   MagneticFieldValues_last[2] = event.values[2];
   
   bHaveMagneticField = true;
  }
  if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
  {
   AccelerometerValues_last[0] = event.values[0];
   AccelerometerValues_last[1] = event.values[1];
   AccelerometerValues_last[2] = event.values[2];
   
   bHaveAccelerometer = true;
  }
  if(bHaveMagneticField &amp;amp;&amp;amp; bHaveAccelerometer)
  {
   if(SensorManager.getRotationMatrix(R, null, AccelerometerValues_last, MagneticFieldValues_last))
  {
   SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, remapR);
   SensorManager.getOrientation(remapR, orientationValues);
    
   Matrix.multiplyMV(orientationVector, 0, remapR, 0, sZVector, 0);
   pitch = (float) (-Math.atan2(orientationVector[1], orientationVector[2]) * RADIANS_TO_DEGREES);
    
   Matrix.multiplyMV(orientationVector, 0, remapR, 0, sZVector, 0);
   orientation = (float) (-Math.atan2(orientationVector[0], orientationVector[1]) * RADIANS_TO_DEGREES);
    
   Matrix.invertM(remapR_inv, 0, remapR, 0);
   Matrix.multiplyMV(azimuthVector, 0, remapR_inv, 0, sZVector, 0);
   azimuth = (float) (180 + Math.atan2(azimuthVector[0], azimuthVector[1]) * RADIANS_TO_DEGREES);
   }
  }
 }
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step6:&lt;/span&gt;Three important values we want are ready. Provide get method for the other class.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; public boolean getNowOrientation(float [] retValues) 
 {
  retValues[0] = pitch;
  retValues[1] = orientation;
  retValues[2] = azimuth;
  return true;
 } 
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step7:&lt;/span&gt;Implement the on action methods.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; public void onResume()
 {
  registerSensor();
 }
 
 public void onPause()
 {
  if(mSensorManager != null &amp;amp;&amp;amp; sensorRegisteredFlag)
  {
   mSensorManager.unregisterListener(this);
  }
 }
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step8:&lt;/span&gt;Back to the main activity class.Create a thread to get the values and refresh the values periodically.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MySensors extends Activity 
{
 private SensorController MySensors = null;
 private Handler mHandler = new Handler(Looper.getMainLooper());
 private TextView NowText = null;
 
 @Override
 public void onCreate(Bundle savedInstanceState) 
 {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
        
  MySensors = new SensorController(this);
        
  NowText = (TextView)findViewById(R.id.TextView01);
        
  mHandler.postDelayed(ReadSensorValues, 300);
 }
    
 private Runnable ReadSensorValues = new Runnable() 
 {
  float orientationValues[] = new float[3];
  public void run() 
  {
   MySensors.getNowOrientation(orientationValues);
         
   NowText.setText(&quot;pitch:&quot; + orientationValues[0] + &quot;\n&quot; +
                   &quot;orientation:&quot; + orientationValues[1] + &quot;\n&quot; +
                   &quot;azimuth:&quot; + orientationValues[2]);
         
   mHandler.postDelayed(ReadSensorValues, 100);
  }        
 };
 protected void onResume()
 {
  super.onResume();
  MySensors.onResume();
 }   
   
 protected void onPause()
 {
  super.onPause();
  MySensors.onPause();
 }    
}
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step9:&lt;/span&gt;Run the application, you should see the values beat in the TextView.

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX4Pa-JGujOR6yHVB5EDjxWTpFB9NZMMGeQx7f62mYt7bvRP09kudeGZizTBDH1YNMVIyXRrO83d6Tcg_6ZSgHGOeauYefUCFXFpUMRwv6djLmxN0Wf3A9cBLFhepLcxB_f5jpY41yXHY/s1600/device.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX4Pa-JGujOR6yHVB5EDjxWTpFB9NZMMGeQx7f62mYt7bvRP09kudeGZizTBDH1YNMVIyXRrO83d6Tcg_6ZSgHGOeauYefUCFXFpUMRwv6djLmxN0Wf3A9cBLFhepLcxB_f5jpY41yXHY/s400/device.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/3090101933166367874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-use-android-sensors.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3090101933166367874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3090101933166367874'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-use-android-sensors.html' title='How to use Android sensors?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX4Pa-JGujOR6yHVB5EDjxWTpFB9NZMMGeQx7f62mYt7bvRP09kudeGZizTBDH1YNMVIyXRrO83d6Tcg_6ZSgHGOeauYefUCFXFpUMRwv6djLmxN0Wf3A9cBLFhepLcxB_f5jpY41yXHY/s72-c/device.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-4179804213201113629</id><published>2012-08-07T10:17:00.000+08:00</published><updated>2012-08-08T18:41:18.856+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>How to use camera in Android?</title><content type='html'>This article teaches how to use Android camera.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Camera preview needs a surface to show.And needs some callback function to handle the take picture processes.&lt;br /&gt;
We create a class named CameraPreivew, and implement the SurfaceHolder.Callback and CameraPreviewCallback.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class CameraPreview implements SurfaceHolder.Callback, Camera.PreviewCallback
{
 public CameraPreview(int PreviewlayoutWidth, int PreviewlayoutHeight)
 {
  // TODO
 } 
 @Override
 public void onPreviewFrame(byte[] arg0, Camera arg1) 
 {
  // At preview mode, the frame data will push to here.
  // But we do not want these data.
 }

 @Override
 public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) 
 {
  // TODO Auto-generated method stub
 }

 @Override
 public void surfaceCreated(SurfaceHolder arg0) 
 {
  // TODO Auto-generated method stub
 }

 @Override
 public void surfaceDestroyed(SurfaceHolder arg0) 
 {
  // TODO Auto-generated method stub
 }

 // Take picture interface
 public void CameraTakePicture(String FileName)
 {
  // TODO 
 }
 
 // Set auto-focus interface
 public void CameraStartAutoFocus()
 {
  // TODO 
 }
}&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;
&lt;/span&gt;At the class constructor, we set the preview size.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
public CameraPreview(int PreviewlayoutWidth, int PreviewlayoutHeight)
{
 PreviewSizeWidth = PreviewlayoutWidth;
 PreviewSizeHeight = PreviewlayoutHeight;
}
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Step3:&lt;/b&gt;&lt;/span&gt;At the SurfaceHolder callback functions, we handle the camera instance.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) 
{
  Parameters parameters;
  mSurfHolder = arg0;
  
  parameters = mCamera.getParameters();
  // Set the camera preview size
  parameters.setPreviewSize(PreviewSizeWidth, PreviewSizeHeight);
  // Set the take picture size, you can set the large size of the camera supported.
  parameters.setPictureSize(PreviewSizeWidth, PreviewSizeHeight);
  
  // Turn on the camera flash. 
  String NowFlashMode = parameters.getFlashMode();
  if ( NowFlashMode != null )
   parameters.setFlashMode(Parameters.FLASH_MODE_ON);
  // Set the auto-focus. 
  String NowFocusMode = parameters.getFocusMode ();
  if ( NowFocusMode != null )
   parameters.setFocusMode(&quot;auto&quot;);
  
  mCamera.setParameters(parameters);
  
  mCamera.startPreview();
}

@Override
public void surfaceCreated(SurfaceHolder arg0) 
{
 mCamera = Camera.open();
 try
 {
  // If did not set the SurfaceHolder, the preview area will be black.
  mCamera.setPreviewDisplay(arg0);
  mCamera.setPreviewCallback(this);
 } 
 catch (IOException e)
 {
  mCamera.release();
  mCamera = null;
 }
}

@Override
public void surfaceDestroyed(SurfaceHolder arg0) 
{
 mCamera.setPreviewCallback(null);
 mCamera.stopPreview();
 mCamera.release();
 mCamera = null;
}
&lt;/pre&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step4:&lt;/span&gt;In the PreviewCallback, we call the myAutoFocusCallback to handle the take picture processes after the auto-focus.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
// Take picture interface
public void CameraTakePicture(String FileName)
{
 TakePicture = true;
 NowPictureFileName = FileName;
 mCamera.autoFocus(myAutoFocusCallback);
}
 
// Set auto-focus interface
public void CameraStartAutoFocus()
{
 TakePicture = false;
 mCamera.autoFocus(myAutoFocusCallback);
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step5:&lt;/span&gt;Create a instance to implement the AutoFocusCallback.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback()
{
 public void onAutoFocus(boolean arg0, Camera NowCamera) 
 {
  if ( TakePicture )
  {
   NowCamera.stopPreview();//fixed for Samsung S2
   NowCamera.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback);
   TakePicture = false;
  }
 }
};
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step6:&lt;/span&gt;Implement 3 callback instance to handle the takepicture processes.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
ShutterCallback shutterCallback = new ShutterCallback()
{
 public void onShutter() 
 {
  // Just do nothing.
 }
};
   
PictureCallback rawPictureCallback = new PictureCallback()
{
 public void onPictureTaken(byte[] arg0, Camera arg1) 
 {
  // Just do nothing.
 }
};
   
PictureCallback jpegPictureCallback = new PictureCallback()
{
 public void onPictureTaken(byte[] data, Camera arg1) 
 {
  // Save the picture.
  try {
   Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0,data.length);
   FileOutputStream out = new FileOutputStream(NowPictureFileName);
   bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
  } 
  catch (IOException e) 
  {
   e.printStackTrace();
  }
 }
}; 
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step7:&lt;/span&gt;The camera basic function we all implemented, now we go back to the main activity to use the CameraPreview.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
public class MyCamera extends Activity
{
 private CameraPreview camPreview; 
 private FrameLayout mainLayout;
     
 private Handler mHandler = new Handler(Looper.getMainLooper());
 
 @Override
 public void onCreate(Bundle savedInstanceState) 
 {
  super.onCreate(savedInstanceState);
  //Set this SPK Full screen
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  WindowManager.LayoutParams.FLAG_FULLSCREEN);
  //Set this APK no title
  requestWindowFeature(Window.FEATURE_NO_TITLE);  
  setContentView(R.layout.main);
        
  SurfaceView camView = new SurfaceView(this);
  SurfaceHolder camHolder = camView.getHolder();
  camPreview = new CameraPreview(640, 480);
        
  camHolder.addCallback(camPreview);
  camHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        
  mainLayout = (FrameLayout) findViewById(R.id.frameLayout1);
  mainLayout.addView(camView, new LayoutParams(640, 480));
 }

 @Override 
 public boolean onTouchEvent(MotionEvent event) 
 { 
  if (event.getAction() == MotionEvent.ACTION_DOWN) 
  { 
   int X = (int)event.getX(); 
   if ( X &amp;gt;= 640 )
    mHandler.postDelayed(TakePicture, 300);
   else
    camPreview.CameraStartAutoFocus();
  }
  return true;
 };
    
 private Runnable TakePicture = new Runnable() 
 {
  String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
  String MyDirectory_path = extStorageDirectory;
  String PictureFileName;
  public void run() 
  {
   File file = new File(MyDirectory_path);
   if (!file.exists()) 
    file.mkdirs();
   PictureFileName = MyDirectory_path + &quot;/MyPicture.jpg&quot;;
   camPreview.CameraTakePicture(PictureFileName);
 }
 };    
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Step8:&lt;/span&gt;The code is all done here, now is to setup the Android configuration to active the Camera hardware.Edit AndroidManifest.xml to active the function we need.
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 

&lt;manifest android:versioncode=&quot;1&quot; android:versionname=&quot;1.0&quot; package=&quot;my.project.MyCamera&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
    &lt;uses -sdk=&quot;-sdk&quot; android:minsdkversion=&quot;8&quot;&gt;
    &lt;uses -feature=&quot;-feature&quot; android:name=&quot;android.hardware.camera&quot;&gt;  
 &lt;uses -feature=&quot;-feature&quot; android:name=&quot;android.hardware.camera.autofocus&quot;&gt;
    &lt;uses -permission=&quot;-permission&quot; android:name=&quot;android.permission.CAMERA&quot;&gt;&lt;/uses&gt;
 &lt;uses -permission=&quot;-permission&quot; android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;&gt;&lt;/uses&gt;
 
 &lt;uses -permission=&quot;-permission&quot; android:name=&quot;android.permission.FLASHLIGHT&quot;&gt;

    &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt;
        &lt;activity android:label=&quot;@string/app_name&quot; android:name=&quot;.MyCamera&quot; android:screenorientation=&quot;landscape&quot;&gt;
            &lt;intent -filter=&quot;-filter&quot;&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot;&gt;
                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;&gt;
            &lt;/category&gt;&lt;/action&gt;&lt;/intent&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/uses&gt;&lt;/uses&gt;&lt;/uses&gt;&lt;/uses&gt;&lt;/manifest&gt;
&lt;/pre&gt;
&lt;br /&gt;
Step9:And the layout file main.xml should be simple like this.
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 

&lt;framelayout android:id=&quot;@+id/frameLayout1&quot; android:layout_height=&quot;fill_parent&quot; android:layout_width=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
&lt;/framelayout&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/4179804213201113629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-use-camera-in-android.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4179804213201113629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4179804213201113629'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-use-camera-in-android.html' title='How to use camera in Android?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-4796607958767152067</id><published>2012-08-01T09:07:00.000+08:00</published><updated>2012-08-08T18:41:34.915+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>How to use Runnable in Android?</title><content type='html'>This article teaches how to use Runnable class in Android. &lt;br /&gt;
&lt;br /&gt;
There are two ways to use thread class.&lt;br /&gt;
One is directly used in the Thread.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;&lt;br /&gt;
new Thread(new Runnable() 
{
    @Override
    public void run() 
    {
        //Do things.
    }
     
}).start();
&lt;/pre&gt;&lt;br /&gt;

Another way is create a new class extend the Runnable interface, and implement the run() function.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;

public class MyClass extends Activity 
{
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        Handler mHandler = new Handler(Looper.getMainLooper());

        // Do it after 300 ms.
        mHandler.postDelayed(DoThings, 300);

        // Or do it right away.
        //mHandler.post(DoThings);
    }    

    private Runnable DoThings = new Runnable() 
    {
        public void run() 
        {
            // Do things.
        }        
    };
}
&lt;/pre&gt;
&lt;br/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/4796607958767152067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-use-runnable-in-android.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4796607958767152067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4796607958767152067'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/08/how-to-use-runnable-in-android.html' title='How to use Runnable in Android?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-5821049915085230941</id><published>2012-07-31T09:51:00.000+08:00</published><updated>2012-08-08T18:41:44.635+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>How to use thread in Android?</title><content type='html'>This article teaches how to use thread class in Android.&lt;br /&gt;
&lt;br /&gt;
There are two ways to use thread class.&lt;br /&gt;
One is directly used in the function.&lt;br /&gt;
The Runnable class is the job to do.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;&lt;br /&gt;
new Thread(new Runnable() 

{
    @Override
    public void run() 
    {
        //Do things.
    }
    
}).start();
&lt;/pre&gt;
&lt;br /&gt;
Another is create a new class and extend the thread interface.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;&lt;br /&gt;
public class MyThread extends Thread
{
    public void run() 
    {
        //Do things. 
    }
}
&lt;/pre&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/5821049915085230941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-use-thread-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/5821049915085230941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/5821049915085230941'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-use-thread-in-android.html' title='How to use thread in Android?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-2956484496202296805</id><published>2012-07-27T10:46:00.000+08:00</published><updated>2012-08-08T18:32:34.638+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>How to create Android JNI</title><content type='html'>This article teaches how to create Android JNI applicatoin.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step1&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;:&lt;/span&gt;&lt;/b&gt;Open Android workspace in Eclipse.The workspace we create for the JNI development.Refer to this article &lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/how-to-install-android-ndk-on-windows.html&quot;&gt;How to install Android NDK on windows&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step2:&lt;/span&gt;&lt;/b&gt;Create a new Android Project.Eclipse toolbar-&amp;gt;New-&amp;gt;Android Project.Create a new project directory in the Cygwin directory.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwblQgqPlJK2p4OZ3thxiZS9HrfVywiC-Eiaw_bAsYDl_zqn75rDhEoog2vIqYwRee7PFA7vVCiQi2QpoLBJM_2Mi1vVkNFpIpUW2Gje1F2G-CtN4nJCee-jnO4cfw65H2CfkUQLXPLIg/s1600/MyFirstJNI_1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwblQgqPlJK2p4OZ3thxiZS9HrfVywiC-Eiaw_bAsYDl_zqn75rDhEoog2vIqYwRee7PFA7vVCiQi2QpoLBJM_2Mi1vVkNFpIpUW2Gje1F2G-CtN4nJCee-jnO4cfw65H2CfkUQLXPLIg/s400/MyFirstJNI_1.PNG&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clicking finish button. A new project in the workspace.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge8L-jK4hun-MD8uOM_B5cRQbA2JsqhZbFEZRgN2hLKUqq3yekuW_Alq-z4VEnB3i1n5q-FKuYUot1InmXFBaYKJuGbZsmjFb8FnbWt13Tq2HDF4ogwgPZcyxGwLUObsr6DqwVySzeTbk/s1600/MyFirstJNI_2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge8L-jK4hun-MD8uOM_B5cRQbA2JsqhZbFEZRgN2hLKUqq3yekuW_Alq-z4VEnB3i1n5q-FKuYUot1InmXFBaYKJuGbZsmjFb8FnbWt13Tq2HDF4ogwgPZcyxGwLUObsr6DqwVySzeTbk/s400/MyFirstJNI_2.PNG&quot; width=&quot;326&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step3:&lt;/span&gt;&lt;/b&gt;Manually create 2 directories in the project directory, JNI and libs.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step4:&lt;/span&gt;&lt;/b&gt;Creating Andoird.mk file in the JNI directory.Android.mk is just a text file.&lt;br /&gt;
Android.mk file contents:&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := first-jni
LOCAL_SRC_FILES := first-jni.cpp
include $(BUILD_SHARED_LIBRARY)
&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step5:&lt;/span&gt;&lt;/b&gt;Creating &amp;nbsp;your jni C/C++ file in the JNI directory.Aftercompile the jni code  successfully . There is a dynamatic link library(libfirst-jni.so) will be created in the libs directory we create manually before.&lt;br /&gt;
The jni code has two different type, C and C++.The difference is C++ file must export it&#39;s JNI function to C.&lt;br /&gt;
The code explains it self.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;

/*
*  first-jni.c
*/
#include &amp;lt;string.h&amp;gt; 
#include &amp;lt;jni.h&amp;gt; 
 
jstring
Java_my_project_MyFirstJNI_MyFirstJNI_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)-&amp;gt;NewStringUTF(env, &quot;My first JNI!&quot;);
}
&lt;/pre&gt;
&amp;lt;&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;

/*
*  first-jni.cpp
*/
#include &amp;lt;string.h&amp;gt; 
#include &amp;lt;jni.h&amp;gt; 
 
extern &quot;C&quot;
jstring
Java_my_project_MyFirstJNI_MyFirstJNI_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return env-&amp;gt;NewStringUTF(&quot;My first JNI!&quot;);
}
&lt;/jni.h&gt;&lt;/string.h&gt;&lt;/pre&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Step6:&lt;/b&gt;&lt;/span&gt;The JNI function name has rules.Refer to this link &lt;a href=&quot;http://code.google.com/p/awesomeguy/wiki/JNITutorial#Naming_Functions&quot;&gt;Naming_Functions&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;Java_{Package name Replace dot with underline}_{Class name}_{function name}()&lt;/span&gt; ,&lt;br /&gt;
In my example will be the &lt;span style=&quot;color: orange;&quot;&gt;&quot;Java_&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;my_project_MyFirstJNI&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color: #93c47d;&quot;&gt;MyFirstJNI&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color: #c27ba0;&quot;&gt;stringFromJNI&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&quot;&lt;/span&gt;,&lt;br /&gt;
&lt;span style=&quot;color: #e06666;&quot;&gt;&quot;my_project_MyFirstJNI&quot;&lt;/span&gt; is the package name, &quot;package &amp;nbsp;my.project.MyFirstJNI;&quot;&lt;br /&gt;
&lt;span style=&quot;color: #93c47d;&quot;&gt;&quot;MyFirstJNI&quot;&lt;/span&gt; is my jni file class name.&lt;br /&gt;
&lt;span style=&quot;color: #c27ba0;&quot;&gt;&quot;stringFromJNI&quot;&lt;/span&gt;&amp;nbsp;is the jni function name for JAVA to call.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Step7&lt;/b&gt;:&lt;/span&gt;Now we had create our own jni function.Press F5 to refresh the Eclipse.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipO5jUcrCDxAhA5I71SyWOkL15dyJOhTSo6mFXtZxXH3QYUft26-5JhUevXc2NQq5-cNUh8vXzTOgINM1_JrmuOYjYWnoJNIo5dGHR9F29q3w6zh0Qk3aC4eyoNrGaKBF0LoEnBm0Kqwc/s1600/MyFirstJNI_3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipO5jUcrCDxAhA5I71SyWOkL15dyJOhTSo6mFXtZxXH3QYUft26-5JhUevXc2NQq5-cNUh8vXzTOgINM1_JrmuOYjYWnoJNIo5dGHR9F29q3w6zh0Qk3aC4eyoNrGaKBF0LoEnBm0Kqwc/s400/MyFirstJNI_3.PNG&quot; width=&quot;280&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Step8:&lt;/b&gt;&lt;/span&gt;Setup the Auto-build configuration, Please flow the steps in this article&amp;nbsp;&lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/how-to-install-android-ndk-on-windows.html&quot;&gt;How to install Android NDK on windows&lt;/a&gt;. Starting from Step11.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step9:&lt;/span&gt;&lt;/b&gt;Modify the JAVA code to call our JNI function.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package my.project.MyFirstJNI;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class MyFirstJNI extends Activity 
{
    // Called when the activity is first created.
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        TextView  tv = new TextView(this);
        tv.setText( stringFromJNI() );
        setContentView(R.layout.main);
    }
    // A native method that is implemented by the
    // &#39;first-jni&#39; native library, which is packaged
    // with this application.
    //
 
    public native String  stringFromJNI();
     
    // this is used to load the &#39;first-jni&#39; library on application
    // startup. The library has already been unpacked into
    // /data/data/my.project.MyFirstJNI/libs/libfirst-jni.so at
    // installation time by the package manager.
    //
    static
    {
        System.loadLibrary(&quot;first-jni&quot;);
    }
}
&lt;/pre&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Final Step:&lt;/b&gt;&lt;/span&gt;Run the project in emulator, the screen will show the string &quot;My first JNI!&quot;.


&lt;br/&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/2956484496202296805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-create-android-jni.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/2956484496202296805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/2956484496202296805'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-create-android-jni.html' title='How to create Android JNI'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwblQgqPlJK2p4OZ3thxiZS9HrfVywiC-Eiaw_bAsYDl_zqn75rDhEoog2vIqYwRee7PFA7vVCiQi2QpoLBJM_2Mi1vVkNFpIpUW2Gje1F2G-CtN4nJCee-jnO4cfw65H2CfkUQLXPLIg/s72-c/MyFirstJNI_1.PNG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-3076448213714881444</id><published>2012-07-26T16:26:00.001+08:00</published><updated>2012-08-08T18:42:06.992+08:00</updated><title type='text'>How to install Android NDK on windows</title><content type='html'>This article teaches how to install Android NDK in Eclipse on windows, and setup the configuration for auto-build JNI native library(.so).&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;First, you already install Android SDK on you PC.&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Step2:&lt;/b&gt;&lt;/span&gt;The difference between Android SDK and Android NDK, Android SDK is to create a pure  JAVA code application, and Android NDK is to create a JAVA application with the native library. The native library is a dynamic library. JAVA call the library through the JNI interface.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step3:&lt;/span&gt;&lt;/b&gt;The NDK content a cross compiler toolchain, must runs on the linux environment. The Cygwin create a linux-link environment on windows. This article shows &lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/cygwin.html&quot;&gt;How to install Cygwin on windows&lt;/a&gt;.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step4:&lt;/span&gt;&lt;/b&gt;Download the &lt;a href=&quot;http://developer.android.com/tools/sdk/ndk/index.html&quot;&gt;NDK from the office web site&lt;/a&gt;.&lt;br /&gt;
&lt;a href=&quot;http://dl.google.com/android/ndk/android-ndk-r8-windows.zip&quot;&gt;android-ndk-r8-windows.zip &lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step5:&lt;/span&gt;&lt;/b&gt;Unzipped the android-ndk-r8-windows.zip to the Cygwin root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step6:&lt;/span&gt;&lt;/b&gt;Append the path define code to the .bash_profile in the I:\cygwin\home\{US ER NAME}\.bash_profile.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;
PATH=/android-ndk-r8:${PATH}
NDK_ROOT=/android-ndk-r8
NDK_Sample=/android-ndk-r8/samples
export PATH NDK_ROOT NDK_Sample
&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step7:&lt;/span&gt;&lt;/b&gt;Click the batch file I:\cygwin\Cygwin.bat, enter Cygwin shell.&lt;br /&gt;
Change current Directory to the /android-ndk-r8/samples/hello-jni/, and run the ndk-build command. The library ibhello-jni.so will be created.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl02U6YkfRGiDaenzdQOcNL_FalE12LTelPV_Iv-ZIvMSpBBYS0nViDhdEdOmmDPmtlbHbIFUoRwRhlMx0sld39pOwBTHipeFk4u3wIpTFxHpV5Yd7erRMvebgjvAtBzXgZfeINJgYWcY/s1600/CygwinInstall_16.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;261&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl02U6YkfRGiDaenzdQOcNL_FalE12LTelPV_Iv-ZIvMSpBBYS0nViDhdEdOmmDPmtlbHbIFUoRwRhlMx0sld39pOwBTHipeFk4u3wIpTFxHpV5Yd7erRMvebgjvAtBzXgZfeINJgYWcY/s400/CygwinInstall_16.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step8:&lt;/span&gt;&lt;/b&gt;When the library shows up. That means the environment of your Android NDK is ok.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step9:&lt;/span&gt;&lt;/b&gt;Let&#39;s start the real project of the Android. In the Eclipse we can open the exist project &quot;hello-jni&quot; from the NDK samples directory.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEindfWbGiz9mW5aAm7dW2KhpwDafcuC7TQbwaJbog68Vy_58beYL6TRecQi-kwLb9LKPCmvmWC_obqKybwY2GClr1wGkeLymd6grSxxcMlIrb1J19ToVp4ZzoZYnEwsDZIjsI_KcH775Qo/s1600/JNI_1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEindfWbGiz9mW5aAm7dW2KhpwDafcuC7TQbwaJbog68Vy_58beYL6TRecQi-kwLb9LKPCmvmWC_obqKybwY2GClr1wGkeLymd6grSxxcMlIrb1J19ToVp4ZzoZYnEwsDZIjsI_KcH775Qo/s400/JNI_1.PNG&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step10:&lt;/span&gt;&lt;/b&gt;In the Package Explorer, we can find the libs directory include the library libhello-jni.so we create before.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvLxIyBc5_rI665qehXOVODh7CeSJFHgDhxsWAVdtMf7yEmV1NhRdWymOVtMWHe5enZ_TexjMuzPXZOtPXibDsNe4jeXGXelShhC1cnRGe9eN7Lxkm52-5NhbUE9nIp81g4jUhtHbcAAI/s1600/JNI_2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvLxIyBc5_rI665qehXOVODh7CeSJFHgDhxsWAVdtMf7yEmV1NhRdWymOVtMWHe5enZ_TexjMuzPXZOtPXibDsNe4jeXGXelShhC1cnRGe9eN7Lxkm52-5NhbUE9nIp81g4jUhtHbcAAI/s400/JNI_2.PNG&quot; width=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step11:&lt;/span&gt;&lt;/b&gt;Now we need setup some configuration to create a auto-build environment.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Enter project properties-&amp;gt;Builders page, we create a new program builder.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWP08d70ZAPtKQqX5gBCBF75HtVcB6TtHmR7aVKheNpKUkw3s8v0-jg4SAlwgueIghwBl0m5HlOmeJfmp3qhyphenhyphenTKZJVshctopQBHZJS933QAd7G2VOFA-J8-wxWIYY_zZN810Y9ZZ5A0M/s1600/JNI_3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcWP08d70ZAPtKQqX5gBCBF75HtVcB6TtHmR7aVKheNpKUkw3s8v0-jg4SAlwgueIghwBl0m5HlOmeJfmp3qhyphenhyphenTKZJVshctopQBHZJS933QAd7G2VOFA-J8-wxWIYY_zZN810Y9ZZ5A0M/s400/JNI_3.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step12:&lt;/span&gt;&lt;/b&gt;Click OK to the next window, fill the text with specific info.&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Name: JNI_Builder&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Locations:I:\cygwin\bin\bash.exe&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Working Directory:I:\cygwin\bin&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Arguments: --login -c &quot;cd $NDK_Sample/hello-jni &amp;amp;&amp;amp; ndk-build&quot;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn_i7UeM6NWSuT2er6AHvE5ufhTEb5_DLWAv3fcjhY42Dxkkj7AcnwAoc7f0HdJz_6B7VBadHgSshh6Dxt0K_xA8vx0rkYc2xFvetdgEEgFGAIsSU0peEA-iMgVlqciJp8JBD8H9uZcco/s1600/JNI_4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn_i7UeM6NWSuT2er6AHvE5ufhTEb5_DLWAv3fcjhY42Dxkkj7AcnwAoc7f0HdJz_6B7VBadHgSshh6Dxt0K_xA8vx0rkYc2xFvetdgEEgFGAIsSU0peEA-iMgVlqciJp8JBD8H9uZcco/s400/JNI_4.PNG&quot; width=&quot;288&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step13:&lt;/span&gt;&lt;/b&gt;Switch to the Refersh page, checked Refresh resources upon completion and Specific resources.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9c_w7C2XGd12Bxg8QWEQ-qdQCnnSfcfQHBVx8zdBicSKXra_d9P4fFW-f0ckcuw6tgHBLb9eEPt6lJ2pqrjlb-Nf21PyT4775KUwe44CrDdZvnYFY6reHHu7UJ01N8feohzKU04QnJU8/s1600/JNI_8.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9c_w7C2XGd12Bxg8QWEQ-qdQCnnSfcfQHBVx8zdBicSKXra_d9P4fFW-f0ckcuw6tgHBLb9eEPt6lJ2pqrjlb-Nf21PyT4775KUwe44CrDdZvnYFY6reHHu7UJ01N8feohzKU04QnJU8/s400/JNI_8.PNG&quot; width=&quot;315&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step14:&lt;/span&gt;&lt;/b&gt;In the pop-up window, we checked the libs directory. And click Finish back to the Edit Configuration window.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIy94wHjxYp5tvWlpzcRC7TEMTadz7H5d06A0rgQVKC8rrxVPhBpS-2JvvxvpFgl4v4w_BipHbznPVRcEj-v6BGqCbhucfFzRpkIPXuVUgcGBuq3F7z4gi-XA6NXO9bs8NBU5N7HsXz7s/s1600/JNI_7.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;395&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIy94wHjxYp5tvWlpzcRC7TEMTadz7H5d06A0rgQVKC8rrxVPhBpS-2JvvxvpFgl4v4w_BipHbznPVRcEj-v6BGqCbhucfFzRpkIPXuVUgcGBuq3F7z4gi-XA6NXO9bs8NBU5N7HsXz7s/s400/JNI_7.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step15:&lt;/span&gt;&lt;/b&gt;Switch to the Build Options page. Checked these options.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Allocate Console&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Launch in background&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;After a &quot;Clean&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;During manual builds&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;During auto builds&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Specify working set if relevant resources.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiELx2CRR60hWbhtVSJOMZQSByN9mnW6egd-im-QLjm_d4TuNWx8r_j1T_jS-aMlAXEI74COTblZkt5qVWVhVZokWrTIZZauJmZwdfHMbz9qHfCzpdqeTxuSPGxDfva-9MHNgDXOdLzlUs/s1600/JNI_10.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiELx2CRR60hWbhtVSJOMZQSByN9mnW6egd-im-QLjm_d4TuNWx8r_j1T_jS-aMlAXEI74COTblZkt5qVWVhVZokWrTIZZauJmZwdfHMbz9qHfCzpdqeTxuSPGxDfva-9MHNgDXOdLzlUs/s400/JNI_10.PNG&quot; width=&quot;315&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step16:&lt;/span&gt;&lt;/b&gt;Click the Specific Resources, We checked the jni directory.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJFqIRaDGApQJ-dDXfyM9XjGi51DbHn9Pu0ph7CSheHnaNI_zngWcR_C1h_tShEMh_vPiqIuuQvApKmQCF_SH5xFBQ__eAHi_M3IABr166vm8IZ5o3hh2IynUGi8KiXZle2V_S7TNRnxY/s1600/JNI_9.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;395&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJFqIRaDGApQJ-dDXfyM9XjGi51DbHn9Pu0ph7CSheHnaNI_zngWcR_C1h_tShEMh_vPiqIuuQvApKmQCF_SH5xFBQ__eAHi_M3IABr166vm8IZ5o3hh2IynUGi8KiXZle2V_S7TNRnxY/s400/JNI_9.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step17:&lt;/span&gt;&lt;/b&gt;Click the finish button, and in the Builders page, it has a new program named &quot;JNI_Builder&quot;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOUARGJiCFCuX8biuuExk7nHCGRnOwBD5saBQJO53wf-QXN_bV6oh38Tz870NBQDTOuN0SBpCvhnkv3UFxLyaNs46yjp7Dpw3PAn5c7qFObpQ0EXnA97JYQOU3W6DRVkIZQV_tAm07vp0/s1600/JNI_5.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOUARGJiCFCuX8biuuExk7nHCGRnOwBD5saBQJO53wf-QXN_bV6oh38Tz870NBQDTOuN0SBpCvhnkv3UFxLyaNs46yjp7Dpw3PAn5c7qFObpQ0EXnA97JYQOU3W6DRVkIZQV_tAm07vp0/s400/JNI_5.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step18:&lt;/span&gt;&lt;/b&gt;Click OK button, back to the Eclipse main page.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Step19:&lt;/span&gt;&lt;/b&gt;Edit the hello-jni.c file, then save. The JNI-Builder will start to compile native library. And the native library will be packed into the Android APK.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLvXPjbN4UnIsRT2lRD9AGNjewgelBaur7YfjVLcgQL1TUlRpwzeQFrBDmCCYQFkGgHGKpOyDWa0DfPKNG2nYfgvjObGwZ1wEsc8Wqab2hyphenhyphenRZfLt2iJkdDd5Eh66j3jJuNr6IrxPtFDJ4/s1600/JNI_11.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;162&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLvXPjbN4UnIsRT2lRD9AGNjewgelBaur7YfjVLcgQL1TUlRpwzeQFrBDmCCYQFkGgHGKpOyDWa0DfPKNG2nYfgvjObGwZ1wEsc8Wqab2hyphenhyphenRZfLt2iJkdDd5Eh66j3jJuNr6IrxPtFDJ4/s400/JNI_11.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/3076448213714881444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-install-android-ndk-on-windows.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3076448213714881444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/3076448213714881444'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-install-android-ndk-on-windows.html' title='How to install Android NDK on windows'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl02U6YkfRGiDaenzdQOcNL_FalE12LTelPV_Iv-ZIvMSpBBYS0nViDhdEdOmmDPmtlbHbIFUoRwRhlMx0sld39pOwBTHipeFk4u3wIpTFxHpV5Yd7erRMvebgjvAtBzXgZfeINJgYWcY/s72-c/CygwinInstall_16.PNG" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-363878971744398401</id><published>2012-07-25T17:19:00.001+08:00</published><updated>2012-08-08T18:42:21.831+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenGL"/><title type='text'>How to use OpenGL in Android</title><content type='html'>This article &amp;nbsp;teaches how to use OpenGL in Android phone.&lt;br /&gt;
There are two classes must be create and implement GLSurfaceView and Renderer.&lt;br /&gt;
The article&amp;nbsp;&lt;a href=&quot;http://developer.android.com/guide/topics/graphics/opengl.html&quot;&gt;OpenGL&lt;/a&gt;&amp;nbsp;explains classes do. I just focus the implement step.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Step1:&lt;/b&gt;&lt;/span&gt;Create a new project in the Eclipse. I supposed that you already known how.&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step2:&lt;/b&gt;.Modify the layout file &quot;main.xml&quot;.&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:id=&quot;@+id/frameLayout1&quot;&amp;gt;
&amp;lt;/FrameLayout&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step3:&lt;/b&gt;Create a new class i named OpenGLRenderer.The class must implement the Renderer class.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package my.project.MyFirstOpenGL;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLSurfaceView.Renderer;
import android.widget.FrameLayout;

public class OpenGLRenderer implements Renderer
{
 public OpenGLRenderer(Context context, FrameLayout mainLayout)
 {  
 }
 
 @Override
 public void onDrawFrame(GL10 arg0) 
 {
  // TODO Auto-generated method stub
  
 }

 @Override
 public void onSurfaceChanged(GL10 arg0, int arg1, int arg2) 
 {
  // TODO Auto-generated method stub
  
 }

 @Override
 public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) 
 {
  // TODO Auto-generated method stub
  
 }

}&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step4:&lt;/b&gt;In the OpenGLRenderer constructor, we need the Context and FrameLayout parameters.
And create the GLSurfaceView add to the frameLayout.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
public OpenGLRenderer(Context context, FrameLayout mainLayout)
{  
 this.context = context;
 //
 // Create GLSurfaceView and set this class as the renderer.
 //
 GLSurfaceView glView = new GLSurfaceView(context);
 glView.setRenderer(this);  
   
 //put to Main layout
 mainLayout.addView(glView, new LayoutParams(LayoutParams.FILL_PARENT,   LayoutParams.FILL_PARENT));
 }
&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step5:&lt;/b&gt;Put some basic OpenGL code to the other functions.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
 public void onDrawFrame(GL10 gl) 
 {
  // Clear the whole screen and depth.
  gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  
  // Setting the GL_MODELVIEW matrix
  gl.glMatrixMode(GL10.GL_MODELVIEW); 
  // Load the Identity matrix
  gl.glLoadIdentity();
 }
&lt;/pre&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
 public void onSurfaceChanged(GL10 gl, int width, int height) 
 {
  // Set OpenGL viewport
  gl.glViewport(0, 0, width, height);
  
  // Setting the GL_PROJECTION matrix
  gl.glMatrixMode(GL10.GL_PROJECTION);
  // Load the Identity matrix
  gl.glLoadIdentity();
  
  float ratio = (float) width / height;
  // Set the fovy to 45 degree. near depth is 0.1f and far depth is 100.f.
  // And maintain the screen ratio.
  GLU.gluPerspective(gl, 45, ratio, 0.1f, 100.f);
 }
&lt;/pre&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
 public void onSurfaceCreated(GL10 gl, EGLConfig arg1) 
 {
  // Set the background to black
  gl.glClearColor(0, 0, 0, 0);
 }&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step6:&lt;/b&gt;And now we can add OpenGLRenderer class to the main code.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    
 public void onCreate(Bundle savedInstanceState) 
 {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   FrameLayout mainLayout = (FrameLayout) findViewById(R.id.frameLayout1);
   //
   // Create OpenGL surface and render
   // 
   OpenGLRenderer gl3DView = new OpenGLRenderer(this, mainLayout);
 }&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step7:&lt;/b&gt;OK, We put the necessarily code to the project.Now we can run this project on emulator.But there is nothing in the screen but the black.

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-vE9kXvhF8gwSZZAknOElO-QMKFz4QpMveTgLHthuvMkRKHDhMJ_cCTUwJORIAZ0eHdsI5rCe8UA4RUyCs9yvO73USjJmkFnyxzs4zNfQJd-hFm4pwY4DUmytt9v-QsLVzeq7bneY-44/s1600/MyFirstOpenGl_1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-vE9kXvhF8gwSZZAknOElO-QMKFz4QpMveTgLHthuvMkRKHDhMJ_cCTUwJORIAZ0eHdsI5rCe8UA4RUyCs9yvO73USjJmkFnyxzs4zNfQJd-hFm4pwY4DUmytt9v-QsLVzeq7bneY-44/s320/MyFirstOpenGl_1.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step8:&lt;/b&gt;At this stage, we create a OpenGL environment, but we did not put things in there.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;I want load a picture and map to a plane , then rotate it.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; //
 // Load the  Texture
 //
 private void LoadTexture(GL10 gl, Context cont)
 {
   gl.glTexParameterf(GL10.GL_TEXTURE_2D, 
                         GL10.GL_TEXTURE_MAG_FILTER, 
                         GL10.GL_LINEAR);
   InputStream istream = cont.getResources().openRawResource(R.drawable.guam);
   
   Bitmap bitmap;
   try{
    bitmap = BitmapFactory.decodeStream(istream);
   }
   finally{
    try{
     istream.close();
    }
    catch(IOException e){}
   } 
   gl.glGenTextures(MAX_TEXTURE, textureID, 0);
   gl.glBindTexture(GL10.GL_TEXTURE_2D, textureID[0]);
   GLUtils.texImage2D( GL10.GL_TEXTURE_2D, 0, bitmap, 0 ); 
   gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
   
   bitmap.recycle();
   mTextureBuffer = getNativeFloatBuffer(squTex);
   mVerticesBuffer = getNativeFloatBuffer(squVtx);
   mIndexBuffer = getNativeShortBuffer(squInx);
 } 
&lt;/pre&gt;
&lt;pre class=&quot;brush:java&quot;&gt; //
 // Draw the scene
 //
 private void DrawTheScene(GL10 gl)
 { 
  gl.glEnable( GL10.GL_TEXTURE_2D);
  gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);  
  gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

  gl.glVertexPointer( 3, GL10.GL_FLOAT, 0, mVerticesBuffer);
  gl.glTexCoordPointer( 2, GL10.GL_FLOAT, 0, mTextureBuffer);
  
  gl.glBindTexture(GL10.GL_TEXTURE_2D, textureID[0]); 
  
  gl.glDrawElements( GL10.GL_TRIANGLE_FAN,
       squInx.length, 
                      GL10.GL_UNSIGNED_SHORT, 
                      mIndexBuffer);
  
  gl.glDisable(GL10.GL_TEXTURE_2D);
  gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
 } 
&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step9:&lt;/b&gt;We need some variables.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; private float orientation = 0.0f;;
 
 final int MAX_TEXTURE = 20;
 private int[] textureID = new int[MAX_TEXTURE];
 

 //     UV Coordinates             
 //          _________ 
 //  v0(0,0) |         | v3(1,0) 
 //          |         |
 //          |         |
 //  v1(0,1) |_________| v2(1,1)
 //
 //
 //   plane vertices
 //     _________ 
 //  p0 |         | p3 
 //     |         |
 //     |         |
 //  p1 |_________| p2
 //

 float squVtx[] = {   
            -1.0f,  1.0f,  0.0f, //p0 Left-Top corner
            -1.0f, -1.0f,  0.0f, //p1 Left-bottom corner 
             1.0f, -1.0f,  0.0f, //p2 Right-bottom corner 
             1.0f,  1.0f,  0.0f };//p3 Right-top corner 

 // USE GL_TRIANGLE_FAN
 short squInx[] = {  0, 1, 2, 3}; //0-1-2 first triangle
                                  //0-2-3 second triangle 
 float squTex[] ={  0.0f, 0.0f,  //v0 Left-Top corner
                    0.0f, 1.0f,  //v1 Left-bottom corner 
                    1.0f, 1.0f,  //v2 Right-top corner
                    1.0f, 0.0f };//v3 Right-bottom corner 
 
 // Our UV texture buffer.
 private FloatBuffer mTextureBuffer; 
 private FloatBuffer mVerticesBuffer;
 private ShortBuffer mIndexBuffer;
&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step10:&lt;/b&gt;Add LoadTexture() and DrawTheScene() to the code.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; public void onSurfaceCreated(GL10 gl, EGLConfig arg1) 
 {
  // Set the background to black
  gl.glClearColor(0, 0, 0, 0);
  
  //Load the texture
  LoadTexture(gl, context);  
 }
&lt;/pre&gt;
&lt;pre class=&quot;brush:java&quot;&gt; public void onDrawFrame(GL10 gl) 
 {
  // Clear the whole screen and depth.
  gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
  
  // Setting the GL_MODELVIEW matrix
  gl.glMatrixMode(GL10.GL_MODELVIEW); 
  // Load the Identity matrix
  gl.glLoadIdentity();
  
  // Move to Z = -10
  gl.glTranslatef(0, 0, -10f);
  // Rotate y-asix
  gl.glRotatef(orientation, 0, 1.0f, 0);
  
  //every time plus 1 defgee.
  orientation += 1.0f;
  if ( orientation &amp;gt;= 360 )
   orientation = 0.0f;

  // Draw the scene
  DrawTheScene(gl);
 }
&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step11:&lt;/b&gt;Another functions.
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; private FloatBuffer getNativeFloatBuffer(float[] buffer)
 {
  ByteBuffer ibb = ByteBuffer.allocateDirect(buffer.length*4);
  ibb.order(ByteOrder.nativeOrder());
  FloatBuffer fbf = ibb.asFloatBuffer();

  fbf.put(buffer);
  fbf.position(0);
  return fbf;
 } 
 
 private ShortBuffer getNativeShortBuffer(short[] buffer)
 {
  ByteBuffer ibb = ByteBuffer.allocateDirect(buffer.length*2);
  ibb.order(ByteOrder.nativeOrder());
  ShortBuffer sbf = ibb.asShortBuffer();

  sbf.put(buffer);
  sbf.position(0);
  return sbf;
 }&amp;nbsp;&lt;/pre&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step12:&lt;/b&gt;Finally, we put the picture to the OpenGL texture resources and draw 2 triangles to show the picture. Then rotate it frame by fame.


&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEhTWJjKRgXK5eX7RbHs-Hr1AU3l4IhBeyo0IagQeo5524q2NDrLkkeLybYrA7mhls3b5nHa7C-cCyZr961Tim5SlRGcY9qY5wJhvMz0DstdSLU1qArQIv2zLAgQVYeefUOLVXZSiLyrE/s1600/MyFirstOpenGL.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEhTWJjKRgXK5eX7RbHs-Hr1AU3l4IhBeyo0IagQeo5524q2NDrLkkeLybYrA7mhls3b5nHa7C-cCyZr961Tim5SlRGcY9qY5wJhvMz0DstdSLU1qArQIv2zLAgQVYeefUOLVXZSiLyrE/s320/MyFirstOpenGL.gif&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/363878971744398401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-use-opengl-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/363878971744398401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/363878971744398401'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-use-opengl-in-android.html' title='How to use OpenGL in Android'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-vE9kXvhF8gwSZZAknOElO-QMKFz4QpMveTgLHthuvMkRKHDhMJ_cCTUwJORIAZ0eHdsI5rCe8UA4RUyCs9yvO73USjJmkFnyxzs4zNfQJd-hFm4pwY4DUmytt9v-QsLVzeq7bneY-44/s72-c/MyFirstOpenGl_1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-4540687350033600770</id><published>2012-07-23T11:42:00.002+08:00</published><updated>2012-08-08T18:38:46.123+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android-OpenCV"/><title type='text'>How to use  Android-OpenCV JNI API</title><content type='html'>This article shows the steps to build the OpenCV JNI application under the Android.&lt;br /&gt;
Before type the copy, we need setup the environment.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step1:&lt;/b&gt;
First, we need Android JNI environment, you can refer to articles &lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/cygwin.html&quot;&gt;Install the Cygwin&lt;/a&gt;&amp;nbsp;and &lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/android-jni_20.html&quot;&gt;Install the NDK&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step2:&lt;/b&gt;Then, of course, we need the OpenCV library, you can refer to the article&amp;nbsp;&lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/androidopencv.html&quot;&gt;How to use OpenCV under Android&lt;/a&gt;&amp;nbsp;to install the OpenCV library. But there is a little difference, is the install directory. The OpenCV library &amp;nbsp;must installed in the Cygwin directory. In our example, I install the OpenCV library in the I:\Cygwin\JNI\OpenCV-2.4.0&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8vMLXokveBn_Z480X6BzqMZfnK5w3FI-DoWQeLVDTpjtse37gSKlyBw7daDEXOavJ9sKGvoFdvZ-8mxkuzNW5phcvlhM5aGjAg_-MDHvlbiqEsjYqEHl8Pvw_chzz-e20UldnfWMIOa4/s1600/Android-OpenCV-JNI-1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;116&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8vMLXokveBn_Z480X6BzqMZfnK5w3FI-DoWQeLVDTpjtse37gSKlyBw7daDEXOavJ9sKGvoFdvZ-8mxkuzNW5phcvlhM5aGjAg_-MDHvlbiqEsjYqEHl8Pvw_chzz-e20UldnfWMIOa4/s320/Android-OpenCV-JNI-1.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step3:&lt;/b&gt;Create a text file named &quot;includeOpenCV.mk&quot;, the file content shows below.&lt;br /&gt;
OPENCV_MK_PATH:=../OpenCV-2.4.0/share/OpenCV/OpenCV.mk&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step4:&lt;/b&gt;Now, we can start to create the OpenCV-JNI project.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Open the Eclipse, and load the workspace.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step5:&lt;/b&gt;Eclipse menu bar-&amp;gt;File-&amp;gt;New-&amp;gt;Android Project.The new project directory should be in the same directory as the OpenCV-2.4.0 library.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPp2K3l2tEzF9aKlXRhtEnzxPOAVrZdUlWguzsG1kQyXZedYdUZj4jEO4tZBRD2fBaEqUV1nII9hqm0t_PIMWdYZjrn1C25WM9RrxKWyNbfQwM8NS0w2pHdyLdNVtj7spEW96rCVr85uQ/s1600/Android-OpenCV-JNI-2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPp2K3l2tEzF9aKlXRhtEnzxPOAVrZdUlWguzsG1kQyXZedYdUZj4jEO4tZBRD2fBaEqUV1nII9hqm0t_PIMWdYZjrn1C25WM9RrxKWyNbfQwM8NS0w2pHdyLdNVtj7spEW96rCVr85uQ/s400/Android-OpenCV-JNI-2.PNG&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9Dy_3VStkskqIjxSQ7q-a7Q_fgUuTFJOiELpsgfe0yo4Ysnn5zSrnHfoqvyL56jBnTgFT_9SMf5ba6-k2eNRHhBxCmvmo5grf5P8dlttlWLMLRYFvGHqi1ANBLUbLAzY0CXBso7yJRDY/s1600/Android-OpenCV-JNI-3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;148&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9Dy_3VStkskqIjxSQ7q-a7Q_fgUuTFJOiELpsgfe0yo4Ysnn5zSrnHfoqvyL56jBnTgFT_9SMf5ba6-k2eNRHhBxCmvmo5grf5P8dlttlWLMLRYFvGHqi1ANBLUbLAzY0CXBso7yJRDY/s320/Android-OpenCV-JNI-3.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step6:&lt;/b&gt;Create the JNI and libs directories in the project directory. And setup the auto-compile configuration. Please to refer the article&amp;nbsp;&lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/android-jni.html&quot;&gt;Install the NDK&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step7:&lt;/b&gt;Create our JNI c++ code.&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt; 
/*
*  first-opencvjni.cpp
*/
#include &lt;jni .h=&quot;.h&quot;&gt;

#include &amp;lt;opencv2/core/core.hpp&amp;gt;
#include &amp;lt;opencv2/imgproc/imgproc_c.h&amp;gt;


using namespace cv;

extern &quot;C&quot;
jboolean
Java_my_project_MyFirstOpenCVJNI_MyFirstOpenCVJNI_CannyJNI( 
  JNIEnv* env, jobject thiz, 
  jint height, jint width, jintArray in, jintArray out)
{
 //get the data pointer.
 jint* _in = env-&amp;gt;GetIntArrayElements(in, 0);
    jint* _out = env-&amp;gt;GetIntArrayElements(out, 0);


 //Build the Mat structure for input data
 Mat mSrc(height, width, CV_8UC4, (unsigned char *)_in);
 //Build the Mat structure for output data
 Mat mOut(height, width, CV_8UC4, (unsigned char *)_out);

 //Convert Mat to IplImage
 IplImage mSrcImg = mSrc;
 IplImage mOutImg = mOut;

 //Create the gray image for input data.
 IplImage * mSrcGrayImg = cvCreateImage(cvGetSize(&amp;amp;mSrcImg), mSrcImg.depth, 1);
 IplImage * mOutGrayImg = cvCreateImage(cvGetSize(&amp;amp;mSrcImg), mSrcImg.depth, 1);

 //Convert to Gray image
 cvCvtColor(&amp;amp;mSrcImg, mSrcGrayImg, CV_BGR2GRAY);

 //Do canny
 cvCanny(mSrcGrayImg, mOutGrayImg, 80, 100, 3);


 //Convert Gray image to bitmap BGR
 cvCvtColor(mOutGrayImg, &amp;amp;mOutImg, CV_GRAY2BGR);

 //release the pointer. 
    env-&amp;gt;ReleaseIntArrayElements(in, _in, 0);
    env-&amp;gt;ReleaseIntArrayElements(out, _out, 0);
 return true;
}


&lt;/jni&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step8:&lt;/b&gt;Create the make file for Android JNI and OpenCV.
&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt; 
#
#  Android.mk
#

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_LIB_TYPE:=STATIC
OPENCV_INSTALL_MODULES:=on

include ../includeOpenCV.mk
include $(OPENCV_MK_PATH)

LOCAL_MODULE    := first-opencvjni
LOCAL_SRC_FILES := first-opencvjni.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt; 

#
#  Application.mk
#

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_MODULES := first-opencvjni
&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step9:&lt;/b&gt;Put the input image to do the canny() processes.In our example is foot.png.






&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinxlVfLqOSVilJGPPM5MtcPeRbVNFepf76MsX5KAcDQ9acEaT8p2Y_Hb0h6uM9ZkpFRgphycBfguUL0vDYQbXvOELSKWrYv7Y7FecRP5HwzoZMatcFZz10db0JIVEDLTBbQQGSLif0e50/s1600/foot.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinxlVfLqOSVilJGPPM5MtcPeRbVNFepf76MsX5KAcDQ9acEaT8p2Y_Hb0h6uM9ZkpFRgphycBfguUL0vDYQbXvOELSKWrYv7Y7FecRP5HwzoZMatcFZz10db0JIVEDLTBbQQGSLif0e50/s200/foot.png&quot; width=&quot;116&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step10:&lt;/b&gt;The entire project files in the Package Explorer.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhvJX9_zuwC7a4BJ5MMz7bksoQSfCq2T9STNAGa9MAYa7Zy2DZ6if3CGzwE9J9Z1I5zXZBn52vsZ8Zt5sni_uaZ6qIWfSqh7gDGSmN7o-rpNJYdJ2CSoR5sJTVPkJpkIYD5_jqKefG_m8/s1600/Android-OpenCV-JNI-4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhvJX9_zuwC7a4BJ5MMz7bksoQSfCq2T9STNAGa9MAYa7Zy2DZ6if3CGzwE9J9Z1I5zXZBn52vsZ8Zt5sni_uaZ6qIWfSqh7gDGSmN7o-rpNJYdJ2CSoR5sJTVPkJpkIYD5_jqKefG_m8/s400/Android-OpenCV-JNI-4.PNG&quot; width=&quot;178&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step11:&lt;/b&gt;When we do the thing&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;right&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;, the libs directory should have the library file &quot;libfirst-opencvjni.so&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step12:&lt;/b&gt;And out APK will be shown in the bin directory.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;b style=&quot;font-size: xx-large;&quot;&gt;Step13:&lt;/b&gt;Run the APK in the real Phone and result will be this.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNtEhSrgs3JtPwiRevQ2isdQ9IycXLGTedYKwPSPTuXGfyK_JJofan5gJd_HOtdkQSuODDV362AojvasVXCaGRTLlDUZRU59U5hLOYDZ2cc8er8q1G66dfxArZYBip3o-PnrVuCNzm7xA/s1600/outCanny.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNtEhSrgs3JtPwiRevQ2isdQ9IycXLGTedYKwPSPTuXGfyK_JJofan5gJd_HOtdkQSuODDV362AojvasVXCaGRTLlDUZRU59U5hLOYDZ2cc8er8q1G66dfxArZYBip3o-PnrVuCNzm7xA/s200/outCanny.png&quot; width=&quot;116&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

  var _gaq = _gaq || [];
  _gaq.push([&#39;_setAccount&#39;, &#39;UA-33962411-1&#39;]);
  _gaq.push([&#39;_trackPageview&#39;]);

  (function() {
    var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
    ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
    var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/4540687350033600770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-use-android-opencv-jni-api.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4540687350033600770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/4540687350033600770'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/how-to-use-android-opencv-jni-api.html' title='How to use  Android-OpenCV JNI API'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8vMLXokveBn_Z480X6BzqMZfnK5w3FI-DoWQeLVDTpjtse37gSKlyBw7daDEXOavJ9sKGvoFdvZ-8mxkuzNW5phcvlhM5aGjAg_-MDHvlbiqEsjYqEHl8Pvw_chzz-e20UldnfWMIOa4/s72-c/Android-OpenCV-JNI-1.PNG" height="72" width="72"/><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-249290266596149244.post-8806051276342587017</id><published>2012-07-20T13:03:00.001+08:00</published><updated>2012-07-27T12:10:47.114+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>建立自己的Android JNI程式</title><content type='html'>&lt;br /&gt;
本篇介紹如何重頭開始建立自己的Android JNI程式.&lt;br /&gt;
&lt;br /&gt;
1.開啟Eclipse, 並進入&lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/android-jni.html&quot;&gt;之前建立&lt;/a&gt;好的Workspace.&lt;br /&gt;
2.在此Workspace建立新專案, Eclipse 功能表-&amp;gt;File-&amp;gt;New-&amp;gt;Android Project.&lt;br /&gt;
3.填入專案資訊, 注意最好將專案位置放在Cygwin中, 因為&lt;span style=&quot;background-color: transparent;&quot;&gt;才可以讓&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;Android NDK自動編譯.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpXSbnxToX7JxuxDDLfdf_P0EYdMOpHAJy3Wysy_Nw9A26eysT6IkcgZLQye3EmrMAnHGKAbFgVFQlgIBehYiZXuVU0g9ZZzA1lfkMHQ54kaMlJmXbs-Jt_S_VpqQnISdGDxVWBaeN_qc/s1600/MyFirstJNI_1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpXSbnxToX7JxuxDDLfdf_P0EYdMOpHAJy3Wysy_Nw9A26eysT6IkcgZLQye3EmrMAnHGKAbFgVFQlgIBehYiZXuVU0g9ZZzA1lfkMHQ54kaMlJmXbs-Jt_S_VpqQnISdGDxVWBaeN_qc/s400/MyFirstJNI_1.PNG&quot; width=&quot;308&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4.按下Finish,回到Eclipse主畫面, 看到Package Explorer中新增MyFirstJNI專案,會自動建立幾個APK專案的目錄.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEYagZ_ajrXa97g_UIamuRuWX_uvkosE4LnXUOB4NA4bPd6owB0Wi3NkzrJTJaP0l34IdEZKdcn80iz-5j1Enh_HNMrCk73lRlxta1svfCk4i38a7UMy0voAnkCeUPNoN42_Ze2nlWwBw/s1600/MyFirstJNI_2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEYagZ_ajrXa97g_UIamuRuWX_uvkosE4LnXUOB4NA4bPd6owB0Wi3NkzrJTJaP0l34IdEZKdcn80iz-5j1Enh_HNMrCk73lRlxta1svfCk4i38a7UMy0voAnkCeUPNoN42_Ze2nlWwBw/s320/MyFirstJNI_2.PNG&quot; width=&quot;261&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.接下來手動新增2個目錄, JNI與libs, JNI目錄是用來放C/C++的JNI source code, libs則是放產生的.so 動態連結函式庫.&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;6.在JNI中需要建立基本的2個檔案, Android.mk與你的C/C++檔案.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp;Android.mk的內容如下&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := first-jni
LOCAL_SRC_FILES := first-jni.cpp
include $(BUILD_SHARED_LIBRARY)
&lt;/pre&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
first-jni.cpp是你的C++原始檔檔名, first-jni則是會被compile成函式庫的名稱,最後的檔案名稱就會是libfirst-jni.so&lt;br /&gt;
&lt;br /&gt;
7.C與C++檔案需要再詳細解說一下, 如果是用C檔案,副檔名使用.c,使用C++檔案則是用.cpp,&lt;br /&gt;
有什麼差別呢? 有很大差別,會跟你的 code有關係, 因為JAVA 呼應JNI時是使用C的函式來呼叫使用, 所以如果是用C++檔案時, JNI的函式介面需要轉換成C函式才行.以下是範例.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;/*
*  first-jni.c
*/
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;jni.h&amp;gt;

jstring
Java_my_project_MyFirstJNI_MyFirstJNI_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)-&amp;gt;NewStringUTF(env, &quot;My first JNI!&quot;);
}
&lt;/pre&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;/*
*  first-jni.cpp
*/
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;jni.h&amp;gt;

extern &quot;C&quot;
jstring
Java_my_project_MyFirstJNI_MyFirstJNI_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return env-&amp;gt;NewStringUTF(&quot;My first JNI!&quot;);
}

&lt;/pre&gt;
C++的函式需要使用extern &quot;C&quot;的方式來export.參數env的使用方法也不一樣.&lt;br /&gt;
&lt;br /&gt;
8.JNI export的函式命名也是有規則的,此&lt;a href=&quot;http://code.google.com/p/awesomeguy/wiki/JNITutorial#Naming_Functions&quot;&gt;連結&lt;/a&gt;有說明, 規則如下&lt;br /&gt;
Java_{Package名稱,點換成底線}_{Class name}_{function name}()&lt;br /&gt;
以我們要建立的範例來看&quot;&lt;span style=&quot;background-color: transparent;&quot;&gt;Java_my_project_MyFirstJNI_MyFirstJNI_stringFromJNI&quot;&lt;/span&gt;&lt;br /&gt;
&quot;my_project_MyFirstJNI&quot;就會是我們的package名稱, &quot;package &amp;nbsp;my.project.MyFirstJNI;&quot;&lt;br /&gt;
&quot;MyFirstJNI&quot;就會是我們建立的class名稱.&lt;br /&gt;
&quot;stringFromJNI&quot;就是我們在JAVA code中要呼叫的函式名稱了.&lt;br /&gt;
&lt;br /&gt;
9.在Eclipse的Package Explorer中按下F5 refresh, 會出現我們建立的2個目錄(JNI,libs)與2個檔案.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUi4oZXCa8YIh9HEdyAKVuKwzA-mzdFUAuaBR0G5OsewofY_ESdF4nwwf-3D8VPLoTz78NqJeQD3QQVS-bRhi97RAhgnkRCgEHFKTZWElPr_JinEJ4Tw58rj-IMQJCMjxXAkEMGmrLqOo/s1600/MyFirstJNI_3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUi4oZXCa8YIh9HEdyAKVuKwzA-mzdFUAuaBR0G5OsewofY_ESdF4nwwf-3D8VPLoTz78NqJeQD3QQVS-bRhi97RAhgnkRCgEHFKTZWElPr_JinEJ4Tw58rj-IMQJCMjxXAkEMGmrLqOo/s320/MyFirstJNI_3.PNG&quot; width=&quot;224&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;10.接下來設定自動編譯, 在專案名稱上按右鍵,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;進入Properties.選擇Builders.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;在Builders右邊畫面選擇New.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;在跳出視窗中選擇Program,按下OK.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;接下來設定Builder, 可以&lt;a href=&quot;http://ibuzzlog.blogspot.tw/2012/07/android-jni.html&quot;&gt;參考此篇文章&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Name: MyFirstJNI_Builder&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Locations:I:\cygwin\bin\bash.exe&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Working Directory:I:\cygwin\bin&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Arguments: --login -c &quot;cd /JNI/MyFirstJNI&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp;&amp;amp;&amp;amp; ndk-build&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;這裡的&lt;/span&gt;
/JNI/MyFirstJNI&amp;nbsp;&lt;span style=&quot;background-color: transparent;&quot;&gt;目錄位置.不同專案需要設定不同的路徑.是相對於在Cygwin中login的home目錄位置.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;11.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;同樣在此視窗中切換到Refresh頁面.勾選Refresh resources upon completion.選擇Specific resources.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;12.&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;在跳出的視窗(Edit Working Set)中, 選擇MyFirstJNI下的libs目錄.按下Finish離開.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOdrzQaOHWvY1-9RkJSghA9JWipBM95cfb1tu66nzko_rydYgUoLv2hXByT5h3l-JsbJyubUFa4Eps6zP6k0EdFkCt-uKwCGTxOcX_WJWIszSjutLf3mvWLHpPpxxV-3lbprIFktJVVGQ/s1600/MyFirstJNI_4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;316&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOdrzQaOHWvY1-9RkJSghA9JWipBM95cfb1tu66nzko_rydYgUoLv2hXByT5h3l-JsbJyubUFa4Eps6zP6k0EdFkCt-uKwCGTxOcX_WJWIszSjutLf3mvWLHpPpxxV-3lbprIFktJVVGQ/s320/MyFirstJNI_4.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: transparent;&quot;&gt;13.&lt;/span&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;切換到Build Options, 勾選下列設定:&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Allocate Console&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Launch in background&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;After a &quot;Clean&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;During manual builds&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;During auto builds&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Specify working set if relevant resources.&lt;br /&gt;
14.點選Specify Resources, 選擇 MyFirstJNI下的JNI目錄, 當此目錄中檔案有變動時, 即啟動編譯.&lt;br /&gt;
15.設定完成後, 回到Eclipse, 打開我們的JNI檔案,first-jni.cpp, 隨便編輯一下後存檔.即可開始自動編譯, 完成後會出現函式庫檔案.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJKRSffAqEoSTyyXlbdfuctrj2qEEJShHXhvJA_cdohotw6yAJa8iqCwbSW5uEZmjbskygxHrREfJfySxgvUGCeTngBs0-vE5ZSd8jE2143zeQ1DqBWthHGAIwwZs7bsPiRHK3UCMFtyw/s1600/MyFirstJNI_5.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJKRSffAqEoSTyyXlbdfuctrj2qEEJShHXhvJA_cdohotw6yAJa8iqCwbSW5uEZmjbskygxHrREfJfySxgvUGCeTngBs0-vE5ZSd8jE2143zeQ1DqBWthHGAIwwZs7bsPiRHK3UCMFtyw/s320/MyFirstJNI_5.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
16.目前為止以成功產生我們的函式庫了, 但JAVA端還沒有來呼叫使用.&lt;br /&gt;
17.編輯&amp;nbsp;MyFirstJNI.java, 如以下程式.&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package my.project.MyFirstJNI;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MyFirstJNI extends Activity 
{
    // Called when the activity is first created.
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        TextView  tv = new TextView(this);
        tv.setText( stringFromJNI() );
        setContentView(R.layout.main);
    }
    // A native method that is implemented by the
    // &#39;first-jni&#39; native library, which is packaged
    // with this application.
    //

    public native String  stringFromJNI();
    
    // this is used to load the &#39;first-jni&#39; library on application
    // startup. The library has already been unpacked into
    // /data/data/my.project.MyFirstJNI/libs/libfirst-jni.so at
    // installation time by the package manager.
    //
    static 
    {
        System.loadLibrary(&quot;first-jni&quot;);
    }
}
&lt;/pre&gt;
18.編輯完成後,在Emulator中執行程式,會出現&quot;My first JNI!&quot;字串.</content><link rel='replies' type='application/atom+xml' href='http://ibuzzlog.blogspot.com/feeds/8806051276342587017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/android-jni_20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/8806051276342587017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/249290266596149244/posts/default/8806051276342587017'/><link rel='alternate' type='text/html' href='http://ibuzzlog.blogspot.com/2012/07/android-jni_20.html' title='建立自己的Android JNI程式'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/07320634714480218745</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpXSbnxToX7JxuxDDLfdf_P0EYdMOpHAJy3Wysy_Nw9A26eysT6IkcgZLQye3EmrMAnHGKAbFgVFQlgIBehYiZXuVU0g9ZZzA1lfkMHQ54kaMlJmXbs-Jt_S_VpqQnISdGDxVWBaeN_qc/s72-c/MyFirstJNI_1.PNG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>