《rainysky陪你一起在zedboard上移植qt+opencv(六):在zedboard上运行Opencv.docx》由会员分享,可在线阅读,更多相关《rainysky陪你一起在zedboard上移植qt+opencv(六):在zedboard上运行Opencv.docx(5页珍藏版)》请在第一文库网上搜索。
1、rainysky陪你一起在Zedboard上移植qt+opencv(六):在Zedboard上运行Opencv和在PC机上一样,建立文件夹optzedboardOPenCV_zed,复制文件进来,解压缩:建立两个文件夹bui1d、insta11,如下图rootrainysky:opencv_zed#Is3jopencv-2.4.40penCV-2.4.4a.tar.bz2a;root0ratnysky:opencv_zed#cdopencv-2.4.4/bTOOt$ratnysky:opencv-2.4.4#nkdtrbui1drrootratnysky:opencv-2.4.4mkdtrin
2、sta11WWW.。Iecfansxomroot点rainysky:OPenCV2.4.4#Isr3rdpartyappscmakedatainc1udeinsta11aandroidbui1dCMake1tsts.txtdocindex.rsttosiarootranysky:opecv2.4.4在这里和PC不太一样了,需要设置编译环境,在。PenCV-2.4.4下面新建一个文件,文件名为too1chain,cmake,里面的内容为:set(CMAKE_SYSTEM_NAME1inux)set(CMAKE_SYSTEM_PROCESSORarm)set(CMAKE_C_COMPI1ER/ro
3、ot/CodeSourcery/Sourcery_CodeBench_1ite_for_Xi1inx_GNU_1inux/bin/arm-i1in-1inu-gnueabi-gcc)Set(CMAKE_CXX_COMPI1ER/root/CodeSourcery/Sourcery_CodeBench_1ite_for_Xi1inx_GNU_1inux/bin/arm-i1in-1inu-gnueabi-g+)进入bui1d文件里面,输入一下命令进行配置:cmake-DCMAKE_TOO1CHAIN_FI1E=too1chain.cmake-DCMAKE_INSTA11_PREFIX=/opt/
4、zedboard/opencv-zed/opencv-2.4.4/insta11./其中CMAKENSTA11.PREFIX,代表的是安装的路径,最好是新建一个新文件夹好保存,另外需要注意的是,最后的是./小心不要少敲一个点,否则会错的哦。ccmake./进行配置,配置的内容是所有的以WITH开头的选项全部选成OFF,(除了以TH_V41选为ON)因为这些需要第三方库支持的,要是选择这些的话就需要安装第三方库了。按C配置,按g生成并保存1root0ratnysky:opencv-2.4.4#Is3rdpartyappscnakedatainc1udeinsta11nodu1esREADME1,
5、androidbui1dCMake1ists.txtdocindex,rsttosp1atformssamp1esroot0ratnysky:oecv-2.4.4#cpnnthgfs基于Xt1tnxZyq书籍八OOIcha1n.sakeroot0ratnysky:opencv-2.4.4#IsJ3rdpartybui1ddatarandroidcnakedocappsCMake1tsts.txtinc1udeindex.rstinsta11tosnodu1esp1atformsREADMEake,root0rainysky:opencv-2.4.4#ake1root0rainysky:open
6、ev-2.4.4#cdbui1d/Jrootratysky:bui1d*ISroot0ra1nysky:bui1depwd/opt/zedboard/opencv_zed/opencv-2.4.4/bui1drootratnysky:bui1d#cnake-DCMAKEeTOO1CHAIN-FI1EtOo1chatn/A11_PREFIX=/opt/zedboard/opencv_zed/opencv-2.4.Insta11./配置完成后就输入make开始编译,编译完成后就是makeinsta11安装啦。安装完成后在insta11的文件夹里就是运行库啦。新建一个专门写程序的文件夹mkdirop
7、tzedboardopencv-zedcode在里面新建一个测试程序:vimedge_detecti_on.cpp这个代码是教材里面带的那个:/*code*/inc1udecv.hinc1udehighgui.hIp1Image*doCanny(Ip1Image*in,doub1eIowThresh,doub1ehighThresh,doub1eaperture)(if(in-nChanne1s!=1)return(0);/Cannyon1yhand1esgraysca1eimagesIp1Image*out=CvCreateImage(CvGetSize(in),in-depth,/IP1D
8、EPTH_8U,1);CVCanny(in,out,IowThresh,highThresh,aperture);return(out);;intmain(intargc,char*argv)(if(argc!=3)printf(zzargumentserror!formatoriginimage,bmptarget_image.bmpn);Ip1Image*imgrgb=Cv1oadImage(argv1);Ip1Image*imggry=CvCreateImage(cvSize(img_rgb-width,imgrgb-height),img_rgb-depth,1);CvCvtCo1or
9、(img_rgb,img_gry,CV_BGR2GRAY);/CvNamedWindow(Examp1eGray”,CV_WINDOW_AUTOSIZE);/CvNamedWindowCExampIeCanny,CV_WINDOW_AUTOSIZE);/CvShowImage(Examp1eGray”,img_gry);Ip1Image*img_cny=doCanny(img_gry,10,100,3);if(cvSave1mage(argv2,img_cny,0)!-O)printf(,zSaveImageSUCCeSSfU1n);/CvShowImage(Examp1eCanny”,img
10、_cny);/CvWaitKey(O);CvRe1easeImage(&imgrgb);CvRe1easeImage(&imggry);CvRe1easeImage(&imgcny);/CvDestroyWindow(zzExamp1eGrayz,);/CvDestroyWindow(,ExampIeCanny);returnO;)复制一个Iena图像进来,最好是一个.jpg格式和一个.bmp格式(作对比),并输入下面的命令进行交叉编译arm-i1in-1inu-gnueabi-g+-I/opt/zedboard/opencv-zed/opencv-2.4.4/insta11/inc1ude-
11、Ioptzedboard/opencv-zed/opencv-2.4.4/insta11/inc1ude/opencv-1opt/zedboard/opencv-zed/opencv-2.4.4/insta11/1ib-1opencv_core-1opencv_imgproc-1opencv_highgui-1opencv_m1-1opencv_video-1opencv_features2d-1opencv_ca1ib3d-1opencv_objdetect-1opencv_contrib-Iopencv1egacy-1opencv_f1ann./edge_detection.cpp-o./
12、edge_detection.o终端HQSIU,23:171,访客中OGrootraiysky:optzedboardopencv-zedcodefisV-rootratnysky:code#PWdoptzedboardopencv-zedcoderootratysky:code#Isedge-detectton.cpp1ea.bnp1ena.jpgrootrtnysky:codearn-xt1tnx-Iinux-gueabtg*-Ioptzedboardopecv-zedopencv-2.4.tnsta11tnc1ude-I/opt/zedboard/opencv_zed/opencv-2.
13、4.4tsta11tc1udeopecv1optzedboardopencv-zedopencv-2.4.4/tnsta11/1tbIoPenCV_Core-IoPenCVJngproc-IopencvJtghgut-IoPenCVJn1-1opencv-vtdeo-1opencv_features2d-1opencv-ca1tb3d1opencv_objdetect1opecv-cotrtbIoPenCV.1egacy-1opecv-f1an.edge-detectton.cpp-o./edge_detectton.oInfi1einc1udedfronoptzedboardopecv-ze
14、dopencv2cv2/f1ann/kneans_index.h:58:8,fronoptzedboardopecv-zedopecv2cv2f1ana11-tdtces.h:38,fronoptzedboardopecv-zedopecv2cv2f1anf1ann-base.hpp:44,fronoptzedboardopecv-zedopecv-2cv2f1anf1ann.hpp:50,fronoptzedboardopecv-zedopecv2cv/cv.h:69,4.Insta11/InC1Ude/open4.4八nsta11八r1udeOPen4.41nsta11tc1udeopen
15、4.4/tnsta11./tnc1u(Je/open4.4/tnsta11/tnc1.ude/openfrom.edge-detectton.cpp:25:optzedboardopencv-zedopencv-2.4.4/tnstaI1/tnc1.ude/opencv2/f1a1ogger.h:73:9:note:themang1ingofva-1tst,haschangedtnGCC4.4rootratnysky:code*Isedge_detectton.cppedge-detectto.o1ena.bmp1ena.jpgrootratnysky:COde/WWW.e1ecF如果要是想在zedboard板卡上面运行,还需要将opencv交