首先本文主要内容是将opencv移植到zedboard的嵌入式linux中,并进行测试。写本文之前参考了xzyfeixiang,懒兔子,超群天晴,rainysky的博客与陆佳华的<嵌入式系统软硬件协同设计>,把我遇到的问题总结下。我的开发平台式win7+虚拟机VMare(安装ubuntu)。本文主要分两个部分:1 opencv在ubuntu上的安装与测试 2 opencv在zedboard上的移植与测试(一) opencv在ubuntu上安装与测试1 下载源码, 可以去opencv官网下载,因为我们在ubuntu上安装,要特别主要下载unix平台的,现在为止最新版本是opencv2.4.9参考地址:http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/download2  安装第三方库,sudo
apt-get
 install
build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev   libtiff4-dev  libswscale-dev libjasper-dev cmake  cmake-curses-gui这个一定要提前安装好,我出现过的一个编译错误就是:     OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp, line 598terminate called after throwing an instance of 'cv::Exception'
        what():  /home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp:598: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow查询网站后需要安装gtk 但是我安装了后问题没有解决,后来明白了,第三方库一定要在配置opencv前安装好,这个问题困扰了我很久,希望大家能够引以为戒。3   将源文件opencv2.4.9.zip拷贝到/opt/zedboard/opencv_pc(自建的目录,也可以其他的地方,但后续目录相应改变), 解压 unzip opencv2.4.9.zip;     解压后多出一个目录,进入opencv2.4.9目录 ,  mkdir build 进入build目录;执行命令.注 本文一些命令需要root账号命令,所以先进入root账号,在进行命令操作cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local    ../     注意../一定不要丢了,因为他需要CMakeList.txt文件,在上一层目录下。/usr/local是安装目录。/etc/ld.so.conf.d/opencv.conf
/usr/
local
/lib
/etc/
bash
.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/
local
/lib/pkgconfig

export 
PKG_CONFIG_PATH

<span style="font-size:18px;">/*code*/
#include "cv.h"
#include "highgui.h"
 
IplImage* doCanny(
    IplImage* in,
    double    lowThresh,
    double    highThresh,
    double    aperture)
{
    if (in->nChannels != 1)
        return(0); // Canny only handles gray scale images
    IplImage* out = cvCreateImage( 
        cvGetSize( in ),
        in->depth, //IPL_DEPTH_8U,    
        1);
    cvCanny( in, out, lowThresh, highThresh, aperture );
    return( out );
};
 
int main( int argc, char** argv )
{
  if(argc!= 3)printf("arguments error! format origin_image.bmp target_image.bmp\n");
  IplImage* img_rgb = cvLoadImage( argv[1] );
  IplImage* img_gry = cvCreateImage( cvSize( img_rgb->width,img_rgb->height ), img_rgb->depth, 1); 
  cvCvtColor(img_rgb, img_gry ,CV_BGR2GRAY);
 // cvNamedWindow("Example Gray", CV_WINDOW_AUTOSIZE );
 // cvNamedWindow("Example Canny", CV_WINDOW_AUTOSIZE );
 // cvShowImage("Example Gray", img_gry );
  IplImage* img_cny = doCanny( img_gry, 10, 100, 3 );
  if(cvSaveImage(argv[2],img_cny,0)!=0)
        printf("Save Image Successful\n");
 // cvShowImage("Example Canny", img_cny );
 // cvWaitKey(0);
  cvReleaseImage( &img_rgb);
  cvReleaseImage( &img_gry);
  cvReleaseImage( &img_cny);
 // cvDestroyWindow("Example Gray");
 // cvDestroyWindow("Example Canny");
 return 0;
}</span>