[视觉算法] 妙算上cuda、opencv以及qt的配置

一、安装CUDA(同官方PDF)
1. 访问下链接:
http://developer.download.nvidia ... uda-repo-l4t-r21.3-
6-5-prod_6.5-42_armhf.deb
2. 执行以下命令安装 “cuda-repo-l4t-r21.3-6-5-prod_6.5-42_armhf.deb”至操作系统。

[plain] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • sudo dpkg -i cuda-repo-l4t-r21.3-6-5-prod_6.5-42_armhf.deb  
  • sudo apt-get update  
  • sudo apt-get install cuda-toolkit-6-5  

具体请参考以下链接:https://developer.nvidia.com/embedded/linux-tegra

(想跑CUDA例程的可参考http://blog.csdn.net/FRD2009041510/article/details/42042807)

二、安装OpenCV

(这一步主要参照两个网站

1.http://blog.csdn.net/FRD2009041510/article/details/42930113   //图文教程挺详细的

2.http://elinux.org/Jetson/Installing_OpenCV)

1.安装 OpenCV4tegra
访问以下链接以下载安装包“ libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.
deb ”
http://developer.download.nvidia ... bopencv4tegra-repo_
l4t-r21_2.4.10.1_armhf.deb   //最新的库版本是2.4.12了
执行以下命令进行安装

[plain] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • sudo dpkg -i libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb  
  • sudo apt-get update  
  • sudo apt-get install libopencv4tegra libopencv4tegra-dev  

2.安装函数库


[plain] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • sudo add-apt-repository universe  
  • sudo apt-get update  
  • # Some general development libraries  
  • sudo apt-get install build-essential make cmake cmake-curses-gui g++  
  • # libav video input/output development libraries  
  • sudo apt-get install libavformat-dev libavutil-dev libswscale-dev  
  • # Video4Linux camera development libraries  
  • sudo apt-get install libv4l-dev  
  • # Eigen3 math development libraries  
  • sudo apt-get install libeigen3-dev  
  • # OpenGL development libraries (to allow creating graphical windows)  
  • sudo apt-get install libglew1.6-dev  
  • # GTK development libraries (to allow creating graphical windows)  
  • sudo apt-get install libgtk2.0-dev  

3.安装opencv源码

①.下载源码(推荐2.4.9)


http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip

②.解压



[plain] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • cd Downloads  
  • unzip opencv-2.4.9.zip  
  • mv opencv-2.4.9 ~  


③.Make


[plain] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • cd ~/opencv-2.4.9  
  • mkdir build  
  • cd build  
  • cmake -DWITH_CUDA=ON -DCUDA_ARCH_BIN="3.2" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF ..  
  • sudo make -j4 install  



④.配置环境变量

echo "# Use OpenCV and other custom-built libraries." >> ~/.bashrcecho "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/" >> ~/.bashrc
source ~/.bashrc
⑤.测试

第一个例子:边缘提取


# Test a simple OpenCV program. Creates a graphical window, hence you should plug a HDMI monitor in or use a remote viewer such as X Tunneling or VNC or TeamViewer on your desktop.cd ~/opencv-2.4.9/samples/cppg++ edge.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -o edge( Or for OpenCV 3.0: g++ edge.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -o edge)./edge 第二个例子:摄像头图像的拉普拉斯变换

# If you have a USB webcam plugged in to your board, then test one of the live camera programs and linking to every OpenCV module.g++ laplace.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o laplace 第三个例子:CPU和GPU进行图像的霍夫变换

# Test a GPU accelerated OpenCV sample.cd ../gpug++ houghlines.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o houghlines./houghlines ../cpp/logo_in_clutter.png 三、QT的安装与配置

1.安装,使用apt-get,编译opensource的方法没有通过//不过!!!貌似只安装qtcreater就行了,商店里有


sudo apt- get install qt4-dev- tools #开发包   sudo apt- get install qtcreator #IDE  sudo apt- get install qt4- doc #开发帮助文档   sudo apt- get install qt4- qtconfig #配置工具   sudo apt- get install qt4-demos #DEMO源码  QT 2 .配置(这一步的截图见csdn:http://blog.csdn.net/u012348655/article/details/50564223)

①.打开qt->Tools->Options->Build&Run

②.配置Qt Versions以及Compilers

在termial中输入which qmake以及which gcc把相应的地址添加进去

3.测试

新建一个控制台工程

在main.c中加入


[cpp] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • #include   
  • #include   
  • #include   
  • #include   
  • #include   
  • #include   
  •   
  • using namespace cv;  
  • using namespace std;  
  •   
  • int main(int argc, char *argv[])  
  • {  
  • //    QCoreApplication a(argc, argv);  
  •   
  •     namedWindow( "src", WINDOW_AUTOSIZE );  
  •     printf("hello lena\n");  
  •     Mat src1 = imread( "lena.jpg" );  
  •     while(1)  
  •     {  
  •         imshow( "src", src1 );  
  •         char c =  waitKey(30);  
  •         if( 27==c )  
  •             return 0;  
  •     }  
  •   
  • //    return a.exec();  
  • }  

在.pro文件中加入




[cpp] view plain copy

                               
登录/注册后可看大图

                               
登录/注册后可看大图


  • SOURCES += main.cpp  
  • INCLUDEPATH += /usr/local/include \  
  •                 /usr/local/include/opencv \  
  •                 /usr/local/include/opencv2  
  •   
  • LIBS += /usr/local/lib/libopencv_highgui.so \  
  •         /usr/local/lib/libopencv_core.so    \  
  •         /usr/local/lib/libopencv_imgproc.so  

在生成的调试文件夹中放入lena.jpg
然后运行

你可能感兴趣的:(兔小子备忘录)