(原創) 如何在VC8編譯libdecodeqr? (C/C++) (VC++) (Image Processing)

Abstract
libdecodeqr是一個open source的C/C++ QR code library,本文討論如何使用VC8編譯。

Introduction
QR code是最近很熱門的二維條碼,常可以在網站上看到,主要用來對url、文字、電話號碼或簡訊作編碼,然後透過手機上的CMOS相機作辨識。libdecoderq是一個open source的C/C++ QR code library,可以在http://trac.koka-in.org/libdecodeqr下載libdecodeqr-0.9.3.tar.bz2,由於libdecodeqr使用了OpenCV,須另外到http://sourceforge.net/projects/opencvlibrary/下載OpenCV_1.0.exe,若要在Windows平台執行,建議下載opencv-win 1.0,而不要下載ch-opencv 2.3.0或2.5.0版本,這兩個版本經我測試,無法與libdecodeqr搭配,只有opencv-win 1.0正常。

安裝OpenCV
由於libdecodeqr在編譯時,需要OpenCV,所以必須先安裝OpenCV。

Step 1:
執行OpenCV_1.0.exe,按<Next>繼續。

opencv_00

Step 2:
接受License,按<Next>繼續。

opencv_01

Step 3:
選擇安裝目錄,按<Next>繼續。

opencv_02

Step 4:
選擇程式集名稱,按<Next>繼續。

opencv_03

Step 5:
將\OpenCV\bin加入PATH系統變數,這步很重要,必須打勾,否則將來執行程式時,會找不到OpenCV的dll,按<Next>繼續。(在我的電腦,並不會自動將C:\Program Files\OpenCV\bin\加到PATH系統變數,必須手動加入,原因不明)

opencv_04

Step 6:
準備開始安裝,按<Next>繼續。

opencv_05

Step 7:
安裝成功。

opencv_06 


編譯libdecodeqr
Step 1:

將下載的libdecodeqr-0.9.3.tar.bz2解壓縮到\libdecodeqr-0.9.3\

Step 2:
用VC8開啟\libdecodeqr-0.9.3\src\libdecodeqr\libdecodeqr.dsw。

libdecodeqr.dsw是VC6的workspace檔,VC8開啟後會自動詢問你是否轉成VC8的格式,選擇<Yes To All>。

libdecodeqr_00

Step 3:
加入OpenCV header路徑

選擇libdecodeqr專案,按右鍵選擇Properties。

libdecodeqr_01

左側選Configuration Properties -> C/C++ -> General,右側選Additional Include Directories。

libdecodeqr_02

加入C:\Program Files\OpenCV\cv\include\ 與 c:\Program Files\OpenCV\cxcore\include\ 路徑,選擇<OK>。

libdecodeqr_03

最後如下圖所示。

 libdecodeqr_04

Step 4:
編譯libdecodeqr。 

 

加入測試程式
libdecodeqr本身提供了測試程式,放在\libdecodeqr-0.9.3\src\sample\simple\下,現在將這個project加入

Step 1:
新增simple專案

simple_00

加入\libdecodeqr-0.9.3\src\sample\simple\simple.dsw

simple_01

simple.dsp是VC6的workspace檔,VC8開啟後會自動詢問你是否轉成VC8的格式,選擇<Yes To All>。

simple_02

Step 2:
新增header路徑

simple_03

Step 3:
新增lib路徑

選擇libdecodeqr專案,按右鍵選擇Properties,左側選Configuration Properties -> Linker -> General,右側選Additional Library Directories。

simple_04

加入C:\Program Files\OpenCV\lib 路徑,選擇<OK>。

simple_05 

最後如下圖所示。

 simple_06 

Step 4:
編譯simple

Step 5:
測試simple

複製\libdecodeqr-0.9.3\img\01-1.jpg到\libdecodeqr-0.9.3\src\sample\simple\Debug\下,在Console模式將路徑切換到\libdecodeqr-0.9.3\src\sample\simple\Debug\,輸入

simple 01-1.jpg


出現以下結果

simple_07

simple_08

解出了以下url

http://www.amazon.co.jp/gp/aw/rd.html?uid=NULLGWDOCOMO&url=/gp/aw/h.html&at=aw_intl6-22


Conclusion

OpenCV是一個open source且free的llibrary,以前我不知道有這個好用的library,為了在C++作影像處理,而跑去用C++/CLI搭配.NET Framework,現在有了OpenCV,就可以在ISO C++下撰寫跨平台的影像處理程式了。

QR code是ISO 18004標準,有了libdecodeqr,除了可以在C++上解QR code,還可以研究它的source,了解QR code是如何解碼。

See Also
(原創) 如何在Linux下編譯OpenCV? (OS) (Linux) (CentOS) (Image Processing) (C/C++)
(原創) 如何在Linux下編譯libdecodeqr? (OS) (Linux) (CenOS) (Image Processing) (C/C++)

Reference
libdecodeqr : http://trac.koka-in.org/libdecodeqr
Open Computer Vision Library : http://sourceforge.net/projects/opencvlibrary/

posted on 2008-02-13 19:34  真 OO无双  阅读(8532)  评论(9编辑  收藏  举报

导航