Windows下Android OpenCV 2.2 安裝筆記

來源:互聯網
上載者:User


本文主要介紹在Windows上使用Cygwin工具構建Android OpenCV 2.2 以及 CVCamera Sample的過程。

參考:
http://opencv.willowgarage.com/wiki/Android2.2

準備:
JDK -

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Cygwin - 選擇ftp://mirrors.kernel.org這個鏡像,搜尋  Devel Install 安裝 gcc、make、swig等工具
Crystax NDK - http://www.crystax.net/android/ndk-r4.php
Ant - http://ant.apache.org/
Android SDK - http://developer.android.com/sdk/index.html
(最新代碼) -  svn checkout https://code.ros.org/svn/opencv/trunk/opencv)

安裝好以上包之後,系統內容變數裡Path需要添加Cygwin,Ant,Android SDK等包的可執行檔目錄。

構建過程:
1.Crystax NDK支援C++的RTTI、STL Ecxeption等特性,下載之後必須解壓到你的Home目錄下(如C:/cygwin/home/username),
在Cygwin中用ls檢查一下android-ndk-r4-crystax目錄是否包含了以下內容:
~/android-ndk-r4-crystax$ ls
build  docs  GNUmakefile  ndk-build  ndk-gdb  README.TXT  samples  sources

2.安裝Android SDK
安裝Android SDK 可以參考coolshell上的一篇文章,圖文並茂:
《Eclipse開發Android應用程式入門》http://coolshell.cn/articles/4270.html
其中還有配置 Eclipse的過程與入門樣本。
這一步只需要安裝好所下載的SDK即可。

3.構建android for OpenCV(假定OpenCV的主目錄為C:/opencv):
進入Cygwin
$cd c:
$cd opencv/android
$mkdir build
$cd build
$cmake ..
$make

4. 構建android-jni:
進入Cygwin
$cd opencv/android/android-jni
$make
此處,第一次make時可能會出現“local.env.mk”相關的警告,不管再make一次即可

進入Window命令列程式
在android-jni目錄下,執行Android SDK/tools中的android.bat:
C:/opencv/android/android-jni> android update project --name android-opencv --path ./
C:/opencv/android/android-jni> ant compile
此處,如果ant過程中出現以下錯誤:
BUILD FAILED
<android-sdk-root>/tools/ant/lib_rules.xml:121: Refrence android.libraries.src not found
找到android-jni目錄中的build.xml檔案,在</setup>後添加:
<path id="android.libraries.src"><path refid="project.libraries.src" /></path>
<path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>
重新執行ant compile即可。
(問題參考: http://code.google.com/p/android/issues/detail?id=13024)

5. 構建CVCamera工程:
進入Cygwin
cd opencv/android/apps/CVCamera
sh build.sh
同樣,第一次執行時可能會出現“local.env.mk”相關的警告,再執行一次

進入Window命令列程式
在CVCamera目錄下,執行Android SDK/tools中的android.bat:
C:/opencv/android/android-jni> android update project --name CVCamera --path ./
C:/opencv/android/android-jni> ant debug
C:/opencv/android/android-jni> ant install

這裡我碰到了BUILD FAILED
AndroidSDK/tools/ant/main_rules.xml:639: The following error occurred while executing this line:
AndroidSDK/tools/ant/main_rules.xml:271: exec returned: 1
查看main_rules.xml的271行:
<exec executable="${adb}" failonerror="true">改為<exec executable="${adb}" failonerror="false">
重新ant install成功

到這裡,Android OpenCV2.2 與 CVCamera便構建完畢了。

 

----------------------------------

作者:小斤(陳忻)

本文屬於原創文章,如需轉載引用請註明原文作者和連結,謝謝。

   

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.