2008年6月16日 星期一

[OpenCV]嵌入式ARM系統中安裝

OpenCV庫編譯

./configure --host=arm-linux --without-gtk --without-carbon  \
--without-quicktime --without-1394libs --without-ffmpeg \
--without-python --without-swig --enable-static --disable-shared \
--disable-apps CXX=armv4l-unknown-linux-g++ CPPFLAGS=-I/usr/include
  • --host=arm-linux :指出交叉編譯arm平臺
  • --without-gtk:忽略gtk+2.0 windows
  • --without-carbon: 不使用Mac OS上的X庫
  • --without-quicktime
  • --without-1394libs
  • --without-ffmpeg
  • --without-python
  • --without-swig
  • --enable-static :生成靜態庫
  • --disable-shared:不生成動態庫
  • CXX=armv4l-unknown-linux-g++ : 指定編譯工具
  • CPPFLAGS=-I/usr/include :OpenCV會用到一些dev的包,如png.h,jpeglib.h,大部分頭文件在/usr/include下。

如果在編譯時出現png.h: No such file or directory ,意即缺少開發包,比如在Debian下可以apt-get install libpng2-dev,或者到libpng的網站 http://www.libpng.org/pub/png/libpng.html ,編譯安裝開發包即可。

用文本编辑器打开 /etc/ld.so.conf 里面一般有一行include /etc/ld.so.conf.d/*. conf

在后面用分号隔开, 然后加入 /usr/local/lib 保存退出就可以了。 这里说明一下,ld.so.conf这个文件。以后你用opencv函数写成的程序,编译成可执行程序后,如果你使用的动态链接库,那么,系统会到这个文件里去找你所指定的这个目录,也就是说执行程序所需要的动态库都在/usr/local/lib下。

編譯常式

  • 編譯常式drawing.c
armv4l-unknown-linux-g++ `pkg-config --cflags --libs opencv`  drawing.c -o drawing
  • 編譯修改後的攝像頭標定程式:
armv4l-unknown-linux-g++ `pkg-config --cflags --libs opencv`  calibration.cpp -o calibration

將生成的可執行程式拷貝到開發板上,運行。如果出現缺少libstdc++庫的情況,可以在arm編譯器目錄下的lib目錄中查找,拷貝到開發板中,並確保程式可以找到即可。

1 則留言:

adam0720 提到...

楼主你好!
我用arm-linux-gcc编译的时候出现如下错误:
[root@utu-Linux]\$ ./drawing
OpenCV ERROR: Unspecified error (The function is not implemented. Rebuild the li
brary with Windows, GTK+ 2.x or Carbon support)
in function cvNamedWindow, window.cpp(71)
Terminating the application...
Segmentation fault

如果在配置的时候注释掉without-gtk编译通不过。

2.如果without-v4l 摄像头功能还能用不?
同样注释掉 without-v4l编译也通不过。

3.能否给点建议?谢谢!